babylon.d.ts 2.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142
  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. * Gets or sets a boolean used to define if the node must be serialized
  420. */
  421. doNotSerialize: boolean;
  422. /** @hidden */
  423. _isDisposed: boolean;
  424. /**
  425. * Gets a list of Animations associated with the node
  426. */
  427. animations: Animation[];
  428. protected _ranges: {
  429. [name: string]: Nullable<AnimationRange>;
  430. };
  431. /**
  432. * Callback raised when the node is ready to be used
  433. */
  434. onReady: (node: Node) => void;
  435. private _isEnabled;
  436. private _isParentEnabled;
  437. private _isReady;
  438. /** @hidden */
  439. _currentRenderId: number;
  440. private _parentRenderId;
  441. protected _childRenderId: number;
  442. /** @hidden */
  443. _waitingParentId: Nullable<string>;
  444. /** @hidden */
  445. _scene: Scene;
  446. /** @hidden */
  447. _cache: any;
  448. private _parentNode;
  449. private _children;
  450. /** @hidden */
  451. _worldMatrix: Matrix;
  452. /** @hidden */
  453. _worldMatrixDeterminant: number;
  454. /** @hidden */
  455. private _sceneRootNodesIndex;
  456. /**
  457. * Gets a boolean indicating if the node has been disposed
  458. * @returns true if the node was disposed
  459. */
  460. isDisposed(): boolean;
  461. /**
  462. * Gets or sets the parent of the node
  463. */
  464. parent: Nullable<Node>;
  465. private addToSceneRootNodes;
  466. private removeFromSceneRootNodes;
  467. private _animationPropertiesOverride;
  468. /**
  469. * Gets or sets the animation properties override
  470. */
  471. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  472. /**
  473. * Gets a string idenfifying the name of the class
  474. * @returns "Node" string
  475. */
  476. getClassName(): string;
  477. /**
  478. * An event triggered when the mesh is disposed
  479. */
  480. onDisposeObservable: Observable<Node>;
  481. private _onDisposeObserver;
  482. /**
  483. * Sets a callback that will be raised when the node will be disposed
  484. */
  485. onDispose: () => void;
  486. /**
  487. * Creates a new Node
  488. * @param name the name and id to be given to this node
  489. * @param scene the scene this node will be added to
  490. * @param addToRootNodes the node will be added to scene.rootNodes
  491. */
  492. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  493. /**
  494. * Gets the scene of the node
  495. * @returns a scene
  496. */
  497. getScene(): Scene;
  498. /**
  499. * Gets the engine of the node
  500. * @returns a Engine
  501. */
  502. getEngine(): Engine;
  503. private _behaviors;
  504. /**
  505. * Attach a behavior to the node
  506. * @see http://doc.babylonjs.com/features/behaviour
  507. * @param behavior defines the behavior to attach
  508. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  509. * @returns the current Node
  510. */
  511. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  512. /**
  513. * Remove an attached behavior
  514. * @see http://doc.babylonjs.com/features/behaviour
  515. * @param behavior defines the behavior to attach
  516. * @returns the current Node
  517. */
  518. removeBehavior(behavior: Behavior<Node>): Node;
  519. /**
  520. * Gets the list of attached behaviors
  521. * @see http://doc.babylonjs.com/features/behaviour
  522. */
  523. readonly behaviors: Behavior<Node>[];
  524. /**
  525. * Gets an attached behavior by name
  526. * @param name defines the name of the behavior to look for
  527. * @see http://doc.babylonjs.com/features/behaviour
  528. * @returns null if behavior was not found else the requested behavior
  529. */
  530. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  531. /**
  532. * Returns the latest update of the World matrix
  533. * @returns a Matrix
  534. */
  535. getWorldMatrix(): Matrix;
  536. /** @hidden */
  537. _getWorldMatrixDeterminant(): number;
  538. /**
  539. * Returns directly the latest state of the mesh World matrix.
  540. * A Matrix is returned.
  541. */
  542. readonly worldMatrixFromCache: Matrix;
  543. /** @hidden */
  544. _initCache(): void;
  545. /** @hidden */
  546. updateCache(force?: boolean): void;
  547. /** @hidden */
  548. _updateCache(ignoreParentClass?: boolean): void;
  549. /** @hidden */
  550. _isSynchronized(): boolean;
  551. /** @hidden */
  552. _markSyncedWithParent(): void;
  553. /** @hidden */
  554. isSynchronizedWithParent(): boolean;
  555. /** @hidden */
  556. isSynchronized(): boolean;
  557. /**
  558. * Is this node ready to be used/rendered
  559. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  560. * @return true if the node is ready
  561. */
  562. isReady(completeCheck?: boolean): boolean;
  563. /**
  564. * Is this node enabled?
  565. * 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
  566. * @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
  567. * @return whether this node (and its parent) is enabled
  568. */
  569. isEnabled(checkAncestors?: boolean): boolean;
  570. /** @hidden */
  571. protected _syncParentEnabledState(): void;
  572. /**
  573. * Set the enabled state of this node
  574. * @param value defines the new enabled state
  575. */
  576. setEnabled(value: boolean): void;
  577. /**
  578. * Is this node a descendant of the given node?
  579. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  580. * @param ancestor defines the parent node to inspect
  581. * @returns a boolean indicating if this node is a descendant of the given node
  582. */
  583. isDescendantOf(ancestor: Node): boolean;
  584. /** @hidden */
  585. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  586. /**
  587. * Will return all nodes that have this node as ascendant
  588. * @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
  589. * @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
  590. * @return all children nodes of all types
  591. */
  592. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  593. /**
  594. * Get all child-meshes of this node
  595. * @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
  596. * @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
  597. * @returns an array of AbstractMesh
  598. */
  599. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  600. /**
  601. * Get all child-transformNodes of this node
  602. * @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
  603. * @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
  604. * @returns an array of TransformNode
  605. */
  606. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  607. /**
  608. * Get all direct children of this node
  609. * @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
  610. * @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)
  611. * @returns an array of Node
  612. */
  613. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  614. /** @hidden */
  615. _setReady(state: boolean): void;
  616. /**
  617. * Get an animation by name
  618. * @param name defines the name of the animation to look for
  619. * @returns null if not found else the requested animation
  620. */
  621. getAnimationByName(name: string): Nullable<Animation>;
  622. /**
  623. * Creates an animation range for this node
  624. * @param name defines the name of the range
  625. * @param from defines the starting key
  626. * @param to defines the end key
  627. */
  628. createAnimationRange(name: string, from: number, to: number): void;
  629. /**
  630. * Delete a specific animation range
  631. * @param name defines the name of the range to delete
  632. * @param deleteFrames defines if animation frames from the range must be deleted as well
  633. */
  634. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  635. /**
  636. * Get an animation range by name
  637. * @param name defines the name of the animation range to look for
  638. * @returns null if not found else the requested animation range
  639. */
  640. getAnimationRange(name: string): Nullable<AnimationRange>;
  641. /**
  642. * Will start the animation sequence
  643. * @param name defines the range frames for animation sequence
  644. * @param loop defines if the animation should loop (false by default)
  645. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  646. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  647. * @returns the object created for this animation. If range does not exist, it will return null
  648. */
  649. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  650. /**
  651. * Serialize animation ranges into a JSON compatible object
  652. * @returns serialization object
  653. */
  654. serializeAnimationRanges(): any;
  655. /**
  656. * Computes the world matrix of the node
  657. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  658. * @returns the world matrix
  659. */
  660. computeWorldMatrix(force?: boolean): Matrix;
  661. /**
  662. * Releases resources associated with this node.
  663. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  664. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  665. */
  666. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  667. /**
  668. * Parse animation range data from a serialization object and store them into a given node
  669. * @param node defines where to store the animation ranges
  670. * @param parsedNode defines the serialization object to read data from
  671. * @param scene defines the hosting scene
  672. */
  673. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  674. }
  675. }
  676. declare module BABYLON {
  677. /**
  678. * Define an interface for all classes that will hold resources
  679. */
  680. interface IDisposable {
  681. /**
  682. * Releases all held resources
  683. */
  684. dispose(): void;
  685. }
  686. /**
  687. * This class is used by the onRenderingGroupObservable
  688. */
  689. class RenderingGroupInfo {
  690. /**
  691. * The Scene that being rendered
  692. */
  693. scene: Scene;
  694. /**
  695. * The camera currently used for the rendering pass
  696. */
  697. camera: Nullable<Camera>;
  698. /**
  699. * The ID of the renderingGroup being processed
  700. */
  701. renderingGroupId: number;
  702. }
  703. /** Interface defining initialization parameters for Scene class */
  704. interface SceneOptions {
  705. /**
  706. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by Id
  707. * It will improve performance when the number of geometries becomes important.
  708. */
  709. useGeometryIdsMap?: boolean;
  710. /**
  711. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  712. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  713. */
  714. useMaterialMeshMap?: boolean;
  715. /**
  716. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  717. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  718. */
  719. useClonedMeshhMap?: boolean;
  720. }
  721. /**
  722. * Represents a scene to be rendered by the engine.
  723. * @see http://doc.babylonjs.com/features/scene
  724. */
  725. class Scene extends AbstractScene implements IAnimatable {
  726. private static _uniqueIdCounter;
  727. /** The fog is deactivated */
  728. static readonly FOGMODE_NONE: number;
  729. /** The fog density is following an exponential function */
  730. static readonly FOGMODE_EXP: number;
  731. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  732. static readonly FOGMODE_EXP2: number;
  733. /** The fog density is following a linear function. */
  734. static readonly FOGMODE_LINEAR: number;
  735. /**
  736. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  737. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  738. */
  739. static MinDeltaTime: number;
  740. /**
  741. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  742. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  743. */
  744. static MaxDeltaTime: number;
  745. /**
  746. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  747. */
  748. autoClear: boolean;
  749. /**
  750. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  751. */
  752. autoClearDepthAndStencil: boolean;
  753. /**
  754. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  755. */
  756. clearColor: Color4;
  757. /**
  758. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  759. */
  760. ambientColor: Color3;
  761. /** @hidden */
  762. _environmentBRDFTexture: BaseTexture;
  763. /** @hidden */
  764. protected _environmentTexture: BaseTexture;
  765. /**
  766. * Texture used in all pbr material as the reflection texture.
  767. * As in the majority of the scene they are the same (exception for multi room and so on),
  768. * this is easier to reference from here than from all the materials.
  769. */
  770. /**
  771. * Texture used in all pbr material as the reflection texture.
  772. * As in the majority of the scene they are the same (exception for multi room and so on),
  773. * this is easier to set here than in all the materials.
  774. */
  775. environmentTexture: BaseTexture;
  776. /** @hidden */
  777. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  778. /**
  779. * Default image processing configuration used either in the rendering
  780. * Forward main pass or through the imageProcessingPostProcess if present.
  781. * As in the majority of the scene they are the same (exception for multi camera),
  782. * this is easier to reference from here than from all the materials and post process.
  783. *
  784. * No setter as we it is a shared configuration, you can set the values instead.
  785. */
  786. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  787. private _forceWireframe;
  788. /**
  789. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  790. */
  791. forceWireframe: boolean;
  792. private _forcePointsCloud;
  793. /**
  794. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  795. */
  796. forcePointsCloud: boolean;
  797. /**
  798. * Gets or sets the active clipplane 1
  799. */
  800. clipPlane: Nullable<Plane>;
  801. /**
  802. * Gets or sets the active clipplane 2
  803. */
  804. clipPlane2: Nullable<Plane>;
  805. /**
  806. * Gets or sets the active clipplane 3
  807. */
  808. clipPlane3: Nullable<Plane>;
  809. /**
  810. * Gets or sets the active clipplane 4
  811. */
  812. clipPlane4: Nullable<Plane>;
  813. /**
  814. * Gets or sets a boolean indicating if animations are enabled
  815. */
  816. animationsEnabled: boolean;
  817. private _animationPropertiesOverride;
  818. /**
  819. * Gets or sets the animation properties override
  820. */
  821. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  822. /**
  823. * Gets or sets a boolean indicating if a constant deltatime has to be used
  824. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  825. */
  826. useConstantAnimationDeltaTime: boolean;
  827. /**
  828. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  829. * Please note that it requires to run a ray cast through the scene on every frame
  830. */
  831. constantlyUpdateMeshUnderPointer: boolean;
  832. /**
  833. * Defines the HTML cursor to use when hovering over interactive elements
  834. */
  835. hoverCursor: string;
  836. /**
  837. * Defines the HTML default cursor to use (empty by default)
  838. */
  839. defaultCursor: string;
  840. /**
  841. * This is used to call preventDefault() on pointer down
  842. * in order to block unwanted artifacts like system double clicks
  843. */
  844. preventDefaultOnPointerDown: boolean;
  845. /**
  846. * This is used to call preventDefault() on pointer up
  847. * in order to block unwanted artifacts like system double clicks
  848. */
  849. preventDefaultOnPointerUp: boolean;
  850. /**
  851. * Gets or sets user defined metadata
  852. */
  853. metadata: any;
  854. /**
  855. * Gets the name of the plugin used to load this scene (null by default)
  856. */
  857. loadingPluginName: string;
  858. /**
  859. * Use this array to add regular expressions used to disable offline support for specific urls
  860. */
  861. disableOfflineSupportExceptionRules: RegExp[];
  862. /**
  863. * An event triggered when the scene is disposed.
  864. */
  865. onDisposeObservable: Observable<Scene>;
  866. private _onDisposeObserver;
  867. /** Sets a function to be executed when this scene is disposed. */
  868. onDispose: () => void;
  869. /**
  870. * An event triggered before rendering the scene (right after animations and physics)
  871. */
  872. onBeforeRenderObservable: Observable<Scene>;
  873. private _onBeforeRenderObserver;
  874. /** Sets a function to be executed before rendering this scene */
  875. beforeRender: Nullable<() => void>;
  876. /**
  877. * An event triggered after rendering the scene
  878. */
  879. onAfterRenderObservable: Observable<Scene>;
  880. private _onAfterRenderObserver;
  881. /** Sets a function to be executed after rendering this scene */
  882. afterRender: Nullable<() => void>;
  883. /**
  884. * An event triggered before animating the scene
  885. */
  886. onBeforeAnimationsObservable: Observable<Scene>;
  887. /**
  888. * An event triggered after animations processing
  889. */
  890. onAfterAnimationsObservable: Observable<Scene>;
  891. /**
  892. * An event triggered before draw calls are ready to be sent
  893. */
  894. onBeforeDrawPhaseObservable: Observable<Scene>;
  895. /**
  896. * An event triggered after draw calls have been sent
  897. */
  898. onAfterDrawPhaseObservable: Observable<Scene>;
  899. /**
  900. * An event triggered when the scene is ready
  901. */
  902. onReadyObservable: Observable<Scene>;
  903. /**
  904. * An event triggered before rendering a camera
  905. */
  906. onBeforeCameraRenderObservable: Observable<Camera>;
  907. private _onBeforeCameraRenderObserver;
  908. /** Sets a function to be executed before rendering a camera*/
  909. beforeCameraRender: () => void;
  910. /**
  911. * An event triggered after rendering a camera
  912. */
  913. onAfterCameraRenderObservable: Observable<Camera>;
  914. private _onAfterCameraRenderObserver;
  915. /** Sets a function to be executed after rendering a camera*/
  916. afterCameraRender: () => void;
  917. /**
  918. * An event triggered when active meshes evaluation is about to start
  919. */
  920. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  921. /**
  922. * An event triggered when active meshes evaluation is done
  923. */
  924. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  925. /**
  926. * An event triggered when particles rendering is about to start
  927. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  928. */
  929. onBeforeParticlesRenderingObservable: Observable<Scene>;
  930. /**
  931. * An event triggered when particles rendering is done
  932. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  933. */
  934. onAfterParticlesRenderingObservable: Observable<Scene>;
  935. /**
  936. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  937. */
  938. onDataLoadedObservable: Observable<Scene>;
  939. /**
  940. * An event triggered when a camera is created
  941. */
  942. onNewCameraAddedObservable: Observable<Camera>;
  943. /**
  944. * An event triggered when a camera is removed
  945. */
  946. onCameraRemovedObservable: Observable<Camera>;
  947. /**
  948. * An event triggered when a light is created
  949. */
  950. onNewLightAddedObservable: Observable<Light>;
  951. /**
  952. * An event triggered when a light is removed
  953. */
  954. onLightRemovedObservable: Observable<Light>;
  955. /**
  956. * An event triggered when a geometry is created
  957. */
  958. onNewGeometryAddedObservable: Observable<Geometry>;
  959. /**
  960. * An event triggered when a geometry is removed
  961. */
  962. onGeometryRemovedObservable: Observable<Geometry>;
  963. /**
  964. * An event triggered when a transform node is created
  965. */
  966. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  967. /**
  968. * An event triggered when a transform node is removed
  969. */
  970. onTransformNodeRemovedObservable: Observable<TransformNode>;
  971. /**
  972. * An event triggered when a mesh is created
  973. */
  974. onNewMeshAddedObservable: Observable<AbstractMesh>;
  975. /**
  976. * An event triggered when a mesh is removed
  977. */
  978. onMeshRemovedObservable: Observable<AbstractMesh>;
  979. /**
  980. * An event triggered when a material is created
  981. */
  982. onNewMaterialAddedObservable: Observable<Material>;
  983. /**
  984. * An event triggered when a material is removed
  985. */
  986. onMaterialRemovedObservable: Observable<Material>;
  987. /**
  988. * An event triggered when a texture is created
  989. */
  990. onNewTextureAddedObservable: Observable<BaseTexture>;
  991. /**
  992. * An event triggered when a texture is removed
  993. */
  994. onTextureRemovedObservable: Observable<BaseTexture>;
  995. /**
  996. * An event triggered when render targets are about to be rendered
  997. * Can happen multiple times per frame.
  998. */
  999. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  1000. /**
  1001. * An event triggered when render targets were rendered.
  1002. * Can happen multiple times per frame.
  1003. */
  1004. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  1005. /**
  1006. * An event triggered before calculating deterministic simulation step
  1007. */
  1008. onBeforeStepObservable: Observable<Scene>;
  1009. /**
  1010. * An event triggered after calculating deterministic simulation step
  1011. */
  1012. onAfterStepObservable: Observable<Scene>;
  1013. /**
  1014. * An event triggered when the activeCamera property is updated
  1015. */
  1016. onActiveCameraChanged: Observable<Scene>;
  1017. /**
  1018. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  1019. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1020. * 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)
  1021. */
  1022. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1023. /**
  1024. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  1025. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1026. * 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)
  1027. */
  1028. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1029. /**
  1030. * This Observable will when a mesh has been imported into the scene.
  1031. */
  1032. onMeshImportedObservable: Observable<AbstractMesh>;
  1033. private _registeredForLateAnimationBindings;
  1034. /**
  1035. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  1036. */
  1037. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  1038. /**
  1039. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  1040. */
  1041. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  1042. /**
  1043. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  1044. */
  1045. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  1046. private _onPointerMove;
  1047. private _onPointerDown;
  1048. private _onPointerUp;
  1049. /** Callback called when a pointer move is detected */
  1050. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1051. /** Callback called when a pointer down is detected */
  1052. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1053. /** Callback called when a pointer up is detected */
  1054. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  1055. /** Callback called when a pointer pick is detected */
  1056. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  1057. /**
  1058. * 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).
  1059. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  1060. */
  1061. onPrePointerObservable: Observable<PointerInfoPre>;
  1062. /**
  1063. * Observable event triggered each time an input event is received from the rendering canvas
  1064. */
  1065. onPointerObservable: Observable<PointerInfo>;
  1066. /**
  1067. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  1068. */
  1069. readonly unTranslatedPointer: Vector2;
  1070. /** The distance in pixel that you have to move to prevent some events */
  1071. static DragMovementThreshold: number;
  1072. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1073. static LongPressDelay: number;
  1074. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1075. static DoubleClickDelay: number;
  1076. /** If you need to check double click without raising a single click at first click, enable this flag */
  1077. static ExclusiveDoubleClickMode: boolean;
  1078. private _initClickEvent;
  1079. private _initActionManager;
  1080. private _delayedSimpleClick;
  1081. private _delayedSimpleClickTimeout;
  1082. private _previousDelayedSimpleClickTimeout;
  1083. private _meshPickProceed;
  1084. private _previousButtonPressed;
  1085. private _currentPickResult;
  1086. private _previousPickResult;
  1087. private _totalPointersPressed;
  1088. private _doubleClickOccured;
  1089. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1090. cameraToUseForPointers: Nullable<Camera>;
  1091. private _pointerX;
  1092. private _pointerY;
  1093. private _unTranslatedPointerX;
  1094. private _unTranslatedPointerY;
  1095. private _startingPointerPosition;
  1096. private _previousStartingPointerPosition;
  1097. private _startingPointerTime;
  1098. private _previousStartingPointerTime;
  1099. private _pointerCaptures;
  1100. private _timeAccumulator;
  1101. private _currentStepId;
  1102. private _currentInternalStep;
  1103. /** @hidden */
  1104. _mirroredCameraPosition: Nullable<Vector3>;
  1105. /**
  1106. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1107. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1108. */
  1109. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1110. /**
  1111. * Observable event triggered each time an keyboard event is received from the hosting window
  1112. */
  1113. onKeyboardObservable: Observable<KeyboardInfo>;
  1114. private _onKeyDown;
  1115. private _onKeyUp;
  1116. private _onCanvasFocusObserver;
  1117. private _onCanvasBlurObserver;
  1118. private _useRightHandedSystem;
  1119. /**
  1120. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1121. */
  1122. useRightHandedSystem: boolean;
  1123. /**
  1124. * Sets the step Id used by deterministic lock step
  1125. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1126. * @param newStepId defines the step Id
  1127. */
  1128. setStepId(newStepId: number): void;
  1129. /**
  1130. * Gets the step Id used by deterministic lock step
  1131. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1132. * @returns the step Id
  1133. */
  1134. getStepId(): number;
  1135. /**
  1136. * Gets the internal step used by deterministic lock step
  1137. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1138. * @returns the internal step
  1139. */
  1140. getInternalStep(): number;
  1141. private _fogEnabled;
  1142. /**
  1143. * Gets or sets a boolean indicating if fog is enabled on this scene
  1144. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1145. * (Default is true)
  1146. */
  1147. fogEnabled: boolean;
  1148. private _fogMode;
  1149. /**
  1150. * Gets or sets the fog mode to use
  1151. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1152. * | mode | value |
  1153. * | --- | --- |
  1154. * | FOGMODE_NONE | 0 |
  1155. * | FOGMODE_EXP | 1 |
  1156. * | FOGMODE_EXP2 | 2 |
  1157. * | FOGMODE_LINEAR | 3 |
  1158. */
  1159. fogMode: number;
  1160. /**
  1161. * Gets or sets the fog color to use
  1162. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1163. * (Default is Color3(0.2, 0.2, 0.3))
  1164. */
  1165. fogColor: Color3;
  1166. /**
  1167. * Gets or sets the fog density to use
  1168. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1169. * (Default is 0.1)
  1170. */
  1171. fogDensity: number;
  1172. /**
  1173. * Gets or sets the fog start distance to use
  1174. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1175. * (Default is 0)
  1176. */
  1177. fogStart: number;
  1178. /**
  1179. * Gets or sets the fog end distance to use
  1180. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1181. * (Default is 1000)
  1182. */
  1183. fogEnd: number;
  1184. private _shadowsEnabled;
  1185. /**
  1186. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1187. */
  1188. shadowsEnabled: boolean;
  1189. private _lightsEnabled;
  1190. /**
  1191. * Gets or sets a boolean indicating if lights are enabled on this scene
  1192. */
  1193. lightsEnabled: boolean;
  1194. /** All of the active cameras added to this scene. */
  1195. activeCameras: Camera[];
  1196. private _activeCamera;
  1197. /** Gets or sets the current active camera */
  1198. activeCamera: Nullable<Camera>;
  1199. private _defaultMaterial;
  1200. /** The default material used on meshes when no material is affected */
  1201. /** The default material used on meshes when no material is affected */
  1202. defaultMaterial: Material;
  1203. private _texturesEnabled;
  1204. /**
  1205. * Gets or sets a boolean indicating if textures are enabled on this scene
  1206. */
  1207. texturesEnabled: boolean;
  1208. /**
  1209. * Gets or sets a boolean indicating if particles are enabled on this scene
  1210. */
  1211. particlesEnabled: boolean;
  1212. /**
  1213. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1214. */
  1215. spritesEnabled: boolean;
  1216. private _skeletonsEnabled;
  1217. /**
  1218. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1219. */
  1220. skeletonsEnabled: boolean;
  1221. /**
  1222. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1223. */
  1224. lensFlaresEnabled: boolean;
  1225. /**
  1226. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1227. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1228. */
  1229. collisionsEnabled: boolean;
  1230. private _workerCollisions;
  1231. /** @hidden */
  1232. collisionCoordinator: ICollisionCoordinator;
  1233. /**
  1234. * Defines the gravity applied to this scene (used only for collisions)
  1235. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1236. */
  1237. gravity: Vector3;
  1238. /**
  1239. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1240. */
  1241. postProcessesEnabled: boolean;
  1242. /**
  1243. * The list of postprocesses added to the scene
  1244. */
  1245. postProcesses: PostProcess[];
  1246. /**
  1247. * Gets the current postprocess manager
  1248. */
  1249. postProcessManager: PostProcessManager;
  1250. /**
  1251. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1252. */
  1253. renderTargetsEnabled: boolean;
  1254. /**
  1255. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1256. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1257. */
  1258. dumpNextRenderTargets: boolean;
  1259. /**
  1260. * The list of user defined render targets added to the scene
  1261. */
  1262. customRenderTargets: RenderTargetTexture[];
  1263. /**
  1264. * Defines if texture loading must be delayed
  1265. * If true, textures will only be loaded when they need to be rendered
  1266. */
  1267. useDelayedTextureLoading: boolean;
  1268. /**
  1269. * Gets the list of meshes imported to the scene through SceneLoader
  1270. */
  1271. importedMeshesFiles: String[];
  1272. /**
  1273. * Gets or sets a boolean indicating if probes are enabled on this scene
  1274. */
  1275. probesEnabled: boolean;
  1276. /**
  1277. * Gets or sets the current offline provider to use to store scene data
  1278. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1279. */
  1280. offlineProvider: IOfflineProvider;
  1281. /**
  1282. * Gets or sets the action manager associated with the scene
  1283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1284. */
  1285. actionManager: ActionManager;
  1286. private _meshesForIntersections;
  1287. /**
  1288. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1289. */
  1290. proceduralTexturesEnabled: boolean;
  1291. private _engine;
  1292. private _totalVertices;
  1293. /** @hidden */
  1294. _activeIndices: PerfCounter;
  1295. /** @hidden */
  1296. _activeParticles: PerfCounter;
  1297. /** @hidden */
  1298. _activeBones: PerfCounter;
  1299. private _animationRatio;
  1300. private _animationTimeLast;
  1301. private _animationTime;
  1302. /**
  1303. * Gets or sets a general scale for animation speed
  1304. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1305. */
  1306. animationTimeScale: number;
  1307. /** @hidden */
  1308. _cachedMaterial: Nullable<Material>;
  1309. /** @hidden */
  1310. _cachedEffect: Nullable<Effect>;
  1311. /** @hidden */
  1312. _cachedVisibility: Nullable<number>;
  1313. private _renderId;
  1314. private _frameId;
  1315. private _executeWhenReadyTimeoutId;
  1316. private _intermediateRendering;
  1317. private _viewUpdateFlag;
  1318. private _projectionUpdateFlag;
  1319. private _alternateViewUpdateFlag;
  1320. private _alternateProjectionUpdateFlag;
  1321. /** @hidden */
  1322. _toBeDisposed: Nullable<IDisposable>[];
  1323. private _activeRequests;
  1324. private _pendingData;
  1325. private _isDisposed;
  1326. /**
  1327. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1328. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1329. */
  1330. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1331. private _activeMeshes;
  1332. private _processedMaterials;
  1333. private _renderTargets;
  1334. /** @hidden */
  1335. _activeParticleSystems: SmartArray<IParticleSystem>;
  1336. private _activeSkeletons;
  1337. private _softwareSkinnedMeshes;
  1338. private _renderingManager;
  1339. /** @hidden */
  1340. _activeAnimatables: Animatable[];
  1341. private _transformMatrix;
  1342. private _sceneUbo;
  1343. private _alternateSceneUbo;
  1344. private _pickWithRayInverseMatrix;
  1345. private _viewMatrix;
  1346. private _projectionMatrix;
  1347. private _alternateViewMatrix;
  1348. private _alternateProjectionMatrix;
  1349. private _alternateTransformMatrix;
  1350. private _useAlternateCameraConfiguration;
  1351. private _alternateRendering;
  1352. private _wheelEventName;
  1353. /** @hidden */
  1354. _forcedViewPosition: Nullable<Vector3>;
  1355. /** @hidden */
  1356. readonly _isAlternateRenderingEnabled: boolean;
  1357. private _frustumPlanes;
  1358. /**
  1359. * Gets the list of frustum planes (built from the active camera)
  1360. */
  1361. readonly frustumPlanes: Plane[];
  1362. /**
  1363. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1364. * This is useful if there are more lights that the maximum simulteanous authorized
  1365. */
  1366. requireLightSorting: boolean;
  1367. /** @hidden */
  1368. readonly useMaterialMeshMap: boolean;
  1369. /** @hidden */
  1370. readonly useClonedMeshhMap: boolean;
  1371. private _pointerOverMesh;
  1372. private _pickedDownMesh;
  1373. private _pickedUpMesh;
  1374. private _externalData;
  1375. private _uid;
  1376. /**
  1377. * @hidden
  1378. * Backing store of defined scene components.
  1379. */
  1380. _components: ISceneComponent[];
  1381. /**
  1382. * @hidden
  1383. * Backing store of defined scene components.
  1384. */
  1385. _serializableComponents: ISceneSerializableComponent[];
  1386. /**
  1387. * List of components to register on the next registration step.
  1388. */
  1389. private _transientComponents;
  1390. /**
  1391. * Registers the transient components if needed.
  1392. */
  1393. private _registerTransientComponents;
  1394. /**
  1395. * @hidden
  1396. * Add a component to the scene.
  1397. * Note that the ccomponent could be registered on th next frame if this is called after
  1398. * the register component stage.
  1399. * @param component Defines the component to add to the scene
  1400. */
  1401. _addComponent(component: ISceneComponent): void;
  1402. /**
  1403. * @hidden
  1404. * Gets a component from the scene.
  1405. * @param name defines the name of the component to retrieve
  1406. * @returns the component or null if not present
  1407. */
  1408. _getComponent(name: string): Nullable<ISceneComponent>;
  1409. /**
  1410. * @hidden
  1411. * Defines the actions happening before camera updates.
  1412. */
  1413. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1414. /**
  1415. * @hidden
  1416. * Defines the actions happening before clear the canvas.
  1417. */
  1418. _beforeClearStage: Stage<SimpleStageAction>;
  1419. /**
  1420. * @hidden
  1421. * Defines the actions when collecting render targets for the frame.
  1422. */
  1423. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1424. /**
  1425. * @hidden
  1426. * Defines the actions happening for one camera in the frame.
  1427. */
  1428. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1429. /**
  1430. * @hidden
  1431. * Defines the actions happening during the per mesh ready checks.
  1432. */
  1433. _isReadyForMeshStage: Stage<MeshStageAction>;
  1434. /**
  1435. * @hidden
  1436. * Defines the actions happening before evaluate active mesh checks.
  1437. */
  1438. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1439. /**
  1440. * @hidden
  1441. * Defines the actions happening during the evaluate sub mesh checks.
  1442. */
  1443. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1444. /**
  1445. * @hidden
  1446. * Defines the actions happening during the active mesh stage.
  1447. */
  1448. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1449. /**
  1450. * @hidden
  1451. * Defines the actions happening during the per camera render target step.
  1452. */
  1453. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1454. /**
  1455. * @hidden
  1456. * Defines the actions happening just before the active camera is drawing.
  1457. */
  1458. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1459. /**
  1460. * @hidden
  1461. * Defines the actions happening just before a render target is drawing.
  1462. */
  1463. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1464. /**
  1465. * @hidden
  1466. * Defines the actions happening just before a rendering group is drawing.
  1467. */
  1468. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1469. /**
  1470. * @hidden
  1471. * Defines the actions happening just before a mesh is drawing.
  1472. */
  1473. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1474. /**
  1475. * @hidden
  1476. * Defines the actions happening just after a mesh has been drawn.
  1477. */
  1478. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1479. /**
  1480. * @hidden
  1481. * Defines the actions happening just after a rendering group has been drawn.
  1482. */
  1483. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1484. /**
  1485. * @hidden
  1486. * Defines the actions happening just after the active camera has been drawn.
  1487. */
  1488. _afterCameraDrawStage: Stage<CameraStageAction>;
  1489. /**
  1490. * @hidden
  1491. * Defines the actions happening just after a render target has been drawn.
  1492. */
  1493. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1494. /**
  1495. * @hidden
  1496. * Defines the actions happening just after rendering all cameras and computing intersections.
  1497. */
  1498. _afterRenderStage: Stage<SimpleStageAction>;
  1499. /**
  1500. * @hidden
  1501. * Defines the actions happening when a pointer move event happens.
  1502. */
  1503. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1504. /**
  1505. * @hidden
  1506. * Defines the actions happening when a pointer down event happens.
  1507. */
  1508. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1509. /**
  1510. * @hidden
  1511. * Defines the actions happening when a pointer up event happens.
  1512. */
  1513. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1514. /**
  1515. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  1516. */
  1517. private geometriesById;
  1518. /**
  1519. * Creates a new Scene
  1520. * @param engine defines the engine to use to render this scene
  1521. */
  1522. constructor(engine: Engine, options?: SceneOptions);
  1523. private _defaultMeshCandidates;
  1524. /**
  1525. * @hidden
  1526. */
  1527. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1528. private _defaultSubMeshCandidates;
  1529. /**
  1530. * @hidden
  1531. */
  1532. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1533. /**
  1534. * Sets the default candidate providers for the scene.
  1535. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1536. * and getCollidingSubMeshCandidates to their default function
  1537. */
  1538. setDefaultCandidateProviders(): void;
  1539. /**
  1540. * Gets a boolean indicating if collisions are processed on a web worker
  1541. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1542. */
  1543. workerCollisions: boolean;
  1544. /**
  1545. * Gets the mesh that is currently under the pointer
  1546. */
  1547. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1548. /**
  1549. * Gets the current on-screen X position of the pointer
  1550. */
  1551. readonly pointerX: number;
  1552. /**
  1553. * Gets the current on-screen Y position of the pointer
  1554. */
  1555. readonly pointerY: number;
  1556. /**
  1557. * Gets the cached material (ie. the latest rendered one)
  1558. * @returns the cached material
  1559. */
  1560. getCachedMaterial(): Nullable<Material>;
  1561. /**
  1562. * Gets the cached effect (ie. the latest rendered one)
  1563. * @returns the cached effect
  1564. */
  1565. getCachedEffect(): Nullable<Effect>;
  1566. /**
  1567. * Gets the cached visibility state (ie. the latest rendered one)
  1568. * @returns the cached visibility state
  1569. */
  1570. getCachedVisibility(): Nullable<number>;
  1571. /**
  1572. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1573. * @param material defines the current material
  1574. * @param effect defines the current effect
  1575. * @param visibility defines the current visibility state
  1576. * @returns true if one parameter is not cached
  1577. */
  1578. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1579. /**
  1580. * Gets the engine associated with the scene
  1581. * @returns an Engine
  1582. */
  1583. getEngine(): Engine;
  1584. /**
  1585. * Gets the total number of vertices rendered per frame
  1586. * @returns the total number of vertices rendered per frame
  1587. */
  1588. getTotalVertices(): number;
  1589. /**
  1590. * Gets the performance counter for total vertices
  1591. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1592. */
  1593. readonly totalVerticesPerfCounter: PerfCounter;
  1594. /**
  1595. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1596. * @returns the total number of active indices rendered per frame
  1597. */
  1598. getActiveIndices(): number;
  1599. /**
  1600. * Gets the performance counter for active indices
  1601. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1602. */
  1603. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1604. /**
  1605. * Gets the total number of active particles rendered per frame
  1606. * @returns the total number of active particles rendered per frame
  1607. */
  1608. getActiveParticles(): number;
  1609. /**
  1610. * Gets the performance counter for active particles
  1611. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1612. */
  1613. readonly activeParticlesPerfCounter: PerfCounter;
  1614. /**
  1615. * Gets the total number of active bones rendered per frame
  1616. * @returns the total number of active bones rendered per frame
  1617. */
  1618. getActiveBones(): number;
  1619. /**
  1620. * Gets the performance counter for active bones
  1621. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1622. */
  1623. readonly activeBonesPerfCounter: PerfCounter;
  1624. /**
  1625. * Gets the array of active meshes
  1626. * @returns an array of AbstractMesh
  1627. */
  1628. getActiveMeshes(): SmartArray<AbstractMesh>;
  1629. /**
  1630. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1631. * @returns a number
  1632. */
  1633. getAnimationRatio(): number;
  1634. /**
  1635. * Gets an unique Id for the current render phase
  1636. * @returns a number
  1637. */
  1638. getRenderId(): number;
  1639. /**
  1640. * Gets an unique Id for the current frame
  1641. * @returns a number
  1642. */
  1643. getFrameId(): number;
  1644. /** Call this function if you want to manually increment the render Id*/
  1645. incrementRenderId(): void;
  1646. private _updatePointerPosition;
  1647. private _createUbo;
  1648. private _createAlternateUbo;
  1649. private _setRayOnPointerInfo;
  1650. /**
  1651. * Use this method to simulate a pointer move on a mesh
  1652. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1653. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1654. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1655. * @returns the current scene
  1656. */
  1657. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1658. private _processPointerMove;
  1659. private _checkPrePointerObservable;
  1660. /**
  1661. * Use this method to simulate a pointer down on a mesh
  1662. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1663. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1664. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1665. * @returns the current scene
  1666. */
  1667. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1668. private _processPointerDown;
  1669. /**
  1670. * Use this method to simulate a pointer up on a mesh
  1671. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1672. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1673. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1674. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  1675. * @returns the current scene
  1676. */
  1677. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  1678. private _processPointerUp;
  1679. /**
  1680. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1681. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1682. * @returns true if the pointer was captured
  1683. */
  1684. isPointerCaptured(pointerId?: number): boolean;
  1685. /** @hidden */
  1686. _isPointerSwiping(): boolean;
  1687. /**
  1688. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1689. * @param attachUp defines if you want to attach events to pointerup
  1690. * @param attachDown defines if you want to attach events to pointerdown
  1691. * @param attachMove defines if you want to attach events to pointermove
  1692. */
  1693. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1694. /** Detaches all event handlers*/
  1695. detachControl(): void;
  1696. /**
  1697. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1698. * Delay loaded resources are not taking in account
  1699. * @return true if all required resources are ready
  1700. */
  1701. isReady(): boolean;
  1702. /** Resets all cached information relative to material (including effect and visibility) */
  1703. resetCachedMaterial(): void;
  1704. /**
  1705. * Registers a function to be called before every frame render
  1706. * @param func defines the function to register
  1707. */
  1708. registerBeforeRender(func: () => void): void;
  1709. /**
  1710. * Unregisters a function called before every frame render
  1711. * @param func defines the function to unregister
  1712. */
  1713. unregisterBeforeRender(func: () => void): void;
  1714. /**
  1715. * Registers a function to be called after every frame render
  1716. * @param func defines the function to register
  1717. */
  1718. registerAfterRender(func: () => void): void;
  1719. /**
  1720. * Unregisters a function called after every frame render
  1721. * @param func defines the function to unregister
  1722. */
  1723. unregisterAfterRender(func: () => void): void;
  1724. private _executeOnceBeforeRender;
  1725. /**
  1726. * The provided function will run before render once and will be disposed afterwards.
  1727. * A timeout delay can be provided so that the function will be executed in N ms.
  1728. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1729. * @param func The function to be executed.
  1730. * @param timeout optional delay in ms
  1731. */
  1732. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1733. /** @hidden */
  1734. _addPendingData(data: any): void;
  1735. /** @hidden */
  1736. _removePendingData(data: any): void;
  1737. /**
  1738. * Returns the number of items waiting to be loaded
  1739. * @returns the number of items waiting to be loaded
  1740. */
  1741. getWaitingItemsCount(): number;
  1742. /**
  1743. * Returns a boolean indicating if the scene is still loading data
  1744. */
  1745. readonly isLoading: boolean;
  1746. /**
  1747. * Registers a function to be executed when the scene is ready
  1748. * @param {Function} func - the function to be executed
  1749. */
  1750. executeWhenReady(func: () => void): void;
  1751. /**
  1752. * Returns a promise that resolves when the scene is ready
  1753. * @returns A promise that resolves when the scene is ready
  1754. */
  1755. whenReadyAsync(): Promise<void>;
  1756. /** @hidden */
  1757. _checkIsReady(): void;
  1758. /**
  1759. * Will start the animation sequence of a given target
  1760. * @param target defines the target
  1761. * @param from defines from which frame should animation start
  1762. * @param to defines until which frame should animation run.
  1763. * @param weight defines the weight to apply to the animation (1.0 by default)
  1764. * @param loop defines if the animation loops
  1765. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1766. * @param onAnimationEnd defines the function to be executed when the animation ends
  1767. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1768. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1769. * @returns the animatable object created for this animation
  1770. */
  1771. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1772. /**
  1773. * Will start the animation sequence of a given target
  1774. * @param target defines the target
  1775. * @param from defines from which frame should animation start
  1776. * @param to defines until which frame should animation run.
  1777. * @param loop defines if the animation loops
  1778. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1779. * @param onAnimationEnd defines the function to be executed when the animation ends
  1780. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1781. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1782. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1783. * @returns the animatable object created for this animation
  1784. */
  1785. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1786. /**
  1787. * Will start the animation sequence of a given target and its hierarchy
  1788. * @param target defines the target
  1789. * @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.
  1790. * @param from defines from which frame should animation start
  1791. * @param to defines until which frame should animation run.
  1792. * @param loop defines if the animation loops
  1793. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1794. * @param onAnimationEnd defines the function to be executed when the animation ends
  1795. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1796. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1797. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1798. * @returns the list of created animatables
  1799. */
  1800. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable[];
  1801. /**
  1802. * Begin a new animation on a given node
  1803. * @param target defines the target where the animation will take place
  1804. * @param animations defines the list of animations to start
  1805. * @param from defines the initial value
  1806. * @param to defines the final value
  1807. * @param loop defines if you want animation to loop (off by default)
  1808. * @param speedRatio defines the speed ratio to apply to all animations
  1809. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1810. * @returns the list of created animatables
  1811. */
  1812. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1813. /**
  1814. * Begin a new animation on a given node and its hierarchy
  1815. * @param target defines the root node where the animation will take place
  1816. * @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.
  1817. * @param animations defines the list of animations to start
  1818. * @param from defines the initial value
  1819. * @param to defines the final value
  1820. * @param loop defines if you want animation to loop (off by default)
  1821. * @param speedRatio defines the speed ratio to apply to all animations
  1822. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1823. * @returns the list of animatables created for all nodes
  1824. */
  1825. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1826. /**
  1827. * Gets the animatable associated with a specific target
  1828. * @param target defines the target of the animatable
  1829. * @returns the required animatable if found
  1830. */
  1831. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1832. /**
  1833. * Gets all animatables associated with a given target
  1834. * @param target defines the target to look animatables for
  1835. * @returns an array of Animatables
  1836. */
  1837. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1838. /**
  1839. * Gets all animatable attached to the scene
  1840. */
  1841. readonly animatables: Animatable[];
  1842. /**
  1843. * Will stop the animation of the given target
  1844. * @param target - the target
  1845. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1846. * @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)
  1847. */
  1848. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1849. /**
  1850. * Stops and removes all animations that have been applied to the scene
  1851. */
  1852. stopAllAnimations(): void;
  1853. private _animate;
  1854. /** @hidden */
  1855. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1856. private _processLateAnimationBindingsForMatrices;
  1857. private _processLateAnimationBindingsForQuaternions;
  1858. private _processLateAnimationBindings;
  1859. /** @hidden */
  1860. _switchToAlternateCameraConfiguration(active: boolean): void;
  1861. /**
  1862. * Gets the current view matrix
  1863. * @returns a Matrix
  1864. */
  1865. getViewMatrix(): Matrix;
  1866. /**
  1867. * Gets the current projection matrix
  1868. * @returns a Matrix
  1869. */
  1870. getProjectionMatrix(): Matrix;
  1871. /**
  1872. * Gets the current transform matrix
  1873. * @returns a Matrix made of View * Projection
  1874. */
  1875. getTransformMatrix(): Matrix;
  1876. /**
  1877. * Sets the current transform matrix
  1878. * @param view defines the View matrix to use
  1879. * @param projection defines the Projection matrix to use
  1880. */
  1881. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1882. /** @hidden */
  1883. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1884. /**
  1885. * Gets the uniform buffer used to store scene data
  1886. * @returns a UniformBuffer
  1887. */
  1888. getSceneUniformBuffer(): UniformBuffer;
  1889. /**
  1890. * Gets an unique (relatively to the current scene) Id
  1891. * @returns an unique number for the scene
  1892. */
  1893. getUniqueId(): number;
  1894. /**
  1895. * Add a mesh to the list of scene's meshes
  1896. * @param newMesh defines the mesh to add
  1897. * @param recursive if all child meshes should also be added to the scene
  1898. */
  1899. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1900. /**
  1901. * Remove a mesh for the list of scene's meshes
  1902. * @param toRemove defines the mesh to remove
  1903. * @param recursive if all child meshes should also be removed from the scene
  1904. * @returns the index where the mesh was in the mesh list
  1905. */
  1906. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1907. /**
  1908. * Add a transform node to the list of scene's transform nodes
  1909. * @param newTransformNode defines the transform node to add
  1910. */
  1911. addTransformNode(newTransformNode: TransformNode): void;
  1912. /**
  1913. * Remove a transform node for the list of scene's transform nodes
  1914. * @param toRemove defines the transform node to remove
  1915. * @returns the index where the transform node was in the transform node list
  1916. */
  1917. removeTransformNode(toRemove: TransformNode): number;
  1918. /**
  1919. * Remove a skeleton for the list of scene's skeletons
  1920. * @param toRemove defines the skeleton to remove
  1921. * @returns the index where the skeleton was in the skeleton list
  1922. */
  1923. removeSkeleton(toRemove: Skeleton): number;
  1924. /**
  1925. * Remove a morph target for the list of scene's morph targets
  1926. * @param toRemove defines the morph target to remove
  1927. * @returns the index where the morph target was in the morph target list
  1928. */
  1929. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1930. /**
  1931. * Remove a light for the list of scene's lights
  1932. * @param toRemove defines the light to remove
  1933. * @returns the index where the light was in the light list
  1934. */
  1935. removeLight(toRemove: Light): number;
  1936. /**
  1937. * Remove a camera for the list of scene's cameras
  1938. * @param toRemove defines the camera to remove
  1939. * @returns the index where the camera was in the camera list
  1940. */
  1941. removeCamera(toRemove: Camera): number;
  1942. /**
  1943. * Remove a particle system for the list of scene's particle systems
  1944. * @param toRemove defines the particle system to remove
  1945. * @returns the index where the particle system was in the particle system list
  1946. */
  1947. removeParticleSystem(toRemove: IParticleSystem): number;
  1948. /**
  1949. * Remove a animation for the list of scene's animations
  1950. * @param toRemove defines the animation to remove
  1951. * @returns the index where the animation was in the animation list
  1952. */
  1953. removeAnimation(toRemove: Animation): number;
  1954. /**
  1955. * Removes the given animation group from this scene.
  1956. * @param toRemove The animation group to remove
  1957. * @returns The index of the removed animation group
  1958. */
  1959. removeAnimationGroup(toRemove: AnimationGroup): number;
  1960. /**
  1961. * Removes the given multi-material from this scene.
  1962. * @param toRemove The multi-material to remove
  1963. * @returns The index of the removed multi-material
  1964. */
  1965. removeMultiMaterial(toRemove: MultiMaterial): number;
  1966. /**
  1967. * Removes the given material from this scene.
  1968. * @param toRemove The material to remove
  1969. * @returns The index of the removed material
  1970. */
  1971. removeMaterial(toRemove: Material): number;
  1972. /**
  1973. * Removes the given action manager from this scene.
  1974. * @param toRemove The action manager to remove
  1975. * @returns The index of the removed action manager
  1976. */
  1977. removeActionManager(toRemove: ActionManager): number;
  1978. /**
  1979. * Removes the given texture from this scene.
  1980. * @param toRemove The texture to remove
  1981. * @returns The index of the removed texture
  1982. */
  1983. removeTexture(toRemove: BaseTexture): number;
  1984. /**
  1985. * Adds the given light to this scene
  1986. * @param newLight The light to add
  1987. */
  1988. addLight(newLight: Light): void;
  1989. /**
  1990. * Sorts the list list based on light priorities
  1991. */
  1992. sortLightsByPriority(): void;
  1993. /**
  1994. * Adds the given camera to this scene
  1995. * @param newCamera The camera to add
  1996. */
  1997. addCamera(newCamera: Camera): void;
  1998. /**
  1999. * Adds the given skeleton to this scene
  2000. * @param newSkeleton The skeleton to add
  2001. */
  2002. addSkeleton(newSkeleton: Skeleton): void;
  2003. /**
  2004. * Adds the given particle system to this scene
  2005. * @param newParticleSystem The particle system to add
  2006. */
  2007. addParticleSystem(newParticleSystem: IParticleSystem): void;
  2008. /**
  2009. * Adds the given animation to this scene
  2010. * @param newAnimation The animation to add
  2011. */
  2012. addAnimation(newAnimation: Animation): void;
  2013. /**
  2014. * Adds the given animation group to this scene.
  2015. * @param newAnimationGroup The animation group to add
  2016. */
  2017. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  2018. /**
  2019. * Adds the given multi-material to this scene
  2020. * @param newMultiMaterial The multi-material to add
  2021. */
  2022. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  2023. /**
  2024. * Adds the given material to this scene
  2025. * @param newMaterial The material to add
  2026. */
  2027. addMaterial(newMaterial: Material): void;
  2028. /**
  2029. * Adds the given morph target to this scene
  2030. * @param newMorphTargetManager The morph target to add
  2031. */
  2032. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  2033. /**
  2034. * Adds the given geometry to this scene
  2035. * @param newGeometry The geometry to add
  2036. */
  2037. addGeometry(newGeometry: Geometry): void;
  2038. /**
  2039. * Adds the given action manager to this scene
  2040. * @param newActionManager The action manager to add
  2041. */
  2042. addActionManager(newActionManager: ActionManager): void;
  2043. /**
  2044. * Adds the given texture to this scene.
  2045. * @param newTexture The texture to add
  2046. */
  2047. addTexture(newTexture: BaseTexture): void;
  2048. /**
  2049. * Switch active camera
  2050. * @param newCamera defines the new active camera
  2051. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  2052. */
  2053. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  2054. /**
  2055. * sets the active camera of the scene using its ID
  2056. * @param id defines the camera's ID
  2057. * @return the new active camera or null if none found.
  2058. */
  2059. setActiveCameraByID(id: string): Nullable<Camera>;
  2060. /**
  2061. * sets the active camera of the scene using its name
  2062. * @param name defines the camera's name
  2063. * @returns the new active camera or null if none found.
  2064. */
  2065. setActiveCameraByName(name: string): Nullable<Camera>;
  2066. /**
  2067. * get an animation group using its name
  2068. * @param name defines the material's name
  2069. * @return the animation group or null if none found.
  2070. */
  2071. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2072. /**
  2073. * get a material using its id
  2074. * @param id defines the material's ID
  2075. * @return the material or null if none found.
  2076. */
  2077. getMaterialByID(id: string): Nullable<Material>;
  2078. /**
  2079. * Gets a material using its name
  2080. * @param name defines the material's name
  2081. * @return the material or null if none found.
  2082. */
  2083. getMaterialByName(name: string): Nullable<Material>;
  2084. /**
  2085. * Gets a camera using its id
  2086. * @param id defines the id to look for
  2087. * @returns the camera or null if not found
  2088. */
  2089. getCameraByID(id: string): Nullable<Camera>;
  2090. /**
  2091. * Gets a camera using its unique id
  2092. * @param uniqueId defines the unique id to look for
  2093. * @returns the camera or null if not found
  2094. */
  2095. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2096. /**
  2097. * Gets a camera using its name
  2098. * @param name defines the camera's name
  2099. * @return the camera or null if none found.
  2100. */
  2101. getCameraByName(name: string): Nullable<Camera>;
  2102. /**
  2103. * Gets a bone using its id
  2104. * @param id defines the bone's id
  2105. * @return the bone or null if not found
  2106. */
  2107. getBoneByID(id: string): Nullable<Bone>;
  2108. /**
  2109. * Gets a bone using its id
  2110. * @param name defines the bone's name
  2111. * @return the bone or null if not found
  2112. */
  2113. getBoneByName(name: string): Nullable<Bone>;
  2114. /**
  2115. * Gets a light node using its name
  2116. * @param name defines the the light's name
  2117. * @return the light or null if none found.
  2118. */
  2119. getLightByName(name: string): Nullable<Light>;
  2120. /**
  2121. * Gets a light node using its id
  2122. * @param id defines the light's id
  2123. * @return the light or null if none found.
  2124. */
  2125. getLightByID(id: string): Nullable<Light>;
  2126. /**
  2127. * Gets a light node using its scene-generated unique ID
  2128. * @param uniqueId defines the light's unique id
  2129. * @return the light or null if none found.
  2130. */
  2131. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2132. /**
  2133. * Gets a particle system by id
  2134. * @param id defines the particle system id
  2135. * @return the corresponding system or null if none found
  2136. */
  2137. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2138. /**
  2139. * Gets a geometry using its ID
  2140. * @param id defines the geometry's id
  2141. * @return the geometry or null if none found.
  2142. */
  2143. getGeometryByID(id: string): Nullable<Geometry>;
  2144. private _getGeometryByUniqueID;
  2145. /**
  2146. * Add a new geometry to this scene
  2147. * @param geometry defines the geometry to be added to the scene.
  2148. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2149. * @return a boolean defining if the geometry was added or not
  2150. */
  2151. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2152. /**
  2153. * Removes an existing geometry
  2154. * @param geometry defines the geometry to be removed from the scene
  2155. * @return a boolean defining if the geometry was removed or not
  2156. */
  2157. removeGeometry(geometry: Geometry): boolean;
  2158. /**
  2159. * Gets the list of geometries attached to the scene
  2160. * @returns an array of Geometry
  2161. */
  2162. getGeometries(): Geometry[];
  2163. /**
  2164. * Gets the first added mesh found of a given ID
  2165. * @param id defines the id to search for
  2166. * @return the mesh found or null if not found at all
  2167. */
  2168. getMeshByID(id: string): Nullable<AbstractMesh>;
  2169. /**
  2170. * Gets a list of meshes using their id
  2171. * @param id defines the id to search for
  2172. * @returns a list of meshes
  2173. */
  2174. getMeshesByID(id: string): Array<AbstractMesh>;
  2175. /**
  2176. * Gets the first added transform node found of a given ID
  2177. * @param id defines the id to search for
  2178. * @return the found transform node or null if not found at all.
  2179. */
  2180. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2181. /**
  2182. * Gets a list of transform nodes using their id
  2183. * @param id defines the id to search for
  2184. * @returns a list of transform nodes
  2185. */
  2186. getTransformNodesByID(id: string): Array<TransformNode>;
  2187. /**
  2188. * Gets a mesh with its auto-generated unique id
  2189. * @param uniqueId defines the unique id to search for
  2190. * @return the found mesh or null if not found at all.
  2191. */
  2192. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2193. /**
  2194. * Gets a the last added mesh using a given id
  2195. * @param id defines the id to search for
  2196. * @return the found mesh or null if not found at all.
  2197. */
  2198. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2199. /**
  2200. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2201. * @param id defines the id to search for
  2202. * @return the found node or null if not found at all
  2203. */
  2204. getLastEntryByID(id: string): Nullable<Node>;
  2205. /**
  2206. * Gets a node (Mesh, Camera, Light) using a given id
  2207. * @param id defines the id to search for
  2208. * @return the found node or null if not found at all
  2209. */
  2210. getNodeByID(id: string): Nullable<Node>;
  2211. /**
  2212. * Gets a node (Mesh, Camera, Light) using a given name
  2213. * @param name defines the name to search for
  2214. * @return the found node or null if not found at all.
  2215. */
  2216. getNodeByName(name: string): Nullable<Node>;
  2217. /**
  2218. * Gets a mesh using a given name
  2219. * @param name defines the name to search for
  2220. * @return the found mesh or null if not found at all.
  2221. */
  2222. getMeshByName(name: string): Nullable<AbstractMesh>;
  2223. /**
  2224. * Gets a transform node using a given name
  2225. * @param name defines the name to search for
  2226. * @return the found transform node or null if not found at all.
  2227. */
  2228. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2229. /**
  2230. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2231. * @param id defines the id to search for
  2232. * @return the found skeleton or null if not found at all.
  2233. */
  2234. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2235. /**
  2236. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2237. * @param id defines the id to search for
  2238. * @return the found skeleton or null if not found at all.
  2239. */
  2240. getSkeletonById(id: string): Nullable<Skeleton>;
  2241. /**
  2242. * Gets a skeleton using a given name
  2243. * @param name defines the name to search for
  2244. * @return the found skeleton or null if not found at all.
  2245. */
  2246. getSkeletonByName(name: string): Nullable<Skeleton>;
  2247. /**
  2248. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2249. * @param id defines the id to search for
  2250. * @return the found morph target manager or null if not found at all.
  2251. */
  2252. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2253. /**
  2254. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  2255. * @param id defines the id to search for
  2256. * @return the found morph target or null if not found at all.
  2257. */
  2258. getMorphTargetById(id: string): Nullable<MorphTarget>;
  2259. /**
  2260. * Gets a boolean indicating if the given mesh is active
  2261. * @param mesh defines the mesh to look for
  2262. * @returns true if the mesh is in the active list
  2263. */
  2264. isActiveMesh(mesh: AbstractMesh): boolean;
  2265. /**
  2266. * Return a unique id as a string which can serve as an identifier for the scene
  2267. */
  2268. readonly uid: string;
  2269. /**
  2270. * Add an externaly attached data from its key.
  2271. * This method call will fail and return false, if such key already exists.
  2272. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2273. * @param key the unique key that identifies the data
  2274. * @param data the data object to associate to the key for this Engine instance
  2275. * @return true if no such key were already present and the data was added successfully, false otherwise
  2276. */
  2277. addExternalData<T>(key: string, data: T): boolean;
  2278. /**
  2279. * Get an externaly attached data from its key
  2280. * @param key the unique key that identifies the data
  2281. * @return the associated data, if present (can be null), or undefined if not present
  2282. */
  2283. getExternalData<T>(key: string): Nullable<T>;
  2284. /**
  2285. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2286. * @param key the unique key that identifies the data
  2287. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2288. * @return the associated data, can be null if the factory returned null.
  2289. */
  2290. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2291. /**
  2292. * Remove an externaly attached data from the Engine instance
  2293. * @param key the unique key that identifies the data
  2294. * @return true if the data was successfully removed, false if it doesn't exist
  2295. */
  2296. removeExternalData(key: string): boolean;
  2297. private _evaluateSubMesh;
  2298. /**
  2299. * Clear the processed materials smart array preventing retention point in material dispose.
  2300. */
  2301. freeProcessedMaterials(): void;
  2302. private _preventFreeActiveMeshesAndRenderingGroups;
  2303. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  2304. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  2305. * when disposing several meshes in a row or a hierarchy of meshes.
  2306. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  2307. */
  2308. blockfreeActiveMeshesAndRenderingGroups: boolean;
  2309. /**
  2310. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2311. */
  2312. freeActiveMeshes(): void;
  2313. /**
  2314. * Clear the info related to rendering groups preventing retention points during dispose.
  2315. */
  2316. freeRenderingGroups(): void;
  2317. /** @hidden */
  2318. _isInIntermediateRendering(): boolean;
  2319. /**
  2320. * Lambda returning the list of potentially active meshes.
  2321. */
  2322. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2323. /**
  2324. * Lambda returning the list of potentially active sub meshes.
  2325. */
  2326. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2327. /**
  2328. * Lambda returning the list of potentially intersecting sub meshes.
  2329. */
  2330. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2331. /**
  2332. * Lambda returning the list of potentially colliding sub meshes.
  2333. */
  2334. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2335. private _activeMeshesFrozen;
  2336. /**
  2337. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2338. * @returns the current scene
  2339. */
  2340. freezeActiveMeshes(): Scene;
  2341. /**
  2342. * Use this function to restart evaluating active meshes on every frame
  2343. * @returns the current scene
  2344. */
  2345. unfreezeActiveMeshes(): Scene;
  2346. private _evaluateActiveMeshes;
  2347. private _activeMesh;
  2348. /**
  2349. * Update the transform matrix to update from the current active camera
  2350. * @param force defines a boolean used to force the update even if cache is up to date
  2351. */
  2352. updateTransformMatrix(force?: boolean): void;
  2353. /**
  2354. * 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)
  2355. * @param alternateCamera defines the camera to use
  2356. */
  2357. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2358. /** @hidden */
  2359. _allowPostProcessClearColor: boolean;
  2360. private _renderForCamera;
  2361. private _processSubCameras;
  2362. private _checkIntersections;
  2363. /** @hidden */
  2364. _advancePhysicsEngineStep(step: number): void;
  2365. /**
  2366. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2367. */
  2368. getDeterministicFrameTime: () => number;
  2369. /**
  2370. * Render the scene
  2371. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2372. */
  2373. render(updateCameras?: boolean): void;
  2374. /**
  2375. * Freeze all materials
  2376. * A frozen material will not be updatable but should be faster to render
  2377. */
  2378. freezeMaterials(): void;
  2379. /**
  2380. * Unfreeze all materials
  2381. * A frozen material will not be updatable but should be faster to render
  2382. */
  2383. unfreezeMaterials(): void;
  2384. /**
  2385. * Releases all held ressources
  2386. */
  2387. dispose(): void;
  2388. /**
  2389. * Gets if the scene is already disposed
  2390. */
  2391. readonly isDisposed: boolean;
  2392. /**
  2393. * Call this function to reduce memory footprint of the scene.
  2394. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2395. */
  2396. clearCachedVertexData(): void;
  2397. /**
  2398. * This function will remove the local cached buffer data from texture.
  2399. * It will save memory but will prevent the texture from being rebuilt
  2400. */
  2401. cleanCachedTextureBuffer(): void;
  2402. /**
  2403. * Get the world extend vectors with an optional filter
  2404. *
  2405. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2406. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2407. */
  2408. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2409. min: Vector3;
  2410. max: Vector3;
  2411. };
  2412. /**
  2413. * Creates a ray that can be used to pick in the scene
  2414. * @param x defines the x coordinate of the origin (on-screen)
  2415. * @param y defines the y coordinate of the origin (on-screen)
  2416. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2417. * @param camera defines the camera to use for the picking
  2418. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2419. * @returns a Ray
  2420. */
  2421. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2422. /**
  2423. * Creates a ray that can be used to pick in the scene
  2424. * @param x defines the x coordinate of the origin (on-screen)
  2425. * @param y defines the y coordinate of the origin (on-screen)
  2426. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2427. * @param result defines the ray where to store the picking ray
  2428. * @param camera defines the camera to use for the picking
  2429. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2430. * @returns the current scene
  2431. */
  2432. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2433. /**
  2434. * Creates a ray that can be used to pick in the scene
  2435. * @param x defines the x coordinate of the origin (on-screen)
  2436. * @param y defines the y coordinate of the origin (on-screen)
  2437. * @param camera defines the camera to use for the picking
  2438. * @returns a Ray
  2439. */
  2440. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2441. /**
  2442. * Creates a ray that can be used to pick in the scene
  2443. * @param x defines the x coordinate of the origin (on-screen)
  2444. * @param y defines the y coordinate of the origin (on-screen)
  2445. * @param result defines the ray where to store the picking ray
  2446. * @param camera defines the camera to use for the picking
  2447. * @returns the current scene
  2448. */
  2449. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2450. private _internalPick;
  2451. private _internalMultiPick;
  2452. private _tempPickingRay;
  2453. /** Launch a ray to try to pick a mesh in the scene
  2454. * @param x position on screen
  2455. * @param y position on screen
  2456. * @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
  2457. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2458. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2459. * @returns a PickingInfo
  2460. */
  2461. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2462. private _cachedRayForTransform;
  2463. /** Use the given ray to pick a mesh in the scene
  2464. * @param ray The ray to use to pick meshes
  2465. * @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
  2466. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2467. * @returns a PickingInfo
  2468. */
  2469. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2470. /**
  2471. * Launch a ray to try to pick a mesh in the scene
  2472. * @param x X position on screen
  2473. * @param y Y position on screen
  2474. * @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
  2475. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2476. * @returns an array of PickingInfo
  2477. */
  2478. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2479. /**
  2480. * Launch a ray to try to pick a mesh in the scene
  2481. * @param ray Ray to use
  2482. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2483. * @returns an array of PickingInfo
  2484. */
  2485. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2486. /**
  2487. * Force the value of meshUnderPointer
  2488. * @param mesh defines the mesh to use
  2489. */
  2490. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2491. /**
  2492. * Gets the mesh under the pointer
  2493. * @returns a Mesh or null if no mesh is under the pointer
  2494. */
  2495. getPointerOverMesh(): Nullable<AbstractMesh>;
  2496. /** @hidden */
  2497. _rebuildGeometries(): void;
  2498. /** @hidden */
  2499. _rebuildTextures(): void;
  2500. private _getByTags;
  2501. /**
  2502. * Get a list of meshes by tags
  2503. * @param tagsQuery defines the tags query to use
  2504. * @param forEach defines a predicate used to filter results
  2505. * @returns an array of Mesh
  2506. */
  2507. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2508. /**
  2509. * Get a list of cameras by tags
  2510. * @param tagsQuery defines the tags query to use
  2511. * @param forEach defines a predicate used to filter results
  2512. * @returns an array of Camera
  2513. */
  2514. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2515. /**
  2516. * Get a list of lights by tags
  2517. * @param tagsQuery defines the tags query to use
  2518. * @param forEach defines a predicate used to filter results
  2519. * @returns an array of Light
  2520. */
  2521. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2522. /**
  2523. * Get a list of materials by tags
  2524. * @param tagsQuery defines the tags query to use
  2525. * @param forEach defines a predicate used to filter results
  2526. * @returns an array of Material
  2527. */
  2528. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2529. /**
  2530. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2531. * This allowed control for front to back rendering or reversly depending of the special needs.
  2532. *
  2533. * @param renderingGroupId The rendering group id corresponding to its index
  2534. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2535. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2536. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2537. */
  2538. 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;
  2539. /**
  2540. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2541. *
  2542. * @param renderingGroupId The rendering group id corresponding to its index
  2543. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2544. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2545. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2546. */
  2547. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2548. /**
  2549. * Gets the current auto clear configuration for one rendering group of the rendering
  2550. * manager.
  2551. * @param index the rendering group index to get the information for
  2552. * @returns The auto clear setup for the requested rendering group
  2553. */
  2554. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2555. private _blockMaterialDirtyMechanism;
  2556. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2557. blockMaterialDirtyMechanism: boolean;
  2558. /**
  2559. * Will flag all materials as dirty to trigger new shader compilation
  2560. * @param flag defines the flag used to specify which material part must be marked as dirty
  2561. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2562. */
  2563. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2564. /** @hidden */
  2565. _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;
  2566. /** @hidden */
  2567. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2568. }
  2569. }
  2570. declare module BABYLON {
  2571. /**
  2572. * Groups all the scene component constants in one place to ease maintenance.
  2573. * @hidden
  2574. */
  2575. class SceneComponentConstants {
  2576. static readonly NAME_EFFECTLAYER: string;
  2577. static readonly NAME_LAYER: string;
  2578. static readonly NAME_LENSFLARESYSTEM: string;
  2579. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2580. static readonly NAME_PARTICLESYSTEM: string;
  2581. static readonly NAME_GAMEPAD: string;
  2582. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2583. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2584. static readonly NAME_DEPTHRENDERER: string;
  2585. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2586. static readonly NAME_SPRITE: string;
  2587. static readonly NAME_OUTLINERENDERER: string;
  2588. static readonly NAME_PROCEDURALTEXTURE: string;
  2589. static readonly NAME_SHADOWGENERATOR: string;
  2590. static readonly NAME_OCTREE: string;
  2591. static readonly NAME_PHYSICSENGINE: string;
  2592. static readonly NAME_AUDIO: string;
  2593. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2594. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2595. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2596. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2597. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2598. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2599. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2600. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  2601. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2602. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2603. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2604. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2605. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2606. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2607. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2608. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  2609. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2610. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2611. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2612. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2613. static readonly STEP_AFTERRENDER_AUDIO: number;
  2614. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2615. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2616. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2617. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2618. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2619. static readonly STEP_POINTERMOVE_SPRITE: number;
  2620. static readonly STEP_POINTERDOWN_SPRITE: number;
  2621. static readonly STEP_POINTERUP_SPRITE: number;
  2622. }
  2623. /**
  2624. * This represents a scene component.
  2625. *
  2626. * This is used to decouple the dependency the scene is having on the different workloads like
  2627. * layers, post processes...
  2628. */
  2629. interface ISceneComponent {
  2630. /**
  2631. * The name of the component. Each component must have a unique name.
  2632. */
  2633. name: string;
  2634. /**
  2635. * The scene the component belongs to.
  2636. */
  2637. scene: Scene;
  2638. /**
  2639. * Register the component to one instance of a scene.
  2640. */
  2641. register(): void;
  2642. /**
  2643. * Rebuilds the elements related to this component in case of
  2644. * context lost for instance.
  2645. */
  2646. rebuild(): void;
  2647. /**
  2648. * Disposes the component and the associated ressources.
  2649. */
  2650. dispose(): void;
  2651. }
  2652. /**
  2653. * This represents a SERIALIZABLE scene component.
  2654. *
  2655. * This extends Scene Component to add Serialization methods on top.
  2656. */
  2657. interface ISceneSerializableComponent extends ISceneComponent {
  2658. /**
  2659. * Adds all the element from the container to the scene
  2660. * @param container the container holding the elements
  2661. */
  2662. addFromContainer(container: AbstractScene): void;
  2663. /**
  2664. * Removes all the elements in the container from the scene
  2665. * @param container contains the elements to remove
  2666. */
  2667. removeFromContainer(container: AbstractScene): void;
  2668. /**
  2669. * Serializes the component data to the specified json object
  2670. * @param serializationObject The object to serialize to
  2671. */
  2672. serialize(serializationObject: any): void;
  2673. }
  2674. /**
  2675. * Strong typing of a Mesh related stage step action
  2676. */
  2677. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2678. /**
  2679. * Strong typing of a Evaluate Sub Mesh related stage step action
  2680. */
  2681. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2682. /**
  2683. * Strong typing of a Active Mesh related stage step action
  2684. */
  2685. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2686. /**
  2687. * Strong typing of a Camera related stage step action
  2688. */
  2689. type CameraStageAction = (camera: Camera) => void;
  2690. /**
  2691. * Strong typing of a Render Target related stage step action
  2692. */
  2693. type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  2694. /**
  2695. * Strong typing of a RenderingGroup related stage step action
  2696. */
  2697. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2698. /**
  2699. * Strong typing of a Mesh Render related stage step action
  2700. */
  2701. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2702. /**
  2703. * Strong typing of a simple stage step action
  2704. */
  2705. type SimpleStageAction = () => void;
  2706. /**
  2707. * Strong typing of a render target action.
  2708. */
  2709. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2710. /**
  2711. * Strong typing of a pointer move action.
  2712. */
  2713. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2714. /**
  2715. * Strong typing of a pointer up/down action.
  2716. */
  2717. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2718. /**
  2719. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2720. * @hidden
  2721. */
  2722. class Stage<T extends Function> extends Array<{
  2723. index: number;
  2724. component: ISceneComponent;
  2725. action: T;
  2726. }> {
  2727. /**
  2728. * Hide ctor from the rest of the world.
  2729. * @param items The items to add.
  2730. */
  2731. private constructor();
  2732. /**
  2733. * Creates a new Stage.
  2734. * @returns A new instance of a Stage
  2735. */
  2736. static Create<T extends Function>(): Stage<T>;
  2737. /**
  2738. * Registers a step in an ordered way in the targeted stage.
  2739. * @param index Defines the position to register the step in
  2740. * @param component Defines the component attached to the step
  2741. * @param action Defines the action to launch during the step
  2742. */
  2743. registerStep(index: number, component: ISceneComponent, action: T): void;
  2744. /**
  2745. * Clears all the steps from the stage.
  2746. */
  2747. clear(): void;
  2748. }
  2749. }
  2750. declare module BABYLON {
  2751. /** Alias type for value that can be null */
  2752. type Nullable<T> = T | null;
  2753. /**
  2754. * Alias type for number that are floats
  2755. * @ignorenaming
  2756. */
  2757. type float = number;
  2758. /**
  2759. * Alias type for number that are doubles.
  2760. * @ignorenaming
  2761. */
  2762. type double = number;
  2763. /**
  2764. * Alias type for number that are integer
  2765. * @ignorenaming
  2766. */
  2767. type int = number;
  2768. /** Alias type for number array or Float32Array */
  2769. type FloatArray = number[] | Float32Array;
  2770. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2771. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2772. /**
  2773. * Alias for types that can be used by a Buffer or VertexBuffer.
  2774. */
  2775. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2776. /**
  2777. * Alias type for primitive types
  2778. * @ignorenaming
  2779. */
  2780. type Primitive = undefined | null | boolean | string | number | Function;
  2781. /**
  2782. * Type modifier to make all the properties of an object Readonly
  2783. */
  2784. type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  2785. /**
  2786. * Type modifier to make all the properties of an object Readonly recursively
  2787. */
  2788. type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  2789. /** @hidden */
  2790. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  2791. }
  2792. /** @hidden */
  2793. /** @hidden */
  2794. type DeepImmutableObject<T> = {
  2795. readonly [K in keyof T]: DeepImmutable<T[K]>;
  2796. };
  2797. }
  2798. declare module BABYLON {
  2799. /**
  2800. * The action to be carried out following a trigger
  2801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2802. */
  2803. class Action {
  2804. /** the trigger, with or without parameters, for the action */
  2805. triggerOptions: any;
  2806. /**
  2807. * Trigger for the action
  2808. */
  2809. trigger: number;
  2810. /**
  2811. * Internal only - manager for action
  2812. * @hidden
  2813. */
  2814. _actionManager: ActionManager;
  2815. private _nextActiveAction;
  2816. private _child;
  2817. private _condition?;
  2818. private _triggerParameter;
  2819. /**
  2820. * An event triggered prior to action being executed.
  2821. */
  2822. onBeforeExecuteObservable: Observable<Action>;
  2823. /**
  2824. * Creates a new Action
  2825. * @param triggerOptions the trigger, with or without parameters, for the action
  2826. * @param condition an optional determinant of action
  2827. */
  2828. constructor(
  2829. /** the trigger, with or without parameters, for the action */
  2830. triggerOptions: any, condition?: Condition);
  2831. /**
  2832. * Internal only
  2833. * @hidden
  2834. */
  2835. _prepare(): void;
  2836. /**
  2837. * Gets the trigger parameters
  2838. * @returns the trigger parameters
  2839. */
  2840. getTriggerParameter(): any;
  2841. /**
  2842. * Internal only - executes current action event
  2843. * @hidden
  2844. */
  2845. _executeCurrent(evt?: ActionEvent): void;
  2846. /**
  2847. * Execute placeholder for child classes
  2848. * @param evt optional action event
  2849. */
  2850. execute(evt?: ActionEvent): void;
  2851. /**
  2852. * Skips to next active action
  2853. */
  2854. skipToNextActiveAction(): void;
  2855. /**
  2856. * Adds action to chain of actions, may be a DoNothingAction
  2857. * @param action defines the next action to execute
  2858. * @returns The action passed in
  2859. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2860. */
  2861. then(action: Action): Action;
  2862. /**
  2863. * Internal only
  2864. * @hidden
  2865. */
  2866. _getProperty(propertyPath: string): string;
  2867. /**
  2868. * Internal only
  2869. * @hidden
  2870. */
  2871. _getEffectiveTarget(target: any, propertyPath: string): any;
  2872. /**
  2873. * Serialize placeholder for child classes
  2874. * @param parent of child
  2875. * @returns the serialized object
  2876. */
  2877. serialize(parent: any): any;
  2878. /**
  2879. * Internal only called by serialize
  2880. * @hidden
  2881. */
  2882. protected _serialize(serializedAction: any, parent?: any): any;
  2883. /**
  2884. * Internal only
  2885. * @hidden
  2886. */
  2887. static _SerializeValueAsString: (value: any) => string;
  2888. /**
  2889. * Internal only
  2890. * @hidden
  2891. */
  2892. static _GetTargetProperty: (target: Scene | Node) => {
  2893. name: string;
  2894. targetType: string;
  2895. value: string;
  2896. };
  2897. }
  2898. }
  2899. declare module BABYLON {
  2900. /**
  2901. * ActionEvent is the event being sent when an action is triggered.
  2902. */
  2903. class ActionEvent {
  2904. /** The mesh or sprite that triggered the action */
  2905. source: any;
  2906. /** The X mouse cursor position at the time of the event */
  2907. pointerX: number;
  2908. /** The Y mouse cursor position at the time of the event */
  2909. pointerY: number;
  2910. /** The mesh that is currently pointed at (can be null) */
  2911. meshUnderPointer: Nullable<AbstractMesh>;
  2912. /** the original (browser) event that triggered the ActionEvent */
  2913. sourceEvent?: any;
  2914. /** additional data for the event */
  2915. additionalData?: any;
  2916. /**
  2917. * Creates a new ActionEvent
  2918. * @param source The mesh or sprite that triggered the action
  2919. * @param pointerX The X mouse cursor position at the time of the event
  2920. * @param pointerY The Y mouse cursor position at the time of the event
  2921. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2922. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2923. * @param additionalData additional data for the event
  2924. */
  2925. constructor(
  2926. /** The mesh or sprite that triggered the action */
  2927. source: any,
  2928. /** The X mouse cursor position at the time of the event */
  2929. pointerX: number,
  2930. /** The Y mouse cursor position at the time of the event */
  2931. pointerY: number,
  2932. /** The mesh that is currently pointed at (can be null) */
  2933. meshUnderPointer: Nullable<AbstractMesh>,
  2934. /** the original (browser) event that triggered the ActionEvent */
  2935. sourceEvent?: any,
  2936. /** additional data for the event */
  2937. additionalData?: any);
  2938. /**
  2939. * Helper function to auto-create an ActionEvent from a source mesh.
  2940. * @param source The source mesh that triggered the event
  2941. * @param evt The original (browser) event
  2942. * @param additionalData additional data for the event
  2943. * @returns the new ActionEvent
  2944. */
  2945. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2946. /**
  2947. * Helper function to auto-create an ActionEvent from a source sprite
  2948. * @param source The source sprite that triggered the event
  2949. * @param scene Scene associated with the sprite
  2950. * @param evt The original (browser) event
  2951. * @param additionalData additional data for the event
  2952. * @returns the new ActionEvent
  2953. */
  2954. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2955. /**
  2956. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2957. * @param scene the scene where the event occurred
  2958. * @param evt The original (browser) event
  2959. * @returns the new ActionEvent
  2960. */
  2961. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2962. /**
  2963. * Helper function to auto-create an ActionEvent from a primitive
  2964. * @param prim defines the target primitive
  2965. * @param pointerPos defines the pointer position
  2966. * @param evt The original (browser) event
  2967. * @param additionalData additional data for the event
  2968. * @returns the new ActionEvent
  2969. */
  2970. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2971. }
  2972. /**
  2973. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2974. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2976. */
  2977. class ActionManager {
  2978. /**
  2979. * Nothing
  2980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2981. */
  2982. static readonly NothingTrigger: number;
  2983. /**
  2984. * On pick
  2985. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2986. */
  2987. static readonly OnPickTrigger: number;
  2988. /**
  2989. * On left pick
  2990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2991. */
  2992. static readonly OnLeftPickTrigger: number;
  2993. /**
  2994. * On right pick
  2995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2996. */
  2997. static readonly OnRightPickTrigger: number;
  2998. /**
  2999. * On center pick
  3000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3001. */
  3002. static readonly OnCenterPickTrigger: number;
  3003. /**
  3004. * On pick down
  3005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3006. */
  3007. static readonly OnPickDownTrigger: number;
  3008. /**
  3009. * On double pick
  3010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3011. */
  3012. static readonly OnDoublePickTrigger: number;
  3013. /**
  3014. * On pick up
  3015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3016. */
  3017. static readonly OnPickUpTrigger: number;
  3018. /**
  3019. * On pick out.
  3020. * This trigger will only be raised if you also declared a OnPickDown
  3021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3022. */
  3023. static readonly OnPickOutTrigger: number;
  3024. /**
  3025. * On long press
  3026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3027. */
  3028. static readonly OnLongPressTrigger: number;
  3029. /**
  3030. * On pointer over
  3031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3032. */
  3033. static readonly OnPointerOverTrigger: number;
  3034. /**
  3035. * On pointer out
  3036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3037. */
  3038. static readonly OnPointerOutTrigger: number;
  3039. /**
  3040. * On every frame
  3041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3042. */
  3043. static readonly OnEveryFrameTrigger: number;
  3044. /**
  3045. * On intersection enter
  3046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3047. */
  3048. static readonly OnIntersectionEnterTrigger: number;
  3049. /**
  3050. * On intersection exit
  3051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3052. */
  3053. static readonly OnIntersectionExitTrigger: number;
  3054. /**
  3055. * On key down
  3056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3057. */
  3058. static readonly OnKeyDownTrigger: number;
  3059. /**
  3060. * On key up
  3061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3062. */
  3063. static readonly OnKeyUpTrigger: number;
  3064. /** Gets the list of active triggers */
  3065. static Triggers: {
  3066. [key: string]: number;
  3067. };
  3068. /** Gets the list of actions */
  3069. actions: Action[];
  3070. /** Gets the cursor to use when hovering items */
  3071. hoverCursor: string;
  3072. private _scene;
  3073. /**
  3074. * Creates a new action manager
  3075. * @param scene defines the hosting scene
  3076. */
  3077. constructor(scene: Scene);
  3078. /**
  3079. * Releases all associated resources
  3080. */
  3081. dispose(): void;
  3082. /**
  3083. * Gets hosting scene
  3084. * @returns the hosting scene
  3085. */
  3086. getScene(): Scene;
  3087. /**
  3088. * Does this action manager handles actions of any of the given triggers
  3089. * @param triggers defines the triggers to be tested
  3090. * @return a boolean indicating whether one (or more) of the triggers is handled
  3091. */
  3092. hasSpecificTriggers(triggers: number[]): boolean;
  3093. /**
  3094. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3095. * speed.
  3096. * @param triggerA defines the trigger to be tested
  3097. * @param triggerB defines the trigger to be tested
  3098. * @return a boolean indicating whether one (or more) of the triggers is handled
  3099. */
  3100. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3101. /**
  3102. * Does this action manager handles actions of a given trigger
  3103. * @param trigger defines the trigger to be tested
  3104. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3105. * @return whether the trigger is handled
  3106. */
  3107. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3108. /**
  3109. * Does this action manager has pointer triggers
  3110. */
  3111. readonly hasPointerTriggers: boolean;
  3112. /**
  3113. * Does this action manager has pick triggers
  3114. */
  3115. readonly hasPickTriggers: boolean;
  3116. /**
  3117. * Does exist one action manager with at least one trigger
  3118. **/
  3119. static readonly HasTriggers: boolean;
  3120. /**
  3121. * Does exist one action manager with at least one pick trigger
  3122. **/
  3123. static readonly HasPickTriggers: boolean;
  3124. /**
  3125. * Does exist one action manager that handles actions of a given trigger
  3126. * @param trigger defines the trigger to be tested
  3127. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3128. **/
  3129. static HasSpecificTrigger(trigger: number): boolean;
  3130. /**
  3131. * Registers an action to this action manager
  3132. * @param action defines the action to be registered
  3133. * @return the action amended (prepared) after registration
  3134. */
  3135. registerAction(action: Action): Nullable<Action>;
  3136. /**
  3137. * Unregisters an action to this action manager
  3138. * @param action defines the action to be unregistered
  3139. * @return a boolean indicating whether the action has been unregistered
  3140. */
  3141. unregisterAction(action: Action): Boolean;
  3142. /**
  3143. * Process a specific trigger
  3144. * @param trigger defines the trigger to process
  3145. * @param evt defines the event details to be processed
  3146. */
  3147. processTrigger(trigger: number, evt?: ActionEvent): void;
  3148. /** @hidden */
  3149. _getEffectiveTarget(target: any, propertyPath: string): any;
  3150. /** @hidden */
  3151. _getProperty(propertyPath: string): string;
  3152. /**
  3153. * Serialize this manager to a JSON object
  3154. * @param name defines the property name to store this manager
  3155. * @returns a JSON representation of this manager
  3156. */
  3157. serialize(name: string): any;
  3158. /**
  3159. * Creates a new ActionManager from a JSON data
  3160. * @param parsedActions defines the JSON data to read from
  3161. * @param object defines the hosting mesh
  3162. * @param scene defines the hosting scene
  3163. */
  3164. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3165. /**
  3166. * Get a trigger name by index
  3167. * @param trigger defines the trigger index
  3168. * @returns a trigger name
  3169. */
  3170. static GetTriggerName(trigger: number): string;
  3171. }
  3172. }
  3173. declare module BABYLON {
  3174. /**
  3175. * A Condition applied to an Action
  3176. */
  3177. class Condition {
  3178. /**
  3179. * Internal only - manager for action
  3180. * @hidden
  3181. */
  3182. _actionManager: ActionManager;
  3183. /**
  3184. * Internal only
  3185. * @hidden
  3186. */
  3187. _evaluationId: number;
  3188. /**
  3189. * Internal only
  3190. * @hidden
  3191. */
  3192. _currentResult: boolean;
  3193. /**
  3194. * Creates a new Condition
  3195. * @param actionManager the manager of the action the condition is applied to
  3196. */
  3197. constructor(actionManager: ActionManager);
  3198. /**
  3199. * Check if the current condition is valid
  3200. * @returns a boolean
  3201. */
  3202. isValid(): boolean;
  3203. /**
  3204. * Internal only
  3205. * @hidden
  3206. */
  3207. _getProperty(propertyPath: string): string;
  3208. /**
  3209. * Internal only
  3210. * @hidden
  3211. */
  3212. _getEffectiveTarget(target: any, propertyPath: string): any;
  3213. /**
  3214. * Serialize placeholder for child classes
  3215. * @returns the serialized object
  3216. */
  3217. serialize(): any;
  3218. /**
  3219. * Internal only
  3220. * @hidden
  3221. */
  3222. protected _serialize(serializedCondition: any): any;
  3223. }
  3224. /**
  3225. * Defines specific conditional operators as extensions of Condition
  3226. */
  3227. class ValueCondition extends Condition {
  3228. /** path to specify the property of the target the conditional operator uses */
  3229. propertyPath: string;
  3230. /** the value compared by the conditional operator against the current value of the property */
  3231. value: any;
  3232. /** the conditional operator, default ValueCondition.IsEqual */
  3233. operator: number;
  3234. /**
  3235. * Internal only
  3236. * @hidden
  3237. */
  3238. private static _IsEqual;
  3239. /**
  3240. * Internal only
  3241. * @hidden
  3242. */
  3243. private static _IsDifferent;
  3244. /**
  3245. * Internal only
  3246. * @hidden
  3247. */
  3248. private static _IsGreater;
  3249. /**
  3250. * Internal only
  3251. * @hidden
  3252. */
  3253. private static _IsLesser;
  3254. /**
  3255. * returns the number for IsEqual
  3256. */
  3257. static readonly IsEqual: number;
  3258. /**
  3259. * Returns the number for IsDifferent
  3260. */
  3261. static readonly IsDifferent: number;
  3262. /**
  3263. * Returns the number for IsGreater
  3264. */
  3265. static readonly IsGreater: number;
  3266. /**
  3267. * Returns the number for IsLesser
  3268. */
  3269. static readonly IsLesser: number;
  3270. /**
  3271. * Internal only The action manager for the condition
  3272. * @hidden
  3273. */
  3274. _actionManager: ActionManager;
  3275. /**
  3276. * Internal only
  3277. * @hidden
  3278. */
  3279. private _target;
  3280. /**
  3281. * Internal only
  3282. * @hidden
  3283. */
  3284. private _effectiveTarget;
  3285. /**
  3286. * Internal only
  3287. * @hidden
  3288. */
  3289. private _property;
  3290. /**
  3291. * Creates a new ValueCondition
  3292. * @param actionManager manager for the action the condition applies to
  3293. * @param target for the action
  3294. * @param propertyPath path to specify the property of the target the conditional operator uses
  3295. * @param value the value compared by the conditional operator against the current value of the property
  3296. * @param operator the conditional operator, default ValueCondition.IsEqual
  3297. */
  3298. constructor(actionManager: ActionManager, target: any,
  3299. /** path to specify the property of the target the conditional operator uses */
  3300. propertyPath: string,
  3301. /** the value compared by the conditional operator against the current value of the property */
  3302. value: any,
  3303. /** the conditional operator, default ValueCondition.IsEqual */
  3304. operator?: number);
  3305. /**
  3306. * Compares the given value with the property value for the specified conditional operator
  3307. * @returns the result of the comparison
  3308. */
  3309. isValid(): boolean;
  3310. /**
  3311. * Serialize the ValueCondition into a JSON compatible object
  3312. * @returns serialization object
  3313. */
  3314. serialize(): any;
  3315. /**
  3316. * Gets the name of the conditional operator for the ValueCondition
  3317. * @param operator the conditional operator
  3318. * @returns the name
  3319. */
  3320. static GetOperatorName(operator: number): string;
  3321. }
  3322. /**
  3323. * Defines a predicate condition as an extension of Condition
  3324. */
  3325. class PredicateCondition extends Condition {
  3326. /** defines the predicate function used to validate the condition */
  3327. predicate: () => boolean;
  3328. /**
  3329. * Internal only - manager for action
  3330. * @hidden
  3331. */
  3332. _actionManager: ActionManager;
  3333. /**
  3334. * Creates a new PredicateCondition
  3335. * @param actionManager manager for the action the condition applies to
  3336. * @param predicate defines the predicate function used to validate the condition
  3337. */
  3338. constructor(actionManager: ActionManager,
  3339. /** defines the predicate function used to validate the condition */
  3340. predicate: () => boolean);
  3341. /**
  3342. * @returns the validity of the predicate condition
  3343. */
  3344. isValid(): boolean;
  3345. }
  3346. /**
  3347. * Defines a state condition as an extension of Condition
  3348. */
  3349. class StateCondition extends Condition {
  3350. /** Value to compare with target state */
  3351. value: string;
  3352. /**
  3353. * Internal only - manager for action
  3354. * @hidden
  3355. */
  3356. _actionManager: ActionManager;
  3357. /**
  3358. * Internal only
  3359. * @hidden
  3360. */
  3361. private _target;
  3362. /**
  3363. * Creates a new StateCondition
  3364. * @param actionManager manager for the action the condition applies to
  3365. * @param target of the condition
  3366. * @param value to compare with target state
  3367. */
  3368. constructor(actionManager: ActionManager, target: any,
  3369. /** Value to compare with target state */
  3370. value: string);
  3371. /**
  3372. * Gets a boolean indicating if the current condition is met
  3373. * @returns the validity of the state
  3374. */
  3375. isValid(): boolean;
  3376. /**
  3377. * Serialize the StateCondition into a JSON compatible object
  3378. * @returns serialization object
  3379. */
  3380. serialize(): any;
  3381. }
  3382. }
  3383. declare module BABYLON {
  3384. /**
  3385. * This defines an action responsible to toggle a boolean once triggered.
  3386. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3387. */
  3388. class SwitchBooleanAction extends Action {
  3389. /**
  3390. * The path to the boolean property in the target object
  3391. */
  3392. propertyPath: string;
  3393. private _target;
  3394. private _effectiveTarget;
  3395. private _property;
  3396. /**
  3397. * Instantiate the action
  3398. * @param triggerOptions defines the trigger options
  3399. * @param target defines the object containing the boolean
  3400. * @param propertyPath defines the path to the boolean property in the target object
  3401. * @param condition defines the trigger related conditions
  3402. */
  3403. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3404. /** @hidden */
  3405. _prepare(): void;
  3406. /**
  3407. * Execute the action toggle the boolean value.
  3408. */
  3409. execute(): void;
  3410. /**
  3411. * Serializes the actions and its related information.
  3412. * @param parent defines the object to serialize in
  3413. * @returns the serialized object
  3414. */
  3415. serialize(parent: any): any;
  3416. }
  3417. /**
  3418. * This defines an action responsible to set a the state field of the target
  3419. * to a desired value once triggered.
  3420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3421. */
  3422. class SetStateAction extends Action {
  3423. /**
  3424. * The value to store in the state field.
  3425. */
  3426. value: string;
  3427. private _target;
  3428. /**
  3429. * Instantiate the action
  3430. * @param triggerOptions defines the trigger options
  3431. * @param target defines the object containing the state property
  3432. * @param value defines the value to store in the state field
  3433. * @param condition defines the trigger related conditions
  3434. */
  3435. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3436. /**
  3437. * Execute the action and store the value on the target state property.
  3438. */
  3439. execute(): void;
  3440. /**
  3441. * Serializes the actions and its related information.
  3442. * @param parent defines the object to serialize in
  3443. * @returns the serialized object
  3444. */
  3445. serialize(parent: any): any;
  3446. }
  3447. /**
  3448. * This defines an action responsible to set a property of the target
  3449. * to a desired value once triggered.
  3450. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3451. */
  3452. class SetValueAction extends Action {
  3453. /**
  3454. * The path of the property to set in the target.
  3455. */
  3456. propertyPath: string;
  3457. /**
  3458. * The value to set in the property
  3459. */
  3460. value: any;
  3461. private _target;
  3462. private _effectiveTarget;
  3463. private _property;
  3464. /**
  3465. * Instantiate the action
  3466. * @param triggerOptions defines the trigger options
  3467. * @param target defines the object containing the property
  3468. * @param propertyPath defines the path of the property to set in the target
  3469. * @param value defines the value to set in the property
  3470. * @param condition defines the trigger related conditions
  3471. */
  3472. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3473. /** @hidden */
  3474. _prepare(): void;
  3475. /**
  3476. * Execute the action and set the targetted property to the desired value.
  3477. */
  3478. execute(): void;
  3479. /**
  3480. * Serializes the actions and its related information.
  3481. * @param parent defines the object to serialize in
  3482. * @returns the serialized object
  3483. */
  3484. serialize(parent: any): any;
  3485. }
  3486. /**
  3487. * This defines an action responsible to increment the target value
  3488. * to a desired value once triggered.
  3489. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3490. */
  3491. class IncrementValueAction extends Action {
  3492. /**
  3493. * The path of the property to increment in the target.
  3494. */
  3495. propertyPath: string;
  3496. /**
  3497. * The value we should increment the property by.
  3498. */
  3499. value: any;
  3500. private _target;
  3501. private _effectiveTarget;
  3502. private _property;
  3503. /**
  3504. * Instantiate the action
  3505. * @param triggerOptions defines the trigger options
  3506. * @param target defines the object containing the property
  3507. * @param propertyPath defines the path of the property to increment in the target
  3508. * @param value defines the value value we should increment the property by
  3509. * @param condition defines the trigger related conditions
  3510. */
  3511. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3512. /** @hidden */
  3513. _prepare(): void;
  3514. /**
  3515. * Execute the action and increment the target of the value amount.
  3516. */
  3517. execute(): void;
  3518. /**
  3519. * Serializes the actions and its related information.
  3520. * @param parent defines the object to serialize in
  3521. * @returns the serialized object
  3522. */
  3523. serialize(parent: any): any;
  3524. }
  3525. /**
  3526. * This defines an action responsible to start an animation once triggered.
  3527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3528. */
  3529. class PlayAnimationAction extends Action {
  3530. /**
  3531. * Where the animation should start (animation frame)
  3532. */
  3533. from: number;
  3534. /**
  3535. * Where the animation should stop (animation frame)
  3536. */
  3537. to: number;
  3538. /**
  3539. * Define if the animation should loop or stop after the first play.
  3540. */
  3541. loop?: boolean;
  3542. private _target;
  3543. /**
  3544. * Instantiate the action
  3545. * @param triggerOptions defines the trigger options
  3546. * @param target defines the target animation or animation name
  3547. * @param from defines from where the animation should start (animation frame)
  3548. * @param end defines where the animation should stop (animation frame)
  3549. * @param loop defines if the animation should loop or stop after the first play
  3550. * @param condition defines the trigger related conditions
  3551. */
  3552. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3553. /** @hidden */
  3554. _prepare(): void;
  3555. /**
  3556. * Execute the action and play the animation.
  3557. */
  3558. execute(): void;
  3559. /**
  3560. * Serializes the actions and its related information.
  3561. * @param parent defines the object to serialize in
  3562. * @returns the serialized object
  3563. */
  3564. serialize(parent: any): any;
  3565. }
  3566. /**
  3567. * This defines an action responsible to stop an animation once triggered.
  3568. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3569. */
  3570. class StopAnimationAction extends Action {
  3571. private _target;
  3572. /**
  3573. * Instantiate the action
  3574. * @param triggerOptions defines the trigger options
  3575. * @param target defines the target animation or animation name
  3576. * @param condition defines the trigger related conditions
  3577. */
  3578. constructor(triggerOptions: any, target: any, condition?: Condition);
  3579. /** @hidden */
  3580. _prepare(): void;
  3581. /**
  3582. * Execute the action and stop the animation.
  3583. */
  3584. execute(): void;
  3585. /**
  3586. * Serializes the actions and its related information.
  3587. * @param parent defines the object to serialize in
  3588. * @returns the serialized object
  3589. */
  3590. serialize(parent: any): any;
  3591. }
  3592. /**
  3593. * This defines an action responsible that does nothing once triggered.
  3594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3595. */
  3596. class DoNothingAction extends Action {
  3597. /**
  3598. * Instantiate the action
  3599. * @param triggerOptions defines the trigger options
  3600. * @param condition defines the trigger related conditions
  3601. */
  3602. constructor(triggerOptions?: any, condition?: Condition);
  3603. /**
  3604. * Execute the action and do nothing.
  3605. */
  3606. execute(): void;
  3607. /**
  3608. * Serializes the actions and its related information.
  3609. * @param parent defines the object to serialize in
  3610. * @returns the serialized object
  3611. */
  3612. serialize(parent: any): any;
  3613. }
  3614. /**
  3615. * This defines an action responsible to trigger several actions once triggered.
  3616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3617. */
  3618. class CombineAction extends Action {
  3619. /**
  3620. * The list of aggregated animations to run.
  3621. */
  3622. children: Action[];
  3623. /**
  3624. * Instantiate the action
  3625. * @param triggerOptions defines the trigger options
  3626. * @param children defines the list of aggregated animations to run
  3627. * @param condition defines the trigger related conditions
  3628. */
  3629. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3630. /** @hidden */
  3631. _prepare(): void;
  3632. /**
  3633. * Execute the action and executes all the aggregated actions.
  3634. */
  3635. execute(evt: ActionEvent): void;
  3636. /**
  3637. * Serializes the actions and its related information.
  3638. * @param parent defines the object to serialize in
  3639. * @returns the serialized object
  3640. */
  3641. serialize(parent: any): any;
  3642. }
  3643. /**
  3644. * This defines an action responsible to run code (external event) once triggered.
  3645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3646. */
  3647. class ExecuteCodeAction extends Action {
  3648. /**
  3649. * The callback function to run.
  3650. */
  3651. func: (evt: ActionEvent) => void;
  3652. /**
  3653. * Instantiate the action
  3654. * @param triggerOptions defines the trigger options
  3655. * @param func defines the callback function to run
  3656. * @param condition defines the trigger related conditions
  3657. */
  3658. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3659. /**
  3660. * Execute the action and run the attached code.
  3661. */
  3662. execute(evt: ActionEvent): void;
  3663. }
  3664. /**
  3665. * This defines an action responsible to set the parent property of the target once triggered.
  3666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3667. */
  3668. class SetParentAction extends Action {
  3669. private _parent;
  3670. private _target;
  3671. /**
  3672. * Instantiate the action
  3673. * @param triggerOptions defines the trigger options
  3674. * @param target defines the target containing the parent property
  3675. * @param parent defines from where the animation should start (animation frame)
  3676. * @param condition defines the trigger related conditions
  3677. */
  3678. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3679. /** @hidden */
  3680. _prepare(): void;
  3681. /**
  3682. * Execute the action and set the parent property.
  3683. */
  3684. execute(): void;
  3685. /**
  3686. * Serializes the actions and its related information.
  3687. * @param parent defines the object to serialize in
  3688. * @returns the serialized object
  3689. */
  3690. serialize(parent: any): any;
  3691. }
  3692. }
  3693. declare module BABYLON {
  3694. /**
  3695. * This defines an action helpful to play a defined sound on a triggered action.
  3696. */
  3697. class PlaySoundAction extends Action {
  3698. private _sound;
  3699. /**
  3700. * Instantiate the action
  3701. * @param triggerOptions defines the trigger options
  3702. * @param sound defines the sound to play
  3703. * @param condition defines the trigger related conditions
  3704. */
  3705. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3706. /** @hidden */
  3707. _prepare(): void;
  3708. /**
  3709. * Execute the action and play the sound.
  3710. */
  3711. execute(): void;
  3712. /**
  3713. * Serializes the actions and its related information.
  3714. * @param parent defines the object to serialize in
  3715. * @returns the serialized object
  3716. */
  3717. serialize(parent: any): any;
  3718. }
  3719. /**
  3720. * This defines an action helpful to stop a defined sound on a triggered action.
  3721. */
  3722. class StopSoundAction extends Action {
  3723. private _sound;
  3724. /**
  3725. * Instantiate the action
  3726. * @param triggerOptions defines the trigger options
  3727. * @param sound defines the sound to stop
  3728. * @param condition defines the trigger related conditions
  3729. */
  3730. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3731. /** @hidden */
  3732. _prepare(): void;
  3733. /**
  3734. * Execute the action and stop the sound.
  3735. */
  3736. execute(): void;
  3737. /**
  3738. * Serializes the actions and its related information.
  3739. * @param parent defines the object to serialize in
  3740. * @returns the serialized object
  3741. */
  3742. serialize(parent: any): any;
  3743. }
  3744. }
  3745. declare module BABYLON {
  3746. /**
  3747. * This defines an action responsible to change the value of a property
  3748. * by interpolating between its current value and the newly set one once triggered.
  3749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3750. */
  3751. class InterpolateValueAction extends Action {
  3752. /**
  3753. * Defines the path of the property where the value should be interpolated
  3754. */
  3755. propertyPath: string;
  3756. /**
  3757. * Defines the target value at the end of the interpolation.
  3758. */
  3759. value: any;
  3760. /**
  3761. * Defines the time it will take for the property to interpolate to the value.
  3762. */
  3763. duration: number;
  3764. /**
  3765. * Defines if the other scene animations should be stopped when the action has been triggered
  3766. */
  3767. stopOtherAnimations?: boolean;
  3768. /**
  3769. * Defines a callback raised once the interpolation animation has been done.
  3770. */
  3771. onInterpolationDone?: () => void;
  3772. /**
  3773. * Observable triggered once the interpolation animation has been done.
  3774. */
  3775. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3776. private _target;
  3777. private _effectiveTarget;
  3778. private _property;
  3779. /**
  3780. * Instantiate the action
  3781. * @param triggerOptions defines the trigger options
  3782. * @param target defines the object containing the value to interpolate
  3783. * @param propertyPath defines the path to the property in the target object
  3784. * @param value defines the target value at the end of the interpolation
  3785. * @param duration deines the time it will take for the property to interpolate to the value.
  3786. * @param condition defines the trigger related conditions
  3787. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3788. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3789. */
  3790. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3791. /** @hidden */
  3792. _prepare(): void;
  3793. /**
  3794. * Execute the action starts the value interpolation.
  3795. */
  3796. execute(): void;
  3797. /**
  3798. * Serializes the actions and its related information.
  3799. * @param parent defines the object to serialize in
  3800. * @returns the serialized object
  3801. */
  3802. serialize(parent: any): any;
  3803. }
  3804. }
  3805. declare module BABYLON {
  3806. /**
  3807. * Class used to store an actual running animation
  3808. */
  3809. class Animatable {
  3810. /** defines the target object */
  3811. target: any;
  3812. /** defines the starting frame number (default is 0) */
  3813. fromFrame: number;
  3814. /** defines the ending frame number (default is 100) */
  3815. toFrame: number;
  3816. /** defines if the animation must loop (default is false) */
  3817. loopAnimation: boolean;
  3818. /** defines a callback to call when animation ends if it is not looping */
  3819. onAnimationEnd?: (() => void) | null | undefined;
  3820. private _localDelayOffset;
  3821. private _pausedDelay;
  3822. private _runtimeAnimations;
  3823. private _paused;
  3824. private _scene;
  3825. private _speedRatio;
  3826. private _weight;
  3827. private _syncRoot;
  3828. /**
  3829. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3830. * This will only apply for non looping animation (default is true)
  3831. */
  3832. disposeOnEnd: boolean;
  3833. /**
  3834. * Gets a boolean indicating if the animation has started
  3835. */
  3836. animationStarted: boolean;
  3837. /**
  3838. * Observer raised when the animation ends
  3839. */
  3840. onAnimationEndObservable: Observable<Animatable>;
  3841. /**
  3842. * Gets the root Animatable used to synchronize and normalize animations
  3843. */
  3844. readonly syncRoot: Animatable;
  3845. /**
  3846. * Gets the current frame of the first RuntimeAnimation
  3847. * Used to synchronize Animatables
  3848. */
  3849. readonly masterFrame: number;
  3850. /**
  3851. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3852. */
  3853. weight: number;
  3854. /**
  3855. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3856. */
  3857. speedRatio: number;
  3858. /**
  3859. * Creates a new Animatable
  3860. * @param scene defines the hosting scene
  3861. * @param target defines the target object
  3862. * @param fromFrame defines the starting frame number (default is 0)
  3863. * @param toFrame defines the ending frame number (default is 100)
  3864. * @param loopAnimation defines if the animation must loop (default is false)
  3865. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3866. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3867. * @param animations defines a group of animation to add to the new Animatable
  3868. */
  3869. constructor(scene: Scene,
  3870. /** defines the target object */
  3871. target: any,
  3872. /** defines the starting frame number (default is 0) */
  3873. fromFrame?: number,
  3874. /** defines the ending frame number (default is 100) */
  3875. toFrame?: number,
  3876. /** defines if the animation must loop (default is false) */
  3877. loopAnimation?: boolean, speedRatio?: number,
  3878. /** defines a callback to call when animation ends if it is not looping */
  3879. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3880. /**
  3881. * Synchronize and normalize current Animatable with a source Animatable
  3882. * This is useful when using animation weights and when animations are not of the same length
  3883. * @param root defines the root Animatable to synchronize with
  3884. * @returns the current Animatable
  3885. */
  3886. syncWith(root: Animatable): Animatable;
  3887. /**
  3888. * Gets the list of runtime animations
  3889. * @returns an array of RuntimeAnimation
  3890. */
  3891. getAnimations(): RuntimeAnimation[];
  3892. /**
  3893. * Adds more animations to the current animatable
  3894. * @param target defines the target of the animations
  3895. * @param animations defines the new animations to add
  3896. */
  3897. appendAnimations(target: any, animations: Animation[]): void;
  3898. /**
  3899. * Gets the source animation for a specific property
  3900. * @param property defines the propertyu to look for
  3901. * @returns null or the source animation for the given property
  3902. */
  3903. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3904. /**
  3905. * Gets the runtime animation for a specific property
  3906. * @param property defines the propertyu to look for
  3907. * @returns null or the runtime animation for the given property
  3908. */
  3909. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3910. /**
  3911. * Resets the animatable to its original state
  3912. */
  3913. reset(): void;
  3914. /**
  3915. * Allows the animatable to blend with current running animations
  3916. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3917. * @param blendingSpeed defines the blending speed to use
  3918. */
  3919. enableBlending(blendingSpeed: number): void;
  3920. /**
  3921. * Disable animation blending
  3922. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3923. */
  3924. disableBlending(): void;
  3925. /**
  3926. * Jump directly to a given frame
  3927. * @param frame defines the frame to jump to
  3928. */
  3929. goToFrame(frame: number): void;
  3930. /**
  3931. * Pause the animation
  3932. */
  3933. pause(): void;
  3934. /**
  3935. * Restart the animation
  3936. */
  3937. restart(): void;
  3938. private _raiseOnAnimationEnd;
  3939. /**
  3940. * Stop and delete the current animation
  3941. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3942. * @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)
  3943. */
  3944. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3945. /**
  3946. * Wait asynchronously for the animation to end
  3947. * @returns a promise which will be fullfilled when the animation ends
  3948. */
  3949. waitAsync(): Promise<Animatable>;
  3950. /** @hidden */
  3951. _animate(delay: number): boolean;
  3952. }
  3953. }
  3954. declare module BABYLON {
  3955. /**
  3956. * Represents the range of an animation
  3957. */
  3958. class AnimationRange {
  3959. /**The name of the animation range**/
  3960. name: string;
  3961. /**The starting frame of the animation */
  3962. from: number;
  3963. /**The ending frame of the animation*/
  3964. to: number;
  3965. /**
  3966. * Initializes the range of an animation
  3967. * @param name The name of the animation range
  3968. * @param from The starting frame of the animation
  3969. * @param to The ending frame of the animation
  3970. */
  3971. constructor(
  3972. /**The name of the animation range**/
  3973. name: string,
  3974. /**The starting frame of the animation */
  3975. from: number,
  3976. /**The ending frame of the animation*/
  3977. to: number);
  3978. /**
  3979. * Makes a copy of the animation range
  3980. * @returns A copy of the animation range
  3981. */
  3982. clone(): AnimationRange;
  3983. }
  3984. /**
  3985. * Composed of a frame, and an action function
  3986. */
  3987. class AnimationEvent {
  3988. /** The frame for which the event is triggered **/
  3989. frame: number;
  3990. /** The event to perform when triggered **/
  3991. action: (currentFrame: number) => void;
  3992. /** Specifies if the event should be triggered only once**/
  3993. onlyOnce?: boolean | undefined;
  3994. /**
  3995. * Specifies if the animation event is done
  3996. */
  3997. isDone: boolean;
  3998. /**
  3999. * Initializes the animation event
  4000. * @param frame The frame for which the event is triggered
  4001. * @param action The event to perform when triggered
  4002. * @param onlyOnce Specifies if the event should be triggered only once
  4003. */
  4004. constructor(
  4005. /** The frame for which the event is triggered **/
  4006. frame: number,
  4007. /** The event to perform when triggered **/
  4008. action: (currentFrame: number) => void,
  4009. /** Specifies if the event should be triggered only once**/
  4010. onlyOnce?: boolean | undefined);
  4011. /** @hidden */
  4012. _clone(): AnimationEvent;
  4013. }
  4014. /**
  4015. * A cursor which tracks a point on a path
  4016. */
  4017. class PathCursor {
  4018. private path;
  4019. /**
  4020. * Stores path cursor callbacks for when an onchange event is triggered
  4021. */
  4022. private _onchange;
  4023. /**
  4024. * The value of the path cursor
  4025. */
  4026. value: number;
  4027. /**
  4028. * The animation array of the path cursor
  4029. */
  4030. animations: Animation[];
  4031. /**
  4032. * Initializes the path cursor
  4033. * @param path The path to track
  4034. */
  4035. constructor(path: Path2);
  4036. /**
  4037. * Gets the cursor point on the path
  4038. * @returns A point on the path cursor at the cursor location
  4039. */
  4040. getPoint(): Vector3;
  4041. /**
  4042. * Moves the cursor ahead by the step amount
  4043. * @param step The amount to move the cursor forward
  4044. * @returns This path cursor
  4045. */
  4046. moveAhead(step?: number): PathCursor;
  4047. /**
  4048. * Moves the cursor behind by the step amount
  4049. * @param step The amount to move the cursor back
  4050. * @returns This path cursor
  4051. */
  4052. moveBack(step?: number): PathCursor;
  4053. /**
  4054. * Moves the cursor by the step amount
  4055. * If the step amount is greater than one, an exception is thrown
  4056. * @param step The amount to move the cursor
  4057. * @returns This path cursor
  4058. */
  4059. move(step: number): PathCursor;
  4060. /**
  4061. * Ensures that the value is limited between zero and one
  4062. * @returns This path cursor
  4063. */
  4064. private ensureLimits;
  4065. /**
  4066. * Runs onchange callbacks on change (used by the animation engine)
  4067. * @returns This path cursor
  4068. */
  4069. private raiseOnChange;
  4070. /**
  4071. * Executes a function on change
  4072. * @param f A path cursor onchange callback
  4073. * @returns This path cursor
  4074. */
  4075. onchange(f: (cursor: PathCursor) => void): PathCursor;
  4076. }
  4077. /**
  4078. * Defines an interface which represents an animation key frame
  4079. */
  4080. interface IAnimationKey {
  4081. /**
  4082. * Frame of the key frame
  4083. */
  4084. frame: number;
  4085. /**
  4086. * Value at the specifies key frame
  4087. */
  4088. value: any;
  4089. /**
  4090. * The input tangent for the cubic hermite spline
  4091. */
  4092. inTangent?: any;
  4093. /**
  4094. * The output tangent for the cubic hermite spline
  4095. */
  4096. outTangent?: any;
  4097. /**
  4098. * The animation interpolation type
  4099. */
  4100. interpolation?: AnimationKeyInterpolation;
  4101. }
  4102. /**
  4103. * Enum for the animation key frame interpolation type
  4104. */
  4105. enum AnimationKeyInterpolation {
  4106. /**
  4107. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4108. */
  4109. STEP = 1
  4110. }
  4111. /**
  4112. * Class used to store any kind of animation
  4113. */
  4114. class Animation {
  4115. /**Name of the animation */
  4116. name: string;
  4117. /**Property to animate */
  4118. targetProperty: string;
  4119. /**The frames per second of the animation */
  4120. framePerSecond: number;
  4121. /**The data type of the animation */
  4122. dataType: number;
  4123. /**The loop mode of the animation */
  4124. loopMode?: number | undefined;
  4125. /**Specifies if blending should be enabled */
  4126. enableBlending?: boolean | undefined;
  4127. /**
  4128. * Use matrix interpolation instead of using direct key value when animating matrices
  4129. */
  4130. static AllowMatricesInterpolation: boolean;
  4131. /**
  4132. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4133. */
  4134. static AllowMatrixDecomposeForInterpolation: boolean;
  4135. /**
  4136. * Stores the key frames of the animation
  4137. */
  4138. private _keys;
  4139. /**
  4140. * Stores the easing function of the animation
  4141. */
  4142. private _easingFunction;
  4143. /**
  4144. * @hidden Internal use only
  4145. */
  4146. _runtimeAnimations: RuntimeAnimation[];
  4147. /**
  4148. * The set of event that will be linked to this animation
  4149. */
  4150. private _events;
  4151. /**
  4152. * Stores an array of target property paths
  4153. */
  4154. targetPropertyPath: string[];
  4155. /**
  4156. * Stores the blending speed of the animation
  4157. */
  4158. blendingSpeed: number;
  4159. /**
  4160. * Stores the animation ranges for the animation
  4161. */
  4162. private _ranges;
  4163. /**
  4164. * @hidden Internal use
  4165. */
  4166. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4167. /**
  4168. * Sets up an animation
  4169. * @param property The property to animate
  4170. * @param animationType The animation type to apply
  4171. * @param framePerSecond The frames per second of the animation
  4172. * @param easingFunction The easing function used in the animation
  4173. * @returns The created animation
  4174. */
  4175. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4176. /**
  4177. * Create and start an animation on a node
  4178. * @param name defines the name of the global animation that will be run on all nodes
  4179. * @param node defines the root node where the animation will take place
  4180. * @param targetProperty defines property to animate
  4181. * @param framePerSecond defines the number of frame per second yo use
  4182. * @param totalFrame defines the number of frames in total
  4183. * @param from defines the initial value
  4184. * @param to defines the final value
  4185. * @param loopMode defines which loop mode you want to use (off by default)
  4186. * @param easingFunction defines the easing function to use (linear by default)
  4187. * @param onAnimationEnd defines the callback to call when animation end
  4188. * @returns the animatable created for this animation
  4189. */
  4190. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4191. /**
  4192. * Create and start an animation on a node and its descendants
  4193. * @param name defines the name of the global animation that will be run on all nodes
  4194. * @param node defines the root node where the animation will take place
  4195. * @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
  4196. * @param targetProperty defines property to animate
  4197. * @param framePerSecond defines the number of frame per second to use
  4198. * @param totalFrame defines the number of frames in total
  4199. * @param from defines the initial value
  4200. * @param to defines the final value
  4201. * @param loopMode defines which loop mode you want to use (off by default)
  4202. * @param easingFunction defines the easing function to use (linear by default)
  4203. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4204. * @returns the list of animatables created for all nodes
  4205. * @example https://www.babylonjs-playground.com/#MH0VLI
  4206. */
  4207. 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[]>;
  4208. /**
  4209. * Creates a new animation, merges it with the existing animations and starts it
  4210. * @param name Name of the animation
  4211. * @param node Node which contains the scene that begins the animations
  4212. * @param targetProperty Specifies which property to animate
  4213. * @param framePerSecond The frames per second of the animation
  4214. * @param totalFrame The total number of frames
  4215. * @param from The frame at the beginning of the animation
  4216. * @param to The frame at the end of the animation
  4217. * @param loopMode Specifies the loop mode of the animation
  4218. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4219. * @param onAnimationEnd Callback to run once the animation is complete
  4220. * @returns Nullable animation
  4221. */
  4222. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4223. /**
  4224. * Transition property of an host to the target Value
  4225. * @param property The property to transition
  4226. * @param targetValue The target Value of the property
  4227. * @param host The object where the property to animate belongs
  4228. * @param scene Scene used to run the animation
  4229. * @param frameRate Framerate (in frame/s) to use
  4230. * @param transition The transition type we want to use
  4231. * @param duration The duration of the animation, in milliseconds
  4232. * @param onAnimationEnd Callback trigger at the end of the animation
  4233. * @returns Nullable animation
  4234. */
  4235. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4236. /**
  4237. * Return the array of runtime animations currently using this animation
  4238. */
  4239. readonly runtimeAnimations: RuntimeAnimation[];
  4240. /**
  4241. * Specifies if any of the runtime animations are currently running
  4242. */
  4243. readonly hasRunningRuntimeAnimations: boolean;
  4244. /**
  4245. * Initializes the animation
  4246. * @param name Name of the animation
  4247. * @param targetProperty Property to animate
  4248. * @param framePerSecond The frames per second of the animation
  4249. * @param dataType The data type of the animation
  4250. * @param loopMode The loop mode of the animation
  4251. * @param enableBlendings Specifies if blending should be enabled
  4252. */
  4253. constructor(
  4254. /**Name of the animation */
  4255. name: string,
  4256. /**Property to animate */
  4257. targetProperty: string,
  4258. /**The frames per second of the animation */
  4259. framePerSecond: number,
  4260. /**The data type of the animation */
  4261. dataType: number,
  4262. /**The loop mode of the animation */
  4263. loopMode?: number | undefined,
  4264. /**Specifies if blending should be enabled */
  4265. enableBlending?: boolean | undefined);
  4266. /**
  4267. * Converts the animation to a string
  4268. * @param fullDetails support for multiple levels of logging within scene loading
  4269. * @returns String form of the animation
  4270. */
  4271. toString(fullDetails?: boolean): string;
  4272. /**
  4273. * Add an event to this animation
  4274. * @param event Event to add
  4275. */
  4276. addEvent(event: AnimationEvent): void;
  4277. /**
  4278. * Remove all events found at the given frame
  4279. * @param frame The frame to remove events from
  4280. */
  4281. removeEvents(frame: number): void;
  4282. /**
  4283. * Retrieves all the events from the animation
  4284. * @returns Events from the animation
  4285. */
  4286. getEvents(): AnimationEvent[];
  4287. /**
  4288. * Creates an animation range
  4289. * @param name Name of the animation range
  4290. * @param from Starting frame of the animation range
  4291. * @param to Ending frame of the animation
  4292. */
  4293. createRange(name: string, from: number, to: number): void;
  4294. /**
  4295. * Deletes an animation range by name
  4296. * @param name Name of the animation range to delete
  4297. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4298. */
  4299. deleteRange(name: string, deleteFrames?: boolean): void;
  4300. /**
  4301. * Gets the animation range by name, or null if not defined
  4302. * @param name Name of the animation range
  4303. * @returns Nullable animation range
  4304. */
  4305. getRange(name: string): Nullable<AnimationRange>;
  4306. /**
  4307. * Gets the key frames from the animation
  4308. * @returns The key frames of the animation
  4309. */
  4310. getKeys(): Array<IAnimationKey>;
  4311. /**
  4312. * Gets the highest frame rate of the animation
  4313. * @returns Highest frame rate of the animation
  4314. */
  4315. getHighestFrame(): number;
  4316. /**
  4317. * Gets the easing function of the animation
  4318. * @returns Easing function of the animation
  4319. */
  4320. getEasingFunction(): IEasingFunction;
  4321. /**
  4322. * Sets the easing function of the animation
  4323. * @param easingFunction A custom mathematical formula for animation
  4324. */
  4325. setEasingFunction(easingFunction: EasingFunction): void;
  4326. /**
  4327. * Interpolates a scalar linearly
  4328. * @param startValue Start value of the animation curve
  4329. * @param endValue End value of the animation curve
  4330. * @param gradient Scalar amount to interpolate
  4331. * @returns Interpolated scalar value
  4332. */
  4333. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4334. /**
  4335. * Interpolates a scalar cubically
  4336. * @param startValue Start value of the animation curve
  4337. * @param outTangent End tangent of the animation
  4338. * @param endValue End value of the animation curve
  4339. * @param inTangent Start tangent of the animation curve
  4340. * @param gradient Scalar amount to interpolate
  4341. * @returns Interpolated scalar value
  4342. */
  4343. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4344. /**
  4345. * Interpolates a quaternion using a spherical linear interpolation
  4346. * @param startValue Start value of the animation curve
  4347. * @param endValue End value of the animation curve
  4348. * @param gradient Scalar amount to interpolate
  4349. * @returns Interpolated quaternion value
  4350. */
  4351. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4352. /**
  4353. * Interpolates a quaternion cubically
  4354. * @param startValue Start value of the animation curve
  4355. * @param outTangent End tangent of the animation curve
  4356. * @param endValue End value of the animation curve
  4357. * @param inTangent Start tangent of the animation curve
  4358. * @param gradient Scalar amount to interpolate
  4359. * @returns Interpolated quaternion value
  4360. */
  4361. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4362. /**
  4363. * Interpolates a Vector3 linearl
  4364. * @param startValue Start value of the animation curve
  4365. * @param endValue End value of the animation curve
  4366. * @param gradient Scalar amount to interpolate
  4367. * @returns Interpolated scalar value
  4368. */
  4369. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4370. /**
  4371. * Interpolates a Vector3 cubically
  4372. * @param startValue Start value of the animation curve
  4373. * @param outTangent End tangent of the animation
  4374. * @param endValue End value of the animation curve
  4375. * @param inTangent Start tangent of the animation curve
  4376. * @param gradient Scalar amount to interpolate
  4377. * @returns InterpolatedVector3 value
  4378. */
  4379. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4380. /**
  4381. * Interpolates a Vector2 linearly
  4382. * @param startValue Start value of the animation curve
  4383. * @param endValue End value of the animation curve
  4384. * @param gradient Scalar amount to interpolate
  4385. * @returns Interpolated Vector2 value
  4386. */
  4387. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4388. /**
  4389. * Interpolates a Vector2 cubically
  4390. * @param startValue Start value of the animation curve
  4391. * @param outTangent End tangent of the animation
  4392. * @param endValue End value of the animation curve
  4393. * @param inTangent Start tangent of the animation curve
  4394. * @param gradient Scalar amount to interpolate
  4395. * @returns Interpolated Vector2 value
  4396. */
  4397. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4398. /**
  4399. * Interpolates a size linearly
  4400. * @param startValue Start value of the animation curve
  4401. * @param endValue End value of the animation curve
  4402. * @param gradient Scalar amount to interpolate
  4403. * @returns Interpolated Size value
  4404. */
  4405. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4406. /**
  4407. * Interpolates a Color3 linearly
  4408. * @param startValue Start value of the animation curve
  4409. * @param endValue End value of the animation curve
  4410. * @param gradient Scalar amount to interpolate
  4411. * @returns Interpolated Color3 value
  4412. */
  4413. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4414. /**
  4415. * @hidden Internal use only
  4416. */
  4417. _getKeyValue(value: any): any;
  4418. /**
  4419. * @hidden Internal use only
  4420. */
  4421. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4422. /**
  4423. * Defines the function to use to interpolate matrices
  4424. * @param startValue defines the start matrix
  4425. * @param endValue defines the end matrix
  4426. * @param gradient defines the gradient between both matrices
  4427. * @param result defines an optional target matrix where to store the interpolation
  4428. * @returns the interpolated matrix
  4429. */
  4430. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4431. /**
  4432. * Makes a copy of the animation
  4433. * @returns Cloned animation
  4434. */
  4435. clone(): Animation;
  4436. /**
  4437. * Sets the key frames of the animation
  4438. * @param values The animation key frames to set
  4439. */
  4440. setKeys(values: Array<IAnimationKey>): void;
  4441. /**
  4442. * Serializes the animation to an object
  4443. * @returns Serialized object
  4444. */
  4445. serialize(): any;
  4446. /**
  4447. * Float animation type
  4448. */
  4449. private static _ANIMATIONTYPE_FLOAT;
  4450. /**
  4451. * Vector3 animation type
  4452. */
  4453. private static _ANIMATIONTYPE_VECTOR3;
  4454. /**
  4455. * Quaternion animation type
  4456. */
  4457. private static _ANIMATIONTYPE_QUATERNION;
  4458. /**
  4459. * Matrix animation type
  4460. */
  4461. private static _ANIMATIONTYPE_MATRIX;
  4462. /**
  4463. * Color3 animation type
  4464. */
  4465. private static _ANIMATIONTYPE_COLOR3;
  4466. /**
  4467. * Vector2 animation type
  4468. */
  4469. private static _ANIMATIONTYPE_VECTOR2;
  4470. /**
  4471. * Size animation type
  4472. */
  4473. private static _ANIMATIONTYPE_SIZE;
  4474. /**
  4475. * Relative Loop Mode
  4476. */
  4477. private static _ANIMATIONLOOPMODE_RELATIVE;
  4478. /**
  4479. * Cycle Loop Mode
  4480. */
  4481. private static _ANIMATIONLOOPMODE_CYCLE;
  4482. /**
  4483. * Constant Loop Mode
  4484. */
  4485. private static _ANIMATIONLOOPMODE_CONSTANT;
  4486. /**
  4487. * Get the float animation type
  4488. */
  4489. static readonly ANIMATIONTYPE_FLOAT: number;
  4490. /**
  4491. * Get the Vector3 animation type
  4492. */
  4493. static readonly ANIMATIONTYPE_VECTOR3: number;
  4494. /**
  4495. * Get the Vector2 animation type
  4496. */
  4497. static readonly ANIMATIONTYPE_VECTOR2: number;
  4498. /**
  4499. * Get the Size animation type
  4500. */
  4501. static readonly ANIMATIONTYPE_SIZE: number;
  4502. /**
  4503. * Get the Quaternion animation type
  4504. */
  4505. static readonly ANIMATIONTYPE_QUATERNION: number;
  4506. /**
  4507. * Get the Matrix animation type
  4508. */
  4509. static readonly ANIMATIONTYPE_MATRIX: number;
  4510. /**
  4511. * Get the Color3 animation type
  4512. */
  4513. static readonly ANIMATIONTYPE_COLOR3: number;
  4514. /**
  4515. * Get the Relative Loop Mode
  4516. */
  4517. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4518. /**
  4519. * Get the Cycle Loop Mode
  4520. */
  4521. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4522. /**
  4523. * Get the Constant Loop Mode
  4524. */
  4525. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4526. /** @hidden */
  4527. static _UniversalLerp(left: any, right: any, amount: number): any;
  4528. /**
  4529. * Parses an animation object and creates an animation
  4530. * @param parsedAnimation Parsed animation object
  4531. * @returns Animation object
  4532. */
  4533. static Parse(parsedAnimation: any): Animation;
  4534. /**
  4535. * Appends the serialized animations from the source animations
  4536. * @param source Source containing the animations
  4537. * @param destination Target to store the animations
  4538. */
  4539. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4540. }
  4541. }
  4542. declare module BABYLON {
  4543. /**
  4544. * This class defines the direct association between an animation and a target
  4545. */
  4546. class TargetedAnimation {
  4547. /**
  4548. * Animation to perform
  4549. */
  4550. animation: Animation;
  4551. /**
  4552. * Target to animate
  4553. */
  4554. target: any;
  4555. }
  4556. /**
  4557. * Use this class to create coordinated animations on multiple targets
  4558. */
  4559. class AnimationGroup implements IDisposable {
  4560. /** The name of the animation group */
  4561. name: string;
  4562. private _scene;
  4563. private _targetedAnimations;
  4564. private _animatables;
  4565. private _from;
  4566. private _to;
  4567. private _isStarted;
  4568. private _speedRatio;
  4569. /**
  4570. * This observable will notify when one animation have ended.
  4571. */
  4572. onAnimationEndObservable: Observable<TargetedAnimation>;
  4573. /**
  4574. * This observable will notify when all animations have ended.
  4575. */
  4576. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4577. /**
  4578. * This observable will notify when all animations have paused.
  4579. */
  4580. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4581. /**
  4582. * Gets the first frame
  4583. */
  4584. readonly from: number;
  4585. /**
  4586. * Gets the last frame
  4587. */
  4588. readonly to: number;
  4589. /**
  4590. * Define if the animations are started
  4591. */
  4592. readonly isStarted: boolean;
  4593. /**
  4594. * Gets or sets the speed ratio to use for all animations
  4595. */
  4596. /**
  4597. * Gets or sets the speed ratio to use for all animations
  4598. */
  4599. speedRatio: number;
  4600. /**
  4601. * Gets the targeted animations for this animation group
  4602. */
  4603. readonly targetedAnimations: Array<TargetedAnimation>;
  4604. /**
  4605. * returning the list of animatables controlled by this animation group.
  4606. */
  4607. readonly animatables: Array<Animatable>;
  4608. /**
  4609. * Instantiates a new Animation Group.
  4610. * This helps managing several animations at once.
  4611. * @see http://doc.babylonjs.com/how_to/group
  4612. * @param name Defines the name of the group
  4613. * @param scene Defines the scene the group belongs to
  4614. */
  4615. constructor(
  4616. /** The name of the animation group */
  4617. name: string, scene?: Nullable<Scene>);
  4618. /**
  4619. * Add an animation (with its target) in the group
  4620. * @param animation defines the animation we want to add
  4621. * @param target defines the target of the animation
  4622. * @returns the TargetedAnimation object
  4623. */
  4624. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4625. /**
  4626. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4627. * It can add constant keys at begin or end
  4628. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4629. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4630. * @returns the animation group
  4631. */
  4632. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4633. /**
  4634. * Start all animations on given targets
  4635. * @param loop defines if animations must loop
  4636. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4637. * @param from defines the from key (optional)
  4638. * @param to defines the to key (optional)
  4639. * @returns the current animation group
  4640. */
  4641. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4642. /**
  4643. * Pause all animations
  4644. * @returns the animation group
  4645. */
  4646. pause(): AnimationGroup;
  4647. /**
  4648. * Play all animations to initial state
  4649. * This function will start() the animations if they were not started or will restart() them if they were paused
  4650. * @param loop defines if animations must loop
  4651. * @returns the animation group
  4652. */
  4653. play(loop?: boolean): AnimationGroup;
  4654. /**
  4655. * Reset all animations to initial state
  4656. * @returns the animation group
  4657. */
  4658. reset(): AnimationGroup;
  4659. /**
  4660. * Restart animations from key 0
  4661. * @returns the animation group
  4662. */
  4663. restart(): AnimationGroup;
  4664. /**
  4665. * Stop all animations
  4666. * @returns the animation group
  4667. */
  4668. stop(): AnimationGroup;
  4669. /**
  4670. * Set animation weight for all animatables
  4671. * @param weight defines the weight to use
  4672. * @return the animationGroup
  4673. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4674. */
  4675. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4676. /**
  4677. * Synchronize and normalize all animatables with a source animatable
  4678. * @param root defines the root animatable to synchronize with
  4679. * @return the animationGroup
  4680. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4681. */
  4682. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4683. /**
  4684. * Goes to a specific frame in this animation group
  4685. * @param frame the frame number to go to
  4686. * @return the animationGroup
  4687. */
  4688. goToFrame(frame: number): AnimationGroup;
  4689. /**
  4690. * Dispose all associated resources
  4691. */
  4692. dispose(): void;
  4693. private _checkAnimationGroupEnded;
  4694. /**
  4695. * Returns a new AnimationGroup object parsed from the source provided.
  4696. * @param parsedAnimationGroup defines the source
  4697. * @param scene defines the scene that will receive the animationGroup
  4698. * @returns a new AnimationGroup
  4699. */
  4700. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4701. /**
  4702. * Returns the string "AnimationGroup"
  4703. * @returns "AnimationGroup"
  4704. */
  4705. getClassName(): string;
  4706. /**
  4707. * Creates a detailled string about the object
  4708. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4709. * @returns a string representing the object
  4710. */
  4711. toString(fullDetails?: boolean): string;
  4712. }
  4713. }
  4714. declare module BABYLON {
  4715. /**
  4716. * Class used to override all child animations of a given target
  4717. */
  4718. class AnimationPropertiesOverride {
  4719. /**
  4720. * Gets or sets a value indicating if animation blending must be used
  4721. */
  4722. enableBlending: boolean;
  4723. /**
  4724. * Gets or sets the blending speed to use when enableBlending is true
  4725. */
  4726. blendingSpeed: number;
  4727. /**
  4728. * Gets or sets the default loop mode to use
  4729. */
  4730. loopMode: number;
  4731. }
  4732. }
  4733. declare module BABYLON {
  4734. /**
  4735. * This represents the main contract an easing function should follow.
  4736. * Easing functions are used throughout the animation system.
  4737. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4738. */
  4739. interface IEasingFunction {
  4740. /**
  4741. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4742. * of the easing function.
  4743. * The link below provides some of the most common examples of easing functions.
  4744. * @see https://easings.net/
  4745. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4746. * @returns the corresponding value on the curve defined by the easing function
  4747. */
  4748. ease(gradient: number): number;
  4749. }
  4750. /**
  4751. * Base class used for every default easing function.
  4752. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4753. */
  4754. class EasingFunction implements IEasingFunction {
  4755. /**
  4756. * Interpolation follows the mathematical formula associated with the easing function.
  4757. */
  4758. static readonly EASINGMODE_EASEIN: number;
  4759. /**
  4760. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4761. */
  4762. static readonly EASINGMODE_EASEOUT: number;
  4763. /**
  4764. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4765. */
  4766. static readonly EASINGMODE_EASEINOUT: number;
  4767. private _easingMode;
  4768. /**
  4769. * Sets the easing mode of the current function.
  4770. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4771. */
  4772. setEasingMode(easingMode: number): void;
  4773. /**
  4774. * Gets the current easing mode.
  4775. * @returns the easing mode
  4776. */
  4777. getEasingMode(): number;
  4778. /**
  4779. * @hidden
  4780. */
  4781. easeInCore(gradient: number): number;
  4782. /**
  4783. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4784. * of the easing function.
  4785. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4786. * @returns the corresponding value on the curve defined by the easing function
  4787. */
  4788. ease(gradient: number): number;
  4789. }
  4790. /**
  4791. * Easing function with a circle shape (see link below).
  4792. * @see https://easings.net/#easeInCirc
  4793. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4794. */
  4795. class CircleEase extends EasingFunction implements IEasingFunction {
  4796. /** @hidden */
  4797. easeInCore(gradient: number): number;
  4798. }
  4799. /**
  4800. * Easing function with a ease back shape (see link below).
  4801. * @see https://easings.net/#easeInBack
  4802. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4803. */
  4804. class BackEase extends EasingFunction implements IEasingFunction {
  4805. /** Defines the amplitude of the function */
  4806. amplitude: number;
  4807. /**
  4808. * Instantiates a back ease easing
  4809. * @see https://easings.net/#easeInBack
  4810. * @param amplitude Defines the amplitude of the function
  4811. */
  4812. constructor(
  4813. /** Defines the amplitude of the function */
  4814. amplitude?: number);
  4815. /** @hidden */
  4816. easeInCore(gradient: number): number;
  4817. }
  4818. /**
  4819. * Easing function with a bouncing shape (see link below).
  4820. * @see https://easings.net/#easeInBounce
  4821. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4822. */
  4823. class BounceEase extends EasingFunction implements IEasingFunction {
  4824. /** Defines the number of bounces */
  4825. bounces: number;
  4826. /** Defines the amplitude of the bounce */
  4827. bounciness: number;
  4828. /**
  4829. * Instantiates a bounce easing
  4830. * @see https://easings.net/#easeInBounce
  4831. * @param bounces Defines the number of bounces
  4832. * @param bounciness Defines the amplitude of the bounce
  4833. */
  4834. constructor(
  4835. /** Defines the number of bounces */
  4836. bounces?: number,
  4837. /** Defines the amplitude of the bounce */
  4838. bounciness?: number);
  4839. /** @hidden */
  4840. easeInCore(gradient: number): number;
  4841. }
  4842. /**
  4843. * Easing function with a power of 3 shape (see link below).
  4844. * @see https://easings.net/#easeInCubic
  4845. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4846. */
  4847. class CubicEase extends EasingFunction implements IEasingFunction {
  4848. /** @hidden */
  4849. easeInCore(gradient: number): number;
  4850. }
  4851. /**
  4852. * Easing function with an elastic shape (see link below).
  4853. * @see https://easings.net/#easeInElastic
  4854. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4855. */
  4856. class ElasticEase extends EasingFunction implements IEasingFunction {
  4857. /** Defines the number of oscillations*/
  4858. oscillations: number;
  4859. /** Defines the amplitude of the oscillations*/
  4860. springiness: number;
  4861. /**
  4862. * Instantiates an elastic easing function
  4863. * @see https://easings.net/#easeInElastic
  4864. * @param oscillations Defines the number of oscillations
  4865. * @param springiness Defines the amplitude of the oscillations
  4866. */
  4867. constructor(
  4868. /** Defines the number of oscillations*/
  4869. oscillations?: number,
  4870. /** Defines the amplitude of the oscillations*/
  4871. springiness?: number);
  4872. /** @hidden */
  4873. easeInCore(gradient: number): number;
  4874. }
  4875. /**
  4876. * Easing function with an exponential shape (see link below).
  4877. * @see https://easings.net/#easeInExpo
  4878. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4879. */
  4880. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4881. /** Defines the exponent of the function */
  4882. exponent: number;
  4883. /**
  4884. * Instantiates an exponential easing function
  4885. * @see https://easings.net/#easeInExpo
  4886. * @param exponent Defines the exponent of the function
  4887. */
  4888. constructor(
  4889. /** Defines the exponent of the function */
  4890. exponent?: number);
  4891. /** @hidden */
  4892. easeInCore(gradient: number): number;
  4893. }
  4894. /**
  4895. * Easing function with a power shape (see link below).
  4896. * @see https://easings.net/#easeInQuad
  4897. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4898. */
  4899. class PowerEase extends EasingFunction implements IEasingFunction {
  4900. /** Defines the power of the function */
  4901. power: number;
  4902. /**
  4903. * Instantiates an power base easing function
  4904. * @see https://easings.net/#easeInQuad
  4905. * @param power Defines the power of the function
  4906. */
  4907. constructor(
  4908. /** Defines the power of the function */
  4909. power?: number);
  4910. /** @hidden */
  4911. easeInCore(gradient: number): number;
  4912. }
  4913. /**
  4914. * Easing function with a power of 2 shape (see link below).
  4915. * @see https://easings.net/#easeInQuad
  4916. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4917. */
  4918. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4919. /** @hidden */
  4920. easeInCore(gradient: number): number;
  4921. }
  4922. /**
  4923. * Easing function with a power of 4 shape (see link below).
  4924. * @see https://easings.net/#easeInQuart
  4925. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4926. */
  4927. class QuarticEase extends EasingFunction implements IEasingFunction {
  4928. /** @hidden */
  4929. easeInCore(gradient: number): number;
  4930. }
  4931. /**
  4932. * Easing function with a power of 5 shape (see link below).
  4933. * @see https://easings.net/#easeInQuint
  4934. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4935. */
  4936. class QuinticEase extends EasingFunction implements IEasingFunction {
  4937. /** @hidden */
  4938. easeInCore(gradient: number): number;
  4939. }
  4940. /**
  4941. * Easing function with a sin shape (see link below).
  4942. * @see https://easings.net/#easeInSine
  4943. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4944. */
  4945. class SineEase extends EasingFunction implements IEasingFunction {
  4946. /** @hidden */
  4947. easeInCore(gradient: number): number;
  4948. }
  4949. /**
  4950. * Easing function with a bezier shape (see link below).
  4951. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4952. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4953. */
  4954. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4955. /** Defines the x component of the start tangent in the bezier curve */
  4956. x1: number;
  4957. /** Defines the y component of the start tangent in the bezier curve */
  4958. y1: number;
  4959. /** Defines the x component of the end tangent in the bezier curve */
  4960. x2: number;
  4961. /** Defines the y component of the end tangent in the bezier curve */
  4962. y2: number;
  4963. /**
  4964. * Instantiates a bezier function
  4965. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4966. * @param x1 Defines the x component of the start tangent in the bezier curve
  4967. * @param y1 Defines the y component of the start tangent in the bezier curve
  4968. * @param x2 Defines the x component of the end tangent in the bezier curve
  4969. * @param y2 Defines the y component of the end tangent in the bezier curve
  4970. */
  4971. constructor(
  4972. /** Defines the x component of the start tangent in the bezier curve */
  4973. x1?: number,
  4974. /** Defines the y component of the start tangent in the bezier curve */
  4975. y1?: number,
  4976. /** Defines the x component of the end tangent in the bezier curve */
  4977. x2?: number,
  4978. /** Defines the y component of the end tangent in the bezier curve */
  4979. y2?: number);
  4980. /** @hidden */
  4981. easeInCore(gradient: number): number;
  4982. }
  4983. }
  4984. declare module BABYLON {
  4985. /**
  4986. * Defines a runtime animation
  4987. */
  4988. class RuntimeAnimation {
  4989. private _events;
  4990. /**
  4991. * The current frame of the runtime animation
  4992. */
  4993. private _currentFrame;
  4994. /**
  4995. * The animation used by the runtime animation
  4996. */
  4997. private _animation;
  4998. /**
  4999. * The target of the runtime animation
  5000. */
  5001. private _target;
  5002. /**
  5003. * The initiating animatable
  5004. */
  5005. private _host;
  5006. /**
  5007. * The original value of the runtime animation
  5008. */
  5009. private _originalValue;
  5010. /**
  5011. * The original blend value of the runtime animation
  5012. */
  5013. private _originalBlendValue;
  5014. /**
  5015. * The offsets cache of the runtime animation
  5016. */
  5017. private _offsetsCache;
  5018. /**
  5019. * The high limits cache of the runtime animation
  5020. */
  5021. private _highLimitsCache;
  5022. /**
  5023. * Specifies if the runtime animation has been stopped
  5024. */
  5025. private _stopped;
  5026. /**
  5027. * The blending factor of the runtime animation
  5028. */
  5029. private _blendingFactor;
  5030. /**
  5031. * The BabylonJS scene
  5032. */
  5033. private _scene;
  5034. /**
  5035. * The current value of the runtime animation
  5036. */
  5037. private _currentValue;
  5038. /** @hidden */
  5039. _workValue: any;
  5040. /**
  5041. * The active target of the runtime animation
  5042. */
  5043. private _activeTarget;
  5044. /**
  5045. * The target path of the runtime animation
  5046. */
  5047. private _targetPath;
  5048. /**
  5049. * The weight of the runtime animation
  5050. */
  5051. private _weight;
  5052. /**
  5053. * The ratio offset of the runtime animation
  5054. */
  5055. private _ratioOffset;
  5056. /**
  5057. * The previous delay of the runtime animation
  5058. */
  5059. private _previousDelay;
  5060. /**
  5061. * The previous ratio of the runtime animation
  5062. */
  5063. private _previousRatio;
  5064. /**
  5065. * Gets the current frame of the runtime animation
  5066. */
  5067. readonly currentFrame: number;
  5068. /**
  5069. * Gets the weight of the runtime animation
  5070. */
  5071. readonly weight: number;
  5072. /**
  5073. * Gets the current value of the runtime animation
  5074. */
  5075. readonly currentValue: any;
  5076. /**
  5077. * Gets the target path of the runtime animation
  5078. */
  5079. readonly targetPath: string;
  5080. /**
  5081. * Gets the actual target of the runtime animation
  5082. */
  5083. readonly target: any;
  5084. /**
  5085. * Create a new RuntimeAnimation object
  5086. * @param target defines the target of the animation
  5087. * @param animation defines the source animation object
  5088. * @param scene defines the hosting scene
  5089. * @param host defines the initiating Animatable
  5090. */
  5091. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5092. /**
  5093. * Gets the animation from the runtime animation
  5094. */
  5095. readonly animation: Animation;
  5096. /**
  5097. * Resets the runtime animation to the beginning
  5098. * @param restoreOriginal defines whether to restore the target property to the original value
  5099. */
  5100. reset(restoreOriginal?: boolean): void;
  5101. /**
  5102. * Specifies if the runtime animation is stopped
  5103. * @returns Boolean specifying if the runtime animation is stopped
  5104. */
  5105. isStopped(): boolean;
  5106. /**
  5107. * Disposes of the runtime animation
  5108. */
  5109. dispose(): void;
  5110. /**
  5111. * Interpolates the animation from the current frame
  5112. * @param currentFrame The frame to interpolate the animation to
  5113. * @param repeatCount The number of times that the animation should loop
  5114. * @param loopMode The type of looping mode to use
  5115. * @param offsetValue Animation offset value
  5116. * @param highLimitValue The high limit value
  5117. * @returns The interpolated value
  5118. */
  5119. private _interpolate;
  5120. /**
  5121. * Apply the interpolated value to the target
  5122. * @param currentValue defines the value computed by the animation
  5123. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5124. */
  5125. setValue(currentValue: any, weight?: number): void;
  5126. private _setValue;
  5127. /**
  5128. * Gets the loop pmode of the runtime animation
  5129. * @returns Loop Mode
  5130. */
  5131. private _getCorrectLoopMode;
  5132. /**
  5133. * Move the current animation to a given frame
  5134. * @param frame defines the frame to move to
  5135. */
  5136. goToFrame(frame: number): void;
  5137. /**
  5138. * @hidden Internal use only
  5139. */
  5140. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5141. /**
  5142. * Execute the current animation
  5143. * @param delay defines the delay to add to the current frame
  5144. * @param from defines the lower bound of the animation range
  5145. * @param to defines the upper bound of the animation range
  5146. * @param loop defines if the current animation must loop
  5147. * @param speedRatio defines the current speed ratio
  5148. * @param weight defines the weight of the animation (default is -1 so no weight)
  5149. * @returns a boolean indicating if the animation is running
  5150. */
  5151. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  5152. }
  5153. }
  5154. declare module BABYLON {
  5155. /**
  5156. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5158. */
  5159. class Analyser {
  5160. /**
  5161. * Gets or sets the smoothing
  5162. * @ignorenaming
  5163. */
  5164. SMOOTHING: number;
  5165. /**
  5166. * Gets or sets the FFT table size
  5167. * @ignorenaming
  5168. */
  5169. FFT_SIZE: number;
  5170. /**
  5171. * Gets or sets the bar graph amplitude
  5172. * @ignorenaming
  5173. */
  5174. BARGRAPHAMPLITUDE: number;
  5175. /**
  5176. * Gets or sets the position of the debug canvas
  5177. * @ignorenaming
  5178. */
  5179. DEBUGCANVASPOS: {
  5180. x: number;
  5181. y: number;
  5182. };
  5183. /**
  5184. * Gets or sets the debug canvas size
  5185. * @ignorenaming
  5186. */
  5187. DEBUGCANVASSIZE: {
  5188. width: number;
  5189. height: number;
  5190. };
  5191. private _byteFreqs;
  5192. private _byteTime;
  5193. private _floatFreqs;
  5194. private _webAudioAnalyser;
  5195. private _debugCanvas;
  5196. private _debugCanvasContext;
  5197. private _scene;
  5198. private _registerFunc;
  5199. private _audioEngine;
  5200. /**
  5201. * Creates a new analyser
  5202. * @param scene defines hosting scene
  5203. */
  5204. constructor(scene: Scene);
  5205. /**
  5206. * Get the number of data values you will have to play with for the visualization
  5207. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5208. * @returns a number
  5209. */
  5210. getFrequencyBinCount(): number;
  5211. /**
  5212. * Gets the current frequency data as a byte array
  5213. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5214. * @returns a Uint8Array
  5215. */
  5216. getByteFrequencyData(): Uint8Array;
  5217. /**
  5218. * Gets the current waveform as a byte array
  5219. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5220. * @returns a Uint8Array
  5221. */
  5222. getByteTimeDomainData(): Uint8Array;
  5223. /**
  5224. * Gets the current frequency data as a float array
  5225. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5226. * @returns a Float32Array
  5227. */
  5228. getFloatFrequencyData(): Float32Array;
  5229. /**
  5230. * Renders the debug canvas
  5231. */
  5232. drawDebugCanvas(): void;
  5233. /**
  5234. * Stops rendering the debug canvas and removes it
  5235. */
  5236. stopDebugCanvas(): void;
  5237. /**
  5238. * Connects two audio nodes
  5239. * @param inputAudioNode defines first node to connect
  5240. * @param outputAudioNode defines second node to connect
  5241. */
  5242. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5243. /**
  5244. * Releases all associated resources
  5245. */
  5246. dispose(): void;
  5247. }
  5248. }
  5249. declare module BABYLON {
  5250. /**
  5251. * This represents an audio engine and it is responsible
  5252. * to play, synchronize and analyse sounds throughout the application.
  5253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5254. */
  5255. interface IAudioEngine extends IDisposable {
  5256. /**
  5257. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5258. */
  5259. readonly canUseWebAudio: boolean;
  5260. /**
  5261. * Gets the current AudioContext if available.
  5262. */
  5263. readonly audioContext: Nullable<AudioContext>;
  5264. /**
  5265. * The master gain node defines the global audio volume of your audio engine.
  5266. */
  5267. readonly masterGain: GainNode;
  5268. /**
  5269. * Gets whether or not mp3 are supported by your browser.
  5270. */
  5271. readonly isMP3supported: boolean;
  5272. /**
  5273. * Gets whether or not ogg are supported by your browser.
  5274. */
  5275. readonly isOGGsupported: boolean;
  5276. /**
  5277. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5278. * @ignoreNaming
  5279. */
  5280. WarnedWebAudioUnsupported: boolean;
  5281. /**
  5282. * Defines if the audio engine relies on a custom unlocked button.
  5283. * In this case, the embedded button will not be displayed.
  5284. */
  5285. useCustomUnlockedButton: boolean;
  5286. /**
  5287. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5288. */
  5289. readonly unlocked: boolean;
  5290. /**
  5291. * Event raised when audio has been unlocked on the browser.
  5292. */
  5293. onAudioUnlockedObservable: Observable<AudioEngine>;
  5294. /**
  5295. * Event raised when audio has been locked on the browser.
  5296. */
  5297. onAudioLockedObservable: Observable<AudioEngine>;
  5298. /**
  5299. * Flags the audio engine in Locked state.
  5300. * This happens due to new browser policies preventing audio to autoplay.
  5301. */
  5302. lock(): void;
  5303. /**
  5304. * Unlocks the audio engine once a user action has been done on the dom.
  5305. * This is helpful to resume play once browser policies have been satisfied.
  5306. */
  5307. unlock(): void;
  5308. }
  5309. /**
  5310. * This represents the default audio engine used in babylon.
  5311. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5313. */
  5314. class AudioEngine implements IAudioEngine {
  5315. private _audioContext;
  5316. private _audioContextInitialized;
  5317. private _muteButton;
  5318. private _hostElement;
  5319. /**
  5320. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5321. */
  5322. canUseWebAudio: boolean;
  5323. /**
  5324. * The master gain node defines the global audio volume of your audio engine.
  5325. */
  5326. masterGain: GainNode;
  5327. /**
  5328. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5329. * @ignoreNaming
  5330. */
  5331. WarnedWebAudioUnsupported: boolean;
  5332. /**
  5333. * Gets whether or not mp3 are supported by your browser.
  5334. */
  5335. isMP3supported: boolean;
  5336. /**
  5337. * Gets whether or not ogg are supported by your browser.
  5338. */
  5339. isOGGsupported: boolean;
  5340. /**
  5341. * Gets whether audio has been unlocked on the device.
  5342. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5343. * a user interaction has happened.
  5344. */
  5345. unlocked: boolean;
  5346. /**
  5347. * Defines if the audio engine relies on a custom unlocked button.
  5348. * In this case, the embedded button will not be displayed.
  5349. */
  5350. useCustomUnlockedButton: boolean;
  5351. /**
  5352. * Event raised when audio has been unlocked on the browser.
  5353. */
  5354. onAudioUnlockedObservable: Observable<AudioEngine>;
  5355. /**
  5356. * Event raised when audio has been locked on the browser.
  5357. */
  5358. onAudioLockedObservable: Observable<AudioEngine>;
  5359. /**
  5360. * Gets the current AudioContext if available.
  5361. */
  5362. readonly audioContext: Nullable<AudioContext>;
  5363. private _connectedAnalyser;
  5364. /**
  5365. * Instantiates a new audio engine.
  5366. *
  5367. * There should be only one per page as some browsers restrict the number
  5368. * of audio contexts you can create.
  5369. * @param hostElement defines the host element where to display the mute icon if necessary
  5370. */
  5371. constructor(hostElement?: Nullable<HTMLElement>);
  5372. /**
  5373. * Flags the audio engine in Locked state.
  5374. * This happens due to new browser policies preventing audio to autoplay.
  5375. */
  5376. lock(): void;
  5377. /**
  5378. * Unlocks the audio engine once a user action has been done on the dom.
  5379. * This is helpful to resume play once browser policies have been satisfied.
  5380. */
  5381. unlock(): void;
  5382. private _resumeAudioContext;
  5383. private _initializeAudioContext;
  5384. private _tryToRun;
  5385. private _triggerRunningState;
  5386. private _triggerSuspendedState;
  5387. private _displayMuteButton;
  5388. private _moveButtonToTopLeft;
  5389. private _onResize;
  5390. private _hideMuteButton;
  5391. /**
  5392. * Destroy and release the resources associated with the audio ccontext.
  5393. */
  5394. dispose(): void;
  5395. /**
  5396. * Gets the global volume sets on the master gain.
  5397. * @returns the global volume if set or -1 otherwise
  5398. */
  5399. getGlobalVolume(): number;
  5400. /**
  5401. * Sets the global volume of your experience (sets on the master gain).
  5402. * @param newVolume Defines the new global volume of the application
  5403. */
  5404. setGlobalVolume(newVolume: number): void;
  5405. /**
  5406. * Connect the audio engine to an audio analyser allowing some amazing
  5407. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5409. * @param analyser The analyser to connect to the engine
  5410. */
  5411. connectToAnalyser(analyser: Analyser): void;
  5412. }
  5413. }
  5414. declare module BABYLON {
  5415. interface AbstractScene {
  5416. /**
  5417. * The list of sounds used in the scene.
  5418. */
  5419. sounds: Nullable<Array<Sound>>;
  5420. }
  5421. interface Scene {
  5422. /**
  5423. * @hidden
  5424. * Backing field
  5425. */
  5426. _mainSoundTrack: SoundTrack;
  5427. /**
  5428. * The main sound track played by the scene.
  5429. * It cotains your primary collection of sounds.
  5430. */
  5431. mainSoundTrack: SoundTrack;
  5432. /**
  5433. * The list of sound tracks added to the scene
  5434. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5435. */
  5436. soundTracks: Nullable<Array<SoundTrack>>;
  5437. /**
  5438. * Gets a sound using a given name
  5439. * @param name defines the name to search for
  5440. * @return the found sound or null if not found at all.
  5441. */
  5442. getSoundByName(name: string): Nullable<Sound>;
  5443. /**
  5444. * Gets or sets if audio support is enabled
  5445. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5446. */
  5447. audioEnabled: boolean;
  5448. /**
  5449. * Gets or sets if audio will be output to headphones
  5450. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5451. */
  5452. headphone: boolean;
  5453. }
  5454. /**
  5455. * Defines the sound scene component responsible to manage any sounds
  5456. * in a given scene.
  5457. */
  5458. class AudioSceneComponent implements ISceneSerializableComponent {
  5459. /**
  5460. * The component name helpfull to identify the component in the list of scene components.
  5461. */
  5462. readonly name: string;
  5463. /**
  5464. * The scene the component belongs to.
  5465. */
  5466. scene: Scene;
  5467. private _audioEnabled;
  5468. /**
  5469. * Gets whether audio is enabled or not.
  5470. * Please use related enable/disable method to switch state.
  5471. */
  5472. readonly audioEnabled: boolean;
  5473. private _headphone;
  5474. /**
  5475. * Gets whether audio is outputing to headphone or not.
  5476. * Please use the according Switch methods to change output.
  5477. */
  5478. readonly headphone: boolean;
  5479. /**
  5480. * Creates a new instance of the component for the given scene
  5481. * @param scene Defines the scene to register the component in
  5482. */
  5483. constructor(scene: Scene);
  5484. /**
  5485. * Registers the component in a given scene
  5486. */
  5487. register(): void;
  5488. /**
  5489. * Rebuilds the elements related to this component in case of
  5490. * context lost for instance.
  5491. */
  5492. rebuild(): void;
  5493. /**
  5494. * Serializes the component data to the specified json object
  5495. * @param serializationObject The object to serialize to
  5496. */
  5497. serialize(serializationObject: any): void;
  5498. /**
  5499. * Adds all the element from the container to the scene
  5500. * @param container the container holding the elements
  5501. */
  5502. addFromContainer(container: AbstractScene): void;
  5503. /**
  5504. * Removes all the elements in the container from the scene
  5505. * @param container contains the elements to remove
  5506. */
  5507. removeFromContainer(container: AbstractScene): void;
  5508. /**
  5509. * Disposes the component and the associated ressources.
  5510. */
  5511. dispose(): void;
  5512. /**
  5513. * Disables audio in the associated scene.
  5514. */
  5515. disableAudio(): void;
  5516. /**
  5517. * Enables audio in the associated scene.
  5518. */
  5519. enableAudio(): void;
  5520. /**
  5521. * Switch audio to headphone output.
  5522. */
  5523. switchAudioModeForHeadphones(): void;
  5524. /**
  5525. * Switch audio to normal speakers.
  5526. */
  5527. switchAudioModeForNormalSpeakers(): void;
  5528. private _afterRender;
  5529. }
  5530. }
  5531. declare module BABYLON {
  5532. /**
  5533. * Defines a sound that can be played in the application.
  5534. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5535. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5536. */
  5537. class Sound {
  5538. /**
  5539. * The name of the sound in the scene.
  5540. */
  5541. name: string;
  5542. /**
  5543. * Does the sound autoplay once loaded.
  5544. */
  5545. autoplay: boolean;
  5546. /**
  5547. * Does the sound loop after it finishes playing once.
  5548. */
  5549. loop: boolean;
  5550. /**
  5551. * Does the sound use a custom attenuation curve to simulate the falloff
  5552. * happening when the source gets further away from the camera.
  5553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5554. */
  5555. useCustomAttenuation: boolean;
  5556. /**
  5557. * The sound track id this sound belongs to.
  5558. */
  5559. soundTrackId: number;
  5560. /**
  5561. * Is this sound currently played.
  5562. */
  5563. isPlaying: boolean;
  5564. /**
  5565. * Is this sound currently paused.
  5566. */
  5567. isPaused: boolean;
  5568. /**
  5569. * Does this sound enables spatial sound.
  5570. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5571. */
  5572. spatialSound: boolean;
  5573. /**
  5574. * Define the reference distance the sound should be heard perfectly.
  5575. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5576. */
  5577. refDistance: number;
  5578. /**
  5579. * Define the roll off factor of spatial sounds.
  5580. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5581. */
  5582. rolloffFactor: number;
  5583. /**
  5584. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5585. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5586. */
  5587. maxDistance: number;
  5588. /**
  5589. * Define the distance attenuation model the sound will follow.
  5590. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5591. */
  5592. distanceModel: string;
  5593. /**
  5594. * @hidden
  5595. * Back Compat
  5596. **/
  5597. onended: () => any;
  5598. /**
  5599. * Observable event when the current playing sound finishes.
  5600. */
  5601. onEndedObservable: Observable<Sound>;
  5602. private _panningModel;
  5603. private _playbackRate;
  5604. private _streaming;
  5605. private _startTime;
  5606. private _startOffset;
  5607. private _position;
  5608. /** @hidden */
  5609. _positionInEmitterSpace: boolean;
  5610. private _localDirection;
  5611. private _volume;
  5612. private _isReadyToPlay;
  5613. private _isDirectional;
  5614. private _readyToPlayCallback;
  5615. private _audioBuffer;
  5616. private _soundSource;
  5617. private _streamingSource;
  5618. private _soundPanner;
  5619. private _soundGain;
  5620. private _inputAudioNode;
  5621. private _outputAudioNode;
  5622. private _coneInnerAngle;
  5623. private _coneOuterAngle;
  5624. private _coneOuterGain;
  5625. private _scene;
  5626. private _connectedTransformNode;
  5627. private _customAttenuationFunction;
  5628. private _registerFunc;
  5629. private _isOutputConnected;
  5630. private _htmlAudioElement;
  5631. private _urlType;
  5632. /**
  5633. * Create a sound and attach it to a scene
  5634. * @param name Name of your sound
  5635. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5636. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5637. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5638. */
  5639. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5640. /**
  5641. * Release the sound and its associated resources
  5642. */
  5643. dispose(): void;
  5644. /**
  5645. * Gets if the sounds is ready to be played or not.
  5646. * @returns true if ready, otherwise false
  5647. */
  5648. isReady(): boolean;
  5649. private _soundLoaded;
  5650. /**
  5651. * Sets the data of the sound from an audiobuffer
  5652. * @param audioBuffer The audioBuffer containing the data
  5653. */
  5654. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5655. /**
  5656. * Updates the current sounds options such as maxdistance, loop...
  5657. * @param options A JSON object containing values named as the object properties
  5658. */
  5659. updateOptions(options: any): void;
  5660. private _createSpatialParameters;
  5661. private _updateSpatialParameters;
  5662. /**
  5663. * Switch the panning model to HRTF:
  5664. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5666. */
  5667. switchPanningModelToHRTF(): void;
  5668. /**
  5669. * Switch the panning model to Equal Power:
  5670. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5671. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5672. */
  5673. switchPanningModelToEqualPower(): void;
  5674. private _switchPanningModel;
  5675. /**
  5676. * Connect this sound to a sound track audio node like gain...
  5677. * @param soundTrackAudioNode the sound track audio node to connect to
  5678. */
  5679. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5680. /**
  5681. * Transform this sound into a directional source
  5682. * @param coneInnerAngle Size of the inner cone in degree
  5683. * @param coneOuterAngle Size of the outer cone in degree
  5684. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5685. */
  5686. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5687. /**
  5688. * Gets or sets the inner angle for the directional cone.
  5689. */
  5690. /**
  5691. * Gets or sets the inner angle for the directional cone.
  5692. */
  5693. directionalConeInnerAngle: number;
  5694. /**
  5695. * Gets or sets the outer angle for the directional cone.
  5696. */
  5697. /**
  5698. * Gets or sets the outer angle for the directional cone.
  5699. */
  5700. directionalConeOuterAngle: number;
  5701. /**
  5702. * Sets the position of the emitter if spatial sound is enabled
  5703. * @param newPosition Defines the new posisiton
  5704. */
  5705. setPosition(newPosition: Vector3): void;
  5706. /**
  5707. * Sets the local direction of the emitter if spatial sound is enabled
  5708. * @param newLocalDirection Defines the new local direction
  5709. */
  5710. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5711. private _updateDirection;
  5712. /** @hidden */
  5713. updateDistanceFromListener(): void;
  5714. /**
  5715. * Sets a new custom attenuation function for the sound.
  5716. * @param callback Defines the function used for the attenuation
  5717. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5718. */
  5719. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5720. /**
  5721. * Play the sound
  5722. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5723. * @param offset (optional) Start the sound setting it at a specific time
  5724. */
  5725. play(time?: number, offset?: number): void;
  5726. private _onended;
  5727. /**
  5728. * Stop the sound
  5729. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5730. */
  5731. stop(time?: number): void;
  5732. /**
  5733. * Put the sound in pause
  5734. */
  5735. pause(): void;
  5736. /**
  5737. * Sets a dedicated volume for this sounds
  5738. * @param newVolume Define the new volume of the sound
  5739. * @param time Define in how long the sound should be at this value
  5740. */
  5741. setVolume(newVolume: number, time?: number): void;
  5742. /**
  5743. * Set the sound play back rate
  5744. * @param newPlaybackRate Define the playback rate the sound should be played at
  5745. */
  5746. setPlaybackRate(newPlaybackRate: number): void;
  5747. /**
  5748. * Gets the volume of the sound.
  5749. * @returns the volume of the sound
  5750. */
  5751. getVolume(): number;
  5752. /**
  5753. * Attach the sound to a dedicated mesh
  5754. * @param transformNode The transform node to connect the sound with
  5755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5756. */
  5757. attachToMesh(transformNode: TransformNode): void;
  5758. /**
  5759. * Detach the sound from the previously attached mesh
  5760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5761. */
  5762. detachFromMesh(): void;
  5763. private _onRegisterAfterWorldMatrixUpdate;
  5764. /**
  5765. * Clone the current sound in the scene.
  5766. * @returns the new sound clone
  5767. */
  5768. clone(): Nullable<Sound>;
  5769. /**
  5770. * Gets the current underlying audio buffer containing the data
  5771. * @returns the audio buffer
  5772. */
  5773. getAudioBuffer(): Nullable<AudioBuffer>;
  5774. /**
  5775. * Serializes the Sound in a JSON representation
  5776. * @returns the JSON representation of the sound
  5777. */
  5778. serialize(): any;
  5779. /**
  5780. * Parse a JSON representation of a sound to innstantiate in a given scene
  5781. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5782. * @param scene Define the scene the new parsed sound should be created in
  5783. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5784. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5785. * @returns the newly parsed sound
  5786. */
  5787. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5788. }
  5789. }
  5790. declare module BABYLON {
  5791. /**
  5792. * Options allowed during the creation of a sound track.
  5793. */
  5794. interface ISoundTrackOptions {
  5795. /**
  5796. * The volume the sound track should take during creation
  5797. */
  5798. volume?: number;
  5799. /**
  5800. * Define if the sound track is the main sound track of the scene
  5801. */
  5802. mainTrack?: boolean;
  5803. }
  5804. /**
  5805. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5806. * It will be also used in a future release to apply effects on a specific track.
  5807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5808. */
  5809. class SoundTrack {
  5810. /**
  5811. * The unique identifier of the sound track in the scene.
  5812. */
  5813. id: number;
  5814. /**
  5815. * The list of sounds included in the sound track.
  5816. */
  5817. soundCollection: Array<Sound>;
  5818. private _outputAudioNode;
  5819. private _scene;
  5820. private _isMainTrack;
  5821. private _connectedAnalyser;
  5822. private _options;
  5823. private _isInitialized;
  5824. /**
  5825. * Creates a new sound track.
  5826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5827. * @param scene Define the scene the sound track belongs to
  5828. * @param options
  5829. */
  5830. constructor(scene: Scene, options?: ISoundTrackOptions);
  5831. private _initializeSoundTrackAudioGraph;
  5832. /**
  5833. * Release the sound track and its associated resources
  5834. */
  5835. dispose(): void;
  5836. /**
  5837. * Adds a sound to this sound track
  5838. * @param sound define the cound to add
  5839. * @ignoreNaming
  5840. */
  5841. AddSound(sound: Sound): void;
  5842. /**
  5843. * Removes a sound to this sound track
  5844. * @param sound define the cound to remove
  5845. * @ignoreNaming
  5846. */
  5847. RemoveSound(sound: Sound): void;
  5848. /**
  5849. * Set a global volume for the full sound track.
  5850. * @param newVolume Define the new volume of the sound track
  5851. */
  5852. setVolume(newVolume: number): void;
  5853. /**
  5854. * Switch the panning model to HRTF:
  5855. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5857. */
  5858. switchPanningModelToHRTF(): void;
  5859. /**
  5860. * Switch the panning model to Equal Power:
  5861. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5863. */
  5864. switchPanningModelToEqualPower(): void;
  5865. /**
  5866. * Connect the sound track to an audio analyser allowing some amazing
  5867. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5869. * @param analyser The analyser to connect to the engine
  5870. */
  5871. connectToAnalyser(analyser: Analyser): void;
  5872. }
  5873. }
  5874. declare module BABYLON {
  5875. /**
  5876. * Wraps one or more Sound objects and selects one with random weight for playback.
  5877. */
  5878. class WeightedSound {
  5879. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5880. loop: boolean;
  5881. private _coneInnerAngle;
  5882. private _coneOuterAngle;
  5883. private _volume;
  5884. /** A Sound is currently playing. */
  5885. isPlaying: boolean;
  5886. /** A Sound is currently paused. */
  5887. isPaused: boolean;
  5888. private _sounds;
  5889. private _weights;
  5890. private _currentIndex?;
  5891. /**
  5892. * Creates a new WeightedSound from the list of sounds given.
  5893. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5894. * @param sounds Array of Sounds that will be selected from.
  5895. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5896. */
  5897. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5898. /**
  5899. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5900. */
  5901. /**
  5902. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5903. */
  5904. directionalConeInnerAngle: number;
  5905. /**
  5906. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5907. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5908. */
  5909. /**
  5910. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5911. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5912. */
  5913. directionalConeOuterAngle: number;
  5914. /**
  5915. * Playback volume.
  5916. */
  5917. /**
  5918. * Playback volume.
  5919. */
  5920. volume: number;
  5921. private _onended;
  5922. /**
  5923. * Suspend playback
  5924. */
  5925. pause(): void;
  5926. /**
  5927. * Stop playback
  5928. */
  5929. stop(): void;
  5930. /**
  5931. * Start playback.
  5932. * @param startOffset Position the clip head at a specific time in seconds.
  5933. */
  5934. play(startOffset?: number): void;
  5935. }
  5936. }
  5937. declare module BABYLON {
  5938. /**
  5939. * Interface used to define a behavior
  5940. */
  5941. interface Behavior<T> {
  5942. /** gets or sets behavior's name */
  5943. name: string;
  5944. /**
  5945. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5946. */
  5947. init(): void;
  5948. /**
  5949. * Called when the behavior is attached to a target
  5950. * @param target defines the target where the behavior is attached to
  5951. */
  5952. attach(target: T): void;
  5953. /**
  5954. * Called when the behavior is detached from its target
  5955. */
  5956. detach(): void;
  5957. }
  5958. /**
  5959. * Interface implemented by classes supporting behaviors
  5960. */
  5961. interface IBehaviorAware<T> {
  5962. /**
  5963. * Attach a behavior
  5964. * @param behavior defines the behavior to attach
  5965. * @returns the current host
  5966. */
  5967. addBehavior(behavior: Behavior<T>): T;
  5968. /**
  5969. * Remove a behavior from the current object
  5970. * @param behavior defines the behavior to detach
  5971. * @returns the current host
  5972. */
  5973. removeBehavior(behavior: Behavior<T>): T;
  5974. /**
  5975. * Gets a behavior using its name to search
  5976. * @param name defines the name to search
  5977. * @returns the behavior or null if not found
  5978. */
  5979. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5980. }
  5981. }
  5982. declare module BABYLON {
  5983. /**
  5984. * Class used to store bone information
  5985. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5986. */
  5987. class Bone extends Node {
  5988. /**
  5989. * defines the bone name
  5990. */
  5991. name: string;
  5992. private static _tmpVecs;
  5993. private static _tmpQuat;
  5994. private static _tmpMats;
  5995. /**
  5996. * Gets the list of child bones
  5997. */
  5998. children: Bone[];
  5999. /** Gets the animations associated with this bone */
  6000. animations: Animation[];
  6001. /**
  6002. * Gets or sets bone length
  6003. */
  6004. length: number;
  6005. /**
  6006. * @hidden Internal only
  6007. * Set this value to map this bone to a different index in the transform matrices
  6008. * Set this value to -1 to exclude the bone from the transform matrices
  6009. */
  6010. _index: Nullable<number>;
  6011. private _skeleton;
  6012. private _localMatrix;
  6013. private _restPose;
  6014. private _baseMatrix;
  6015. private _absoluteTransform;
  6016. private _invertedAbsoluteTransform;
  6017. private _parent;
  6018. private _scalingDeterminant;
  6019. private _worldTransform;
  6020. private _localScaling;
  6021. private _localRotation;
  6022. private _localPosition;
  6023. private _needToDecompose;
  6024. private _needToCompose;
  6025. /** @hidden */
  6026. /** @hidden */
  6027. _matrix: Matrix;
  6028. /**
  6029. * Create a new bone
  6030. * @param name defines the bone name
  6031. * @param skeleton defines the parent skeleton
  6032. * @param parentBone defines the parent (can be null if the bone is the root)
  6033. * @param localMatrix defines the local matrix
  6034. * @param restPose defines the rest pose matrix
  6035. * @param baseMatrix defines the base matrix
  6036. * @param index defines index of the bone in the hiearchy
  6037. */
  6038. constructor(
  6039. /**
  6040. * defines the bone name
  6041. */
  6042. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  6043. /**
  6044. * Gets the parent skeleton
  6045. * @returns a skeleton
  6046. */
  6047. getSkeleton(): Skeleton;
  6048. /**
  6049. * Gets parent bone
  6050. * @returns a bone or null if the bone is the root of the bone hierarchy
  6051. */
  6052. getParent(): Nullable<Bone>;
  6053. /**
  6054. * Sets the parent bone
  6055. * @param parent defines the parent (can be null if the bone is the root)
  6056. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6057. */
  6058. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  6059. /**
  6060. * Gets the local matrix
  6061. * @returns a matrix
  6062. */
  6063. getLocalMatrix(): Matrix;
  6064. /**
  6065. * Gets the base matrix (initial matrix which remains unchanged)
  6066. * @returns a matrix
  6067. */
  6068. getBaseMatrix(): Matrix;
  6069. /**
  6070. * Gets the rest pose matrix
  6071. * @returns a matrix
  6072. */
  6073. getRestPose(): Matrix;
  6074. /**
  6075. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  6076. */
  6077. getWorldMatrix(): Matrix;
  6078. /**
  6079. * Sets the local matrix to rest pose matrix
  6080. */
  6081. returnToRest(): void;
  6082. /**
  6083. * Gets the inverse of the absolute transform matrix.
  6084. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  6085. * @returns a matrix
  6086. */
  6087. getInvertedAbsoluteTransform(): Matrix;
  6088. /**
  6089. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  6090. * @returns a matrix
  6091. */
  6092. getAbsoluteTransform(): Matrix;
  6093. /** Gets or sets current position (in local space) */
  6094. position: Vector3;
  6095. /** Gets or sets current rotation (in local space) */
  6096. rotation: Vector3;
  6097. /** Gets or sets current rotation quaternion (in local space) */
  6098. rotationQuaternion: Quaternion;
  6099. /** Gets or sets current scaling (in local space) */
  6100. scaling: Vector3;
  6101. /**
  6102. * Gets the animation properties override
  6103. */
  6104. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6105. private _decompose;
  6106. private _compose;
  6107. /**
  6108. * Update the base and local matrices
  6109. * @param matrix defines the new base or local matrix
  6110. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6111. * @param updateLocalMatrix defines if the local matrix should be updated
  6112. */
  6113. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6114. /** @hidden */
  6115. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6116. /**
  6117. * Flag the bone as dirty (Forcing it to update everything)
  6118. */
  6119. markAsDirty(): void;
  6120. private _markAsDirtyAndCompose;
  6121. private _markAsDirtyAndDecompose;
  6122. /**
  6123. * Copy an animation range from another bone
  6124. * @param source defines the source bone
  6125. * @param rangeName defines the range name to copy
  6126. * @param frameOffset defines the frame offset
  6127. * @param rescaleAsRequired defines if rescaling must be applied if required
  6128. * @param skelDimensionsRatio defines the scaling ratio
  6129. * @returns true if operation was successful
  6130. */
  6131. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6132. /**
  6133. * Translate the bone in local or world space
  6134. * @param vec The amount to translate the bone
  6135. * @param space The space that the translation is in
  6136. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6137. */
  6138. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6139. /**
  6140. * Set the postion of the bone in local or world space
  6141. * @param position The position to set the bone
  6142. * @param space The space that the position is in
  6143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6144. */
  6145. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6146. /**
  6147. * Set the absolute position of the bone (world space)
  6148. * @param position The position to set the bone
  6149. * @param mesh The mesh that this bone is attached to
  6150. */
  6151. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6152. /**
  6153. * Scale the bone on the x, y and z axes (in local space)
  6154. * @param x The amount to scale the bone on the x axis
  6155. * @param y The amount to scale the bone on the y axis
  6156. * @param z The amount to scale the bone on the z axis
  6157. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6158. */
  6159. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6160. /**
  6161. * Set the bone scaling in local space
  6162. * @param scale defines the scaling vector
  6163. */
  6164. setScale(scale: Vector3): void;
  6165. /**
  6166. * Gets the current scaling in local space
  6167. * @returns the current scaling vector
  6168. */
  6169. getScale(): Vector3;
  6170. /**
  6171. * Gets the current scaling in local space and stores it in a target vector
  6172. * @param result defines the target vector
  6173. */
  6174. getScaleToRef(result: Vector3): void;
  6175. /**
  6176. * Set the yaw, pitch, and roll of the bone in local or world space
  6177. * @param yaw The rotation of the bone on the y axis
  6178. * @param pitch The rotation of the bone on the x axis
  6179. * @param roll The rotation of the bone on the z axis
  6180. * @param space The space that the axes of rotation are in
  6181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6182. */
  6183. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6184. /**
  6185. * Add a rotation to the bone on an axis in local or world space
  6186. * @param axis The axis to rotate the bone on
  6187. * @param amount The amount to rotate the bone
  6188. * @param space The space that the axis is in
  6189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6190. */
  6191. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6192. /**
  6193. * Set the rotation of the bone to a particular axis angle in local or world space
  6194. * @param axis The axis to rotate the bone on
  6195. * @param angle The angle that the bone should be rotated to
  6196. * @param space The space that the axis is in
  6197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6198. */
  6199. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6200. /**
  6201. * Set the euler rotation of the bone in local of world space
  6202. * @param rotation The euler rotation that the bone should be set to
  6203. * @param space The space that the rotation is in
  6204. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6205. */
  6206. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6207. /**
  6208. * Set the quaternion rotation of the bone in local of world space
  6209. * @param quat The quaternion rotation that the bone should be set to
  6210. * @param space The space that the rotation is in
  6211. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6212. */
  6213. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6214. /**
  6215. * Set the rotation matrix of the bone in local of world space
  6216. * @param rotMat The rotation matrix that the bone should be set to
  6217. * @param space The space that the rotation is in
  6218. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6219. */
  6220. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6221. private _rotateWithMatrix;
  6222. private _getNegativeRotationToRef;
  6223. /**
  6224. * Get the position of the bone in local or world space
  6225. * @param space The space that the returned position is in
  6226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6227. * @returns The position of the bone
  6228. */
  6229. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6230. /**
  6231. * Copy the position of the bone to a vector3 in local or world space
  6232. * @param space The space that the returned position is in
  6233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6234. * @param result The vector3 to copy the position to
  6235. */
  6236. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6237. /**
  6238. * Get the absolute position of the bone (world space)
  6239. * @param mesh The mesh that this bone is attached to
  6240. * @returns The absolute position of the bone
  6241. */
  6242. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6243. /**
  6244. * Copy the absolute position of the bone (world space) to the result param
  6245. * @param mesh The mesh that this bone is attached to
  6246. * @param result The vector3 to copy the absolute position to
  6247. */
  6248. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6249. /**
  6250. * Compute the absolute transforms of this bone and its children
  6251. */
  6252. computeAbsoluteTransforms(): void;
  6253. /**
  6254. * Get the world direction from an axis that is in the local space of the bone
  6255. * @param localAxis The local direction that is used to compute the world direction
  6256. * @param mesh The mesh that this bone is attached to
  6257. * @returns The world direction
  6258. */
  6259. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6260. /**
  6261. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6262. * @param localAxis The local direction that is used to compute the world direction
  6263. * @param mesh The mesh that this bone is attached to
  6264. * @param result The vector3 that the world direction will be copied to
  6265. */
  6266. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6267. /**
  6268. * Get the euler rotation of the bone in local or world space
  6269. * @param space The space that the rotation should be in
  6270. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6271. * @returns The euler rotation
  6272. */
  6273. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6274. /**
  6275. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6276. * @param space The space that the rotation should be in
  6277. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6278. * @param result The vector3 that the rotation should be copied to
  6279. */
  6280. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6281. /**
  6282. * Get the quaternion rotation of the bone in either local or world space
  6283. * @param space The space that the rotation should be in
  6284. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6285. * @returns The quaternion rotation
  6286. */
  6287. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6288. /**
  6289. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6290. * @param space The space that the rotation should be in
  6291. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6292. * @param result The quaternion that the rotation should be copied to
  6293. */
  6294. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6295. /**
  6296. * Get the rotation matrix of the bone in local or world space
  6297. * @param space The space that the rotation should be in
  6298. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6299. * @returns The rotation matrix
  6300. */
  6301. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6302. /**
  6303. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6304. * @param space The space that the rotation should be in
  6305. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6306. * @param result The quaternion that the rotation should be copied to
  6307. */
  6308. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6309. /**
  6310. * Get the world position of a point that is in the local space of the bone
  6311. * @param position The local position
  6312. * @param mesh The mesh that this bone is attached to
  6313. * @returns The world position
  6314. */
  6315. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6316. /**
  6317. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6318. * @param position The local position
  6319. * @param mesh The mesh that this bone is attached to
  6320. * @param result The vector3 that the world position should be copied to
  6321. */
  6322. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6323. /**
  6324. * Get the local position of a point that is in world space
  6325. * @param position The world position
  6326. * @param mesh The mesh that this bone is attached to
  6327. * @returns The local position
  6328. */
  6329. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6330. /**
  6331. * Get the local position of a point that is in world space and copy it to the result param
  6332. * @param position The world position
  6333. * @param mesh The mesh that this bone is attached to
  6334. * @param result The vector3 that the local position should be copied to
  6335. */
  6336. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6337. }
  6338. }
  6339. declare module BABYLON {
  6340. /**
  6341. * Class used to apply inverse kinematics to bones
  6342. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6343. */
  6344. class BoneIKController {
  6345. private static _tmpVecs;
  6346. private static _tmpQuat;
  6347. private static _tmpMats;
  6348. /**
  6349. * Gets or sets the target mesh
  6350. */
  6351. targetMesh: AbstractMesh;
  6352. /** Gets or sets the mesh used as pole */
  6353. poleTargetMesh: AbstractMesh;
  6354. /**
  6355. * Gets or sets the bone used as pole
  6356. */
  6357. poleTargetBone: Nullable<Bone>;
  6358. /**
  6359. * Gets or sets the target position
  6360. */
  6361. targetPosition: Vector3;
  6362. /**
  6363. * Gets or sets the pole target position
  6364. */
  6365. poleTargetPosition: Vector3;
  6366. /**
  6367. * Gets or sets the pole target local offset
  6368. */
  6369. poleTargetLocalOffset: Vector3;
  6370. /**
  6371. * Gets or sets the pole angle
  6372. */
  6373. poleAngle: number;
  6374. /**
  6375. * Gets or sets the mesh associated with the controller
  6376. */
  6377. mesh: AbstractMesh;
  6378. /**
  6379. * 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)
  6380. */
  6381. slerpAmount: number;
  6382. private _bone1Quat;
  6383. private _bone1Mat;
  6384. private _bone2Ang;
  6385. private _bone1;
  6386. private _bone2;
  6387. private _bone1Length;
  6388. private _bone2Length;
  6389. private _maxAngle;
  6390. private _maxReach;
  6391. private _rightHandedSystem;
  6392. private _bendAxis;
  6393. private _slerping;
  6394. private _adjustRoll;
  6395. /**
  6396. * Gets or sets maximum allowed angle
  6397. */
  6398. maxAngle: number;
  6399. /**
  6400. * Creates a new BoneIKController
  6401. * @param mesh defines the mesh to control
  6402. * @param bone defines the bone to control
  6403. * @param options defines options to set up the controller
  6404. */
  6405. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6406. targetMesh?: AbstractMesh;
  6407. poleTargetMesh?: AbstractMesh;
  6408. poleTargetBone?: Bone;
  6409. poleTargetLocalOffset?: Vector3;
  6410. poleAngle?: number;
  6411. bendAxis?: Vector3;
  6412. maxAngle?: number;
  6413. slerpAmount?: number;
  6414. });
  6415. private _setMaxAngle;
  6416. /**
  6417. * Force the controller to update the bones
  6418. */
  6419. update(): void;
  6420. }
  6421. }
  6422. declare module BABYLON {
  6423. /**
  6424. * Class used to make a bone look toward a point in space
  6425. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6426. */
  6427. class BoneLookController {
  6428. private static _tmpVecs;
  6429. private static _tmpQuat;
  6430. private static _tmpMats;
  6431. /**
  6432. * The target Vector3 that the bone will look at
  6433. */
  6434. target: Vector3;
  6435. /**
  6436. * The mesh that the bone is attached to
  6437. */
  6438. mesh: AbstractMesh;
  6439. /**
  6440. * The bone that will be looking to the target
  6441. */
  6442. bone: Bone;
  6443. /**
  6444. * The up axis of the coordinate system that is used when the bone is rotated
  6445. */
  6446. upAxis: Vector3;
  6447. /**
  6448. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6449. */
  6450. upAxisSpace: Space;
  6451. /**
  6452. * Used to make an adjustment to the yaw of the bone
  6453. */
  6454. adjustYaw: number;
  6455. /**
  6456. * Used to make an adjustment to the pitch of the bone
  6457. */
  6458. adjustPitch: number;
  6459. /**
  6460. * Used to make an adjustment to the roll of the bone
  6461. */
  6462. adjustRoll: number;
  6463. /**
  6464. * 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)
  6465. */
  6466. slerpAmount: number;
  6467. private _minYaw;
  6468. private _maxYaw;
  6469. private _minPitch;
  6470. private _maxPitch;
  6471. private _minYawSin;
  6472. private _minYawCos;
  6473. private _maxYawSin;
  6474. private _maxYawCos;
  6475. private _midYawConstraint;
  6476. private _minPitchTan;
  6477. private _maxPitchTan;
  6478. private _boneQuat;
  6479. private _slerping;
  6480. private _transformYawPitch;
  6481. private _transformYawPitchInv;
  6482. private _firstFrameSkipped;
  6483. private _yawRange;
  6484. private _fowardAxis;
  6485. /**
  6486. * Gets or sets the minimum yaw angle that the bone can look to
  6487. */
  6488. minYaw: number;
  6489. /**
  6490. * Gets or sets the maximum yaw angle that the bone can look to
  6491. */
  6492. maxYaw: number;
  6493. /**
  6494. * Gets or sets the minimum pitch angle that the bone can look to
  6495. */
  6496. minPitch: number;
  6497. /**
  6498. * Gets or sets the maximum pitch angle that the bone can look to
  6499. */
  6500. maxPitch: number;
  6501. /**
  6502. * Create a BoneLookController
  6503. * @param mesh the mesh that the bone belongs to
  6504. * @param bone the bone that will be looking to the target
  6505. * @param target the target Vector3 to look at
  6506. * @param settings optional settings:
  6507. * * maxYaw: the maximum angle the bone will yaw to
  6508. * * minYaw: the minimum angle the bone will yaw to
  6509. * * maxPitch: the maximum angle the bone will pitch to
  6510. * * minPitch: the minimum angle the bone will yaw to
  6511. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6512. * * upAxis: the up axis of the coordinate system
  6513. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6514. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6515. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6516. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6517. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6518. * * adjustRoll: used to make an adjustment to the roll of the bone
  6519. **/
  6520. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6521. maxYaw?: number;
  6522. minYaw?: number;
  6523. maxPitch?: number;
  6524. minPitch?: number;
  6525. slerpAmount?: number;
  6526. upAxis?: Vector3;
  6527. upAxisSpace?: Space;
  6528. yawAxis?: Vector3;
  6529. pitchAxis?: Vector3;
  6530. adjustYaw?: number;
  6531. adjustPitch?: number;
  6532. adjustRoll?: number;
  6533. });
  6534. /**
  6535. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6536. */
  6537. update(): void;
  6538. private _getAngleDiff;
  6539. private _getAngleBetween;
  6540. private _isAngleBetween;
  6541. }
  6542. }
  6543. declare module BABYLON {
  6544. /**
  6545. * Class used to handle skinning animations
  6546. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6547. */
  6548. class Skeleton implements IAnimatable {
  6549. /** defines the skeleton name */
  6550. name: string;
  6551. /** defines the skeleton Id */
  6552. id: string;
  6553. /**
  6554. * Gets the list of child bones
  6555. */
  6556. bones: Bone[];
  6557. /**
  6558. * Gets an estimate of the dimension of the skeleton at rest
  6559. */
  6560. dimensionsAtRest: Vector3;
  6561. /**
  6562. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6563. */
  6564. needInitialSkinMatrix: boolean;
  6565. /**
  6566. * Gets the list of animations attached to this skeleton
  6567. */
  6568. animations: Array<Animation>;
  6569. private _scene;
  6570. private _isDirty;
  6571. private _transformMatrices;
  6572. private _transformMatrixTexture;
  6573. private _meshesWithPoseMatrix;
  6574. private _animatables;
  6575. private _identity;
  6576. private _synchronizedWithMesh;
  6577. private _ranges;
  6578. private _lastAbsoluteTransformsUpdateId;
  6579. private _canUseTextureForBones;
  6580. /**
  6581. * Specifies if the skeleton should be serialized
  6582. */
  6583. doNotSerialize: boolean;
  6584. /**
  6585. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  6586. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  6587. */
  6588. useTextureToStoreBoneMatrices: boolean;
  6589. private _animationPropertiesOverride;
  6590. /**
  6591. * Gets or sets the animation properties override
  6592. */
  6593. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6594. /**
  6595. * An observable triggered before computing the skeleton's matrices
  6596. */
  6597. onBeforeComputeObservable: Observable<Skeleton>;
  6598. /**
  6599. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  6600. */
  6601. readonly isUsingTextureForMatrices: boolean;
  6602. /**
  6603. * Creates a new skeleton
  6604. * @param name defines the skeleton name
  6605. * @param id defines the skeleton Id
  6606. * @param scene defines the hosting scene
  6607. */
  6608. constructor(
  6609. /** defines the skeleton name */
  6610. name: string,
  6611. /** defines the skeleton Id */
  6612. id: string, scene: Scene);
  6613. /**
  6614. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6615. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6616. * @returns a Float32Array containing matrices data
  6617. */
  6618. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6619. /**
  6620. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  6621. * @returns a raw texture containing the data
  6622. */
  6623. getTransformMatrixTexture(): Nullable<RawTexture>;
  6624. /**
  6625. * Gets the current hosting scene
  6626. * @returns a scene object
  6627. */
  6628. getScene(): Scene;
  6629. /**
  6630. * Gets a string representing the current skeleton data
  6631. * @param fullDetails defines a boolean indicating if we want a verbose version
  6632. * @returns a string representing the current skeleton data
  6633. */
  6634. toString(fullDetails?: boolean): string;
  6635. /**
  6636. * Get bone's index searching by name
  6637. * @param name defines bone's name to search for
  6638. * @return the indice of the bone. Returns -1 if not found
  6639. */
  6640. getBoneIndexByName(name: string): number;
  6641. /**
  6642. * Creater a new animation range
  6643. * @param name defines the name of the range
  6644. * @param from defines the start key
  6645. * @param to defines the end key
  6646. */
  6647. createAnimationRange(name: string, from: number, to: number): void;
  6648. /**
  6649. * Delete a specific animation range
  6650. * @param name defines the name of the range
  6651. * @param deleteFrames defines if frames must be removed as well
  6652. */
  6653. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6654. /**
  6655. * Gets a specific animation range
  6656. * @param name defines the name of the range to look for
  6657. * @returns the requested animation range or null if not found
  6658. */
  6659. getAnimationRange(name: string): Nullable<AnimationRange>;
  6660. /**
  6661. * Gets the list of all animation ranges defined on this skeleton
  6662. * @returns an array
  6663. */
  6664. getAnimationRanges(): Nullable<AnimationRange>[];
  6665. /**
  6666. * Copy animation range from a source skeleton.
  6667. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6668. * @param source defines the source skeleton
  6669. * @param name defines the name of the range to copy
  6670. * @param rescaleAsRequired defines if rescaling must be applied if required
  6671. * @returns true if operation was successful
  6672. */
  6673. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6674. /**
  6675. * Forces the skeleton to go to rest pose
  6676. */
  6677. returnToRest(): void;
  6678. private _getHighestAnimationFrame;
  6679. /**
  6680. * Begin a specific animation range
  6681. * @param name defines the name of the range to start
  6682. * @param loop defines if looping must be turned on (false by default)
  6683. * @param speedRatio defines the speed ratio to apply (1 by default)
  6684. * @param onAnimationEnd defines a callback which will be called when animation will end
  6685. * @returns a new animatable
  6686. */
  6687. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6688. /** @hidden */
  6689. _markAsDirty(): void;
  6690. /** @hidden */
  6691. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6692. /** @hidden */
  6693. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6694. private _computeTransformMatrices;
  6695. /**
  6696. * Build all resources required to render a skeleton
  6697. */
  6698. prepare(): void;
  6699. /**
  6700. * Gets the list of animatables currently running for this skeleton
  6701. * @returns an array of animatables
  6702. */
  6703. getAnimatables(): IAnimatable[];
  6704. /**
  6705. * Clone the current skeleton
  6706. * @param name defines the name of the new skeleton
  6707. * @param id defines the id of the enw skeleton
  6708. * @returns the new skeleton
  6709. */
  6710. clone(name: string, id: string): Skeleton;
  6711. /**
  6712. * Enable animation blending for this skeleton
  6713. * @param blendingSpeed defines the blending speed to apply
  6714. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6715. */
  6716. enableBlending(blendingSpeed?: number): void;
  6717. /**
  6718. * Releases all resources associated with the current skeleton
  6719. */
  6720. dispose(): void;
  6721. /**
  6722. * Serialize the skeleton in a JSON object
  6723. * @returns a JSON object
  6724. */
  6725. serialize(): any;
  6726. /**
  6727. * Creates a new skeleton from serialized data
  6728. * @param parsedSkeleton defines the serialized data
  6729. * @param scene defines the hosting scene
  6730. * @returns a new skeleton
  6731. */
  6732. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6733. /**
  6734. * Compute all node absolute transforms
  6735. * @param forceUpdate defines if computation must be done even if cache is up to date
  6736. */
  6737. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6738. /**
  6739. * Gets the root pose matrix
  6740. * @returns a matrix
  6741. */
  6742. getPoseMatrix(): Nullable<Matrix>;
  6743. /**
  6744. * Sorts bones per internal index
  6745. */
  6746. sortBones(): void;
  6747. private _sortBones;
  6748. }
  6749. }
  6750. declare module BABYLON {
  6751. /**
  6752. * This represents an orbital type of camera.
  6753. *
  6754. * 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.
  6755. * 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.
  6756. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  6757. */
  6758. class ArcRotateCamera extends TargetCamera {
  6759. /**
  6760. * Defines the rotation angle of the camera along the longitudinal axis.
  6761. */
  6762. alpha: number;
  6763. /**
  6764. * Defines the rotation angle of the camera along the latitudinal axis.
  6765. */
  6766. beta: number;
  6767. /**
  6768. * Defines the radius of the camera from it s target point.
  6769. */
  6770. radius: number;
  6771. protected _target: Vector3;
  6772. protected _targetHost: Nullable<AbstractMesh>;
  6773. /**
  6774. * Defines the target point of the camera.
  6775. * The camera looks towards it form the radius distance.
  6776. */
  6777. target: Vector3;
  6778. /**
  6779. * Current inertia value on the longitudinal axis.
  6780. * The bigger this number the longer it will take for the camera to stop.
  6781. */
  6782. inertialAlphaOffset: number;
  6783. /**
  6784. * Current inertia value on the latitudinal axis.
  6785. * The bigger this number the longer it will take for the camera to stop.
  6786. */
  6787. inertialBetaOffset: number;
  6788. /**
  6789. * Current inertia value on the radius axis.
  6790. * The bigger this number the longer it will take for the camera to stop.
  6791. */
  6792. inertialRadiusOffset: number;
  6793. /**
  6794. * Minimum allowed angle on the longitudinal axis.
  6795. * This can help limiting how the Camera is able to move in the scene.
  6796. */
  6797. lowerAlphaLimit: Nullable<number>;
  6798. /**
  6799. * Maximum allowed angle on the longitudinal axis.
  6800. * This can help limiting how the Camera is able to move in the scene.
  6801. */
  6802. upperAlphaLimit: Nullable<number>;
  6803. /**
  6804. * Minimum allowed angle on the latitudinal axis.
  6805. * This can help limiting how the Camera is able to move in the scene.
  6806. */
  6807. lowerBetaLimit: number;
  6808. /**
  6809. * Maximum allowed angle on the latitudinal axis.
  6810. * This can help limiting how the Camera is able to move in the scene.
  6811. */
  6812. upperBetaLimit: number;
  6813. /**
  6814. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  6815. * This can help limiting how the Camera is able to move in the scene.
  6816. */
  6817. lowerRadiusLimit: Nullable<number>;
  6818. /**
  6819. * Maximum allowed distance of the camera to the target (The camera can not get further).
  6820. * This can help limiting how the Camera is able to move in the scene.
  6821. */
  6822. upperRadiusLimit: Nullable<number>;
  6823. /**
  6824. * Defines the current inertia value used during panning of the camera along the X axis.
  6825. */
  6826. inertialPanningX: number;
  6827. /**
  6828. * Defines the current inertia value used during panning of the camera along the Y axis.
  6829. */
  6830. inertialPanningY: number;
  6831. /**
  6832. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  6833. * Basically if your fingers moves away from more than this distance you will be considered
  6834. * in pinch mode.
  6835. */
  6836. pinchToPanMaxDistance: number;
  6837. /**
  6838. * Defines the maximum distance the camera can pan.
  6839. * This could help keeping the cammera always in your scene.
  6840. */
  6841. panningDistanceLimit: Nullable<number>;
  6842. /**
  6843. * Defines the target of the camera before paning.
  6844. */
  6845. panningOriginTarget: Vector3;
  6846. /**
  6847. * Defines the value of the inertia used during panning.
  6848. * 0 would mean stop inertia and one would mean no decelleration at all.
  6849. */
  6850. panningInertia: number;
  6851. /**
  6852. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  6853. */
  6854. angularSensibilityX: number;
  6855. /**
  6856. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  6857. */
  6858. angularSensibilityY: number;
  6859. /**
  6860. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  6861. */
  6862. pinchPrecision: number;
  6863. /**
  6864. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  6865. * It will be used instead of pinchDeltaPrecision if different from 0.
  6866. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  6867. */
  6868. pinchDeltaPercentage: number;
  6869. /**
  6870. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  6871. */
  6872. panningSensibility: number;
  6873. /**
  6874. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  6875. */
  6876. keysUp: number[];
  6877. /**
  6878. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  6879. */
  6880. keysDown: number[];
  6881. /**
  6882. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  6883. */
  6884. keysLeft: number[];
  6885. /**
  6886. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  6887. */
  6888. keysRight: number[];
  6889. /**
  6890. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  6891. */
  6892. wheelPrecision: number;
  6893. /**
  6894. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  6895. * It will be used instead of pinchDeltaPrecision if different from 0.
  6896. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  6897. */
  6898. wheelDeltaPercentage: number;
  6899. /**
  6900. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  6901. */
  6902. zoomOnFactor: number;
  6903. /**
  6904. * Defines a screen offset for the camera position.
  6905. */
  6906. targetScreenOffset: Vector2;
  6907. /**
  6908. * Allows the camera to be completely reversed.
  6909. * If false the camera can not arrive upside down.
  6910. */
  6911. allowUpsideDown: boolean;
  6912. /**
  6913. * Define if double tap/click is used to restore the previously saved state of the camera.
  6914. */
  6915. useInputToRestoreState: boolean;
  6916. /** @hidden */
  6917. _viewMatrix: Matrix;
  6918. /** @hidden */
  6919. _useCtrlForPanning: boolean;
  6920. /** @hidden */
  6921. _panningMouseButton: number;
  6922. /**
  6923. * Defines the inpute associated to the camera.
  6924. */
  6925. inputs: ArcRotateCameraInputsManager;
  6926. /** @hidden */
  6927. _reset: () => void;
  6928. /**
  6929. * Defines the allowed panning axis.
  6930. */
  6931. panningAxis: Vector3;
  6932. protected _localDirection: Vector3;
  6933. protected _transformedDirection: Vector3;
  6934. private _bouncingBehavior;
  6935. /**
  6936. * Gets the bouncing behavior of the camera if it has been enabled.
  6937. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  6938. */
  6939. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  6940. /**
  6941. * Defines if the bouncing behavior of the camera is enabled on the camera.
  6942. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  6943. */
  6944. useBouncingBehavior: boolean;
  6945. private _framingBehavior;
  6946. /**
  6947. * Gets the framing behavior of the camera if it has been enabled.
  6948. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  6949. */
  6950. readonly framingBehavior: Nullable<FramingBehavior>;
  6951. /**
  6952. * Defines if the framing behavior of the camera is enabled on the camera.
  6953. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  6954. */
  6955. useFramingBehavior: boolean;
  6956. private _autoRotationBehavior;
  6957. /**
  6958. * Gets the auto rotation behavior of the camera if it has been enabled.
  6959. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  6960. */
  6961. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  6962. /**
  6963. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  6964. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  6965. */
  6966. useAutoRotationBehavior: boolean;
  6967. /**
  6968. * Observable triggered when the mesh target has been changed on the camera.
  6969. */
  6970. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  6971. /**
  6972. * Event raised when the camera is colliding with a mesh.
  6973. */
  6974. onCollide: (collidedMesh: AbstractMesh) => void;
  6975. /**
  6976. * Defines whether the camera should check collision with the objects oh the scene.
  6977. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  6978. */
  6979. checkCollisions: boolean;
  6980. /**
  6981. * Defines the collision radius of the camera.
  6982. * This simulates a sphere around the camera.
  6983. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  6984. */
  6985. collisionRadius: Vector3;
  6986. protected _collider: Collider;
  6987. protected _previousPosition: Vector3;
  6988. protected _collisionVelocity: Vector3;
  6989. protected _newPosition: Vector3;
  6990. protected _previousAlpha: number;
  6991. protected _previousBeta: number;
  6992. protected _previousRadius: number;
  6993. protected _collisionTriggered: boolean;
  6994. protected _targetBoundingCenter: Nullable<Vector3>;
  6995. private _computationVector;
  6996. /**
  6997. * Instantiates a new ArcRotateCamera in a given scene
  6998. * @param name Defines the name of the camera
  6999. * @param alpha Defines the camera rotation along the logitudinal axis
  7000. * @param beta Defines the camera rotation along the latitudinal axis
  7001. * @param radius Defines the camera distance from its target
  7002. * @param target Defines the camera target
  7003. * @param scene Defines the scene the camera belongs to
  7004. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7005. */
  7006. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7007. /** @hidden */
  7008. _initCache(): void;
  7009. /** @hidden */
  7010. _updateCache(ignoreParentClass?: boolean): void;
  7011. protected _getTargetPosition(): Vector3;
  7012. private _storedAlpha;
  7013. private _storedBeta;
  7014. private _storedRadius;
  7015. private _storedTarget;
  7016. /**
  7017. * Stores the current state of the camera (alpha, beta, radius and target)
  7018. * @returns the camera itself
  7019. */
  7020. storeState(): Camera;
  7021. /**
  7022. * @hidden
  7023. * Restored camera state. You must call storeState() first
  7024. */
  7025. _restoreStateValues(): boolean;
  7026. /** @hidden */
  7027. _isSynchronizedViewMatrix(): boolean;
  7028. /**
  7029. * Attached controls to the current camera.
  7030. * @param element Defines the element the controls should be listened from
  7031. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7032. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  7033. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  7034. */
  7035. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  7036. /**
  7037. * Detach the current controls from the camera.
  7038. * The camera will stop reacting to inputs.
  7039. * @param element Defines the element to stop listening the inputs from
  7040. */
  7041. detachControl(element: HTMLElement): void;
  7042. /** @hidden */
  7043. _checkInputs(): void;
  7044. protected _checkLimits(): void;
  7045. /**
  7046. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  7047. */
  7048. rebuildAnglesAndRadius(): void;
  7049. /**
  7050. * Use a position to define the current camera related information like aplha, beta and radius
  7051. * @param position Defines the position to set the camera at
  7052. */
  7053. setPosition(position: Vector3): void;
  7054. /**
  7055. * Defines the target the camera should look at.
  7056. * This will automatically adapt alpha beta and radius to fit within the new target.
  7057. * @param target Defines the new target as a Vector or a mesh
  7058. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7059. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7060. */
  7061. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7062. /** @hidden */
  7063. _getViewMatrix(): Matrix;
  7064. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7065. /**
  7066. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7067. * @param meshes Defines the mesh to zoom on
  7068. * @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)
  7069. */
  7070. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7071. /**
  7072. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7073. * The target will be changed but the radius
  7074. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7075. * @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)
  7076. */
  7077. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7078. min: Vector3;
  7079. max: Vector3;
  7080. distance: number;
  7081. }, doNotUpdateMaxZ?: boolean): void;
  7082. /**
  7083. * @override
  7084. * Override Camera.createRigCamera
  7085. */
  7086. createRigCamera(name: string, cameraIndex: number): Camera;
  7087. /**
  7088. * @hidden
  7089. * @override
  7090. * Override Camera._updateRigCameras
  7091. */
  7092. _updateRigCameras(): void;
  7093. /**
  7094. * Destroy the camera and release the current resources hold by it.
  7095. */
  7096. dispose(): void;
  7097. /**
  7098. * Gets the current object class name.
  7099. * @return the class name
  7100. */
  7101. getClassName(): string;
  7102. }
  7103. }
  7104. declare module BABYLON {
  7105. /**
  7106. * Default Inputs manager for the ArcRotateCamera.
  7107. * It groups all the default supported inputs for ease of use.
  7108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7109. */
  7110. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7111. /**
  7112. * Instantiates a new ArcRotateCameraInputsManager.
  7113. * @param camera Defines the camera the inputs belong to
  7114. */
  7115. constructor(camera: ArcRotateCamera);
  7116. /**
  7117. * Add mouse wheel input support to the input manager.
  7118. * @returns the current input manager
  7119. */
  7120. addMouseWheel(): ArcRotateCameraInputsManager;
  7121. /**
  7122. * Add pointers input support to the input manager.
  7123. * @returns the current input manager
  7124. */
  7125. addPointers(): ArcRotateCameraInputsManager;
  7126. /**
  7127. * Add keyboard input support to the input manager.
  7128. * @returns the current input manager
  7129. */
  7130. addKeyboard(): ArcRotateCameraInputsManager;
  7131. /**
  7132. * Add orientation input support to the input manager.
  7133. * @returns the current input manager
  7134. */
  7135. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7136. }
  7137. }
  7138. declare module BABYLON {
  7139. /**
  7140. * This is the base class of all the camera used in the application.
  7141. * @see http://doc.babylonjs.com/features/cameras
  7142. */
  7143. class Camera extends Node {
  7144. /**
  7145. * This is the default projection mode used by the cameras.
  7146. * It helps recreating a feeling of perspective and better appreciate depth.
  7147. * This is the best way to simulate real life cameras.
  7148. */
  7149. static readonly PERSPECTIVE_CAMERA: number;
  7150. /**
  7151. * This helps creating camera with an orthographic mode.
  7152. * 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.
  7153. */
  7154. static readonly ORTHOGRAPHIC_CAMERA: number;
  7155. /**
  7156. * This is the default FOV mode for perspective cameras.
  7157. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7158. */
  7159. static readonly FOVMODE_VERTICAL_FIXED: number;
  7160. /**
  7161. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7162. */
  7163. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7164. /**
  7165. * This specifies ther is no need for a camera rig.
  7166. * Basically only one eye is rendered corresponding to the camera.
  7167. */
  7168. static readonly RIG_MODE_NONE: number;
  7169. /**
  7170. * Simulates a camera Rig with one blue eye and one red eye.
  7171. * This can be use with 3d blue and red glasses.
  7172. */
  7173. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7174. /**
  7175. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7176. */
  7177. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7178. /**
  7179. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7180. */
  7181. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7182. /**
  7183. * Defines that both eyes of the camera will be rendered over under each other.
  7184. */
  7185. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7186. /**
  7187. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7188. */
  7189. static readonly RIG_MODE_VR: number;
  7190. /**
  7191. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7192. */
  7193. static readonly RIG_MODE_WEBVR: number;
  7194. /**
  7195. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  7196. */
  7197. static readonly RIG_MODE_CUSTOM: number;
  7198. /**
  7199. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7200. */
  7201. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7202. /**
  7203. * @hidden
  7204. * Might be removed once multiview will be a thing
  7205. */
  7206. static UseAlternateWebVRRendering: boolean;
  7207. /**
  7208. * Define the input manager associated with the camera.
  7209. */
  7210. inputs: CameraInputsManager<Camera>;
  7211. /**
  7212. * Define the current local position of the camera in the scene
  7213. */
  7214. position: Vector3;
  7215. /**
  7216. * The vector the camera should consider as up.
  7217. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  7218. */
  7219. upVector: Vector3;
  7220. /**
  7221. * Define the current limit on the left side for an orthographic camera
  7222. * In scene unit
  7223. */
  7224. orthoLeft: Nullable<number>;
  7225. /**
  7226. * Define the current limit on the right side for an orthographic camera
  7227. * In scene unit
  7228. */
  7229. orthoRight: Nullable<number>;
  7230. /**
  7231. * Define the current limit on the bottom side for an orthographic camera
  7232. * In scene unit
  7233. */
  7234. orthoBottom: Nullable<number>;
  7235. /**
  7236. * Define the current limit on the top side for an orthographic camera
  7237. * In scene unit
  7238. */
  7239. orthoTop: Nullable<number>;
  7240. /**
  7241. * Field Of View is set in Radians. (default is 0.8)
  7242. */
  7243. fov: number;
  7244. /**
  7245. * Define the minimum distance the camera can see from.
  7246. * This is important to note that the depth buffer are not infinite and the closer it starts
  7247. * the more your scene might encounter depth fighting issue.
  7248. */
  7249. minZ: number;
  7250. /**
  7251. * Define the maximum distance the camera can see to.
  7252. * This is important to note that the depth buffer are not infinite and the further it end
  7253. * the more your scene might encounter depth fighting issue.
  7254. */
  7255. maxZ: number;
  7256. /**
  7257. * Define the default inertia of the camera.
  7258. * This helps giving a smooth feeling to the camera movement.
  7259. */
  7260. inertia: number;
  7261. /**
  7262. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  7263. */
  7264. mode: number;
  7265. /**
  7266. * Define wether the camera is intermediate.
  7267. * This is usefull to not present the output directly to the screen in case of rig without post process for instance
  7268. */
  7269. isIntermediate: boolean;
  7270. /**
  7271. * Define the viewport of the camera.
  7272. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  7273. */
  7274. viewport: Viewport;
  7275. /**
  7276. * Restricts the camera to viewing objects with the same layerMask.
  7277. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  7278. */
  7279. layerMask: number;
  7280. /**
  7281. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  7282. */
  7283. fovMode: number;
  7284. /**
  7285. * Rig mode of the camera.
  7286. * This is usefull to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  7287. * This is normally controlled byt the camera themselves as internal use.
  7288. */
  7289. cameraRigMode: number;
  7290. /**
  7291. * Defines the distance between both "eyes" in case of a RIG
  7292. */
  7293. interaxialDistance: number;
  7294. /**
  7295. * Defines if stereoscopic rendering is done side by side or over under.
  7296. */
  7297. isStereoscopicSideBySide: boolean;
  7298. /**
  7299. * 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
  7300. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  7301. * else in the scene.
  7302. */
  7303. customRenderTargets: RenderTargetTexture[];
  7304. /**
  7305. * When set, the camera will render to this render target instead of the default canvas
  7306. */
  7307. outputRenderTarget: Nullable<RenderTargetTexture>;
  7308. /**
  7309. * Observable triggered when the camera view matrix has changed.
  7310. */
  7311. onViewMatrixChangedObservable: Observable<Camera>;
  7312. /**
  7313. * Observable triggered when the camera Projection matrix has changed.
  7314. */
  7315. onProjectionMatrixChangedObservable: Observable<Camera>;
  7316. /**
  7317. * Observable triggered when the inputs have been processed.
  7318. */
  7319. onAfterCheckInputsObservable: Observable<Camera>;
  7320. /**
  7321. * Observable triggered when reset has been called and applied to the camera.
  7322. */
  7323. onRestoreStateObservable: Observable<Camera>;
  7324. /** @hidden */
  7325. _cameraRigParams: any;
  7326. /** @hidden */
  7327. _rigCameras: Camera[];
  7328. /** @hidden */
  7329. _rigPostProcess: Nullable<PostProcess>;
  7330. protected _webvrViewMatrix: Matrix;
  7331. /** @hidden */
  7332. _skipRendering: boolean;
  7333. /** @hidden */
  7334. _alternateCamera: Camera;
  7335. /** @hidden */
  7336. _projectionMatrix: Matrix;
  7337. /** @hidden */
  7338. _postProcesses: Nullable<PostProcess>[];
  7339. /** @hidden */
  7340. _activeMeshes: SmartArray<AbstractMesh>;
  7341. protected _globalPosition: Vector3;
  7342. /** hidden */
  7343. _computedViewMatrix: Matrix;
  7344. private _doNotComputeProjectionMatrix;
  7345. private _transformMatrix;
  7346. private _frustumPlanes;
  7347. private _refreshFrustumPlanes;
  7348. private _storedFov;
  7349. private _stateStored;
  7350. /**
  7351. * Instantiates a new camera object.
  7352. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  7353. * @see http://doc.babylonjs.com/features/cameras
  7354. * @param name Defines the name of the camera in the scene
  7355. * @param position Defines the position of the camera
  7356. * @param scene Defines the scene the camera belongs too
  7357. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  7358. */
  7359. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7360. /**
  7361. * Store current camera state (fov, position, etc..)
  7362. * @returns the camera
  7363. */
  7364. storeState(): Camera;
  7365. /**
  7366. * Restores the camera state values if it has been stored. You must call storeState() first
  7367. */
  7368. protected _restoreStateValues(): boolean;
  7369. /**
  7370. * Restored camera state. You must call storeState() first.
  7371. * @returns true if restored and false otherwise
  7372. */
  7373. restoreState(): boolean;
  7374. /**
  7375. * Gets the class name of the camera.
  7376. * @returns the class name
  7377. */
  7378. getClassName(): string;
  7379. /**
  7380. * Gets a string representation of the camera usefull for debug purpose.
  7381. * @param fullDetails Defines that a more verboe level of logging is required
  7382. * @returns the string representation
  7383. */
  7384. toString(fullDetails?: boolean): string;
  7385. /**
  7386. * Gets the current world space position of the camera.
  7387. */
  7388. readonly globalPosition: Vector3;
  7389. /**
  7390. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  7391. * @returns the active meshe list
  7392. */
  7393. getActiveMeshes(): SmartArray<AbstractMesh>;
  7394. /**
  7395. * Check wether a mesh is part of the current active mesh list of the camera
  7396. * @param mesh Defines the mesh to check
  7397. * @returns true if active, false otherwise
  7398. */
  7399. isActiveMesh(mesh: Mesh): boolean;
  7400. /**
  7401. * Is this camera ready to be used/rendered
  7402. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  7403. * @return true if the camera is ready
  7404. */
  7405. isReady(completeCheck?: boolean): boolean;
  7406. /** @hidden */
  7407. _initCache(): void;
  7408. /** @hidden */
  7409. _updateCache(ignoreParentClass?: boolean): void;
  7410. /** @hidden */
  7411. _isSynchronized(): boolean;
  7412. /** @hidden */
  7413. _isSynchronizedViewMatrix(): boolean;
  7414. /** @hidden */
  7415. _isSynchronizedProjectionMatrix(): boolean;
  7416. /**
  7417. * Attach the input controls to a specific dom element to get the input from.
  7418. * @param element Defines the element the controls should be listened from
  7419. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7420. */
  7421. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7422. /**
  7423. * Detach the current controls from the specified dom element.
  7424. * @param element Defines the element to stop listening the inputs from
  7425. */
  7426. detachControl(element: HTMLElement): void;
  7427. /**
  7428. * Update the camera state according to the different inputs gathered during the frame.
  7429. */
  7430. update(): void;
  7431. /** @hidden */
  7432. _checkInputs(): void;
  7433. /** @hidden */
  7434. readonly rigCameras: Camera[];
  7435. /**
  7436. * Gets the post process used by the rig cameras
  7437. */
  7438. readonly rigPostProcess: Nullable<PostProcess>;
  7439. /**
  7440. * Internal, gets the first post proces.
  7441. * @returns the first post process to be run on this camera.
  7442. */
  7443. _getFirstPostProcess(): Nullable<PostProcess>;
  7444. private _cascadePostProcessesToRigCams;
  7445. /**
  7446. * Attach a post process to the camera.
  7447. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7448. * @param postProcess The post process to attach to the camera
  7449. * @param insertAt The position of the post process in case several of them are in use in the scene
  7450. * @returns the position the post process has been inserted at
  7451. */
  7452. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  7453. /**
  7454. * Detach a post process to the camera.
  7455. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7456. * @param postProcess The post process to detach from the camera
  7457. */
  7458. detachPostProcess(postProcess: PostProcess): void;
  7459. /**
  7460. * Gets the current world matrix of the camera
  7461. */
  7462. getWorldMatrix(): Matrix;
  7463. /** @hidden */
  7464. protected _getViewMatrix(): Matrix;
  7465. /**
  7466. * Gets the current view matrix of the camera.
  7467. * @param force forces the camera to recompute the matrix without looking at the cached state
  7468. * @returns the view matrix
  7469. */
  7470. getViewMatrix(force?: boolean): Matrix;
  7471. /**
  7472. * Freeze the projection matrix.
  7473. * It will prevent the cache check of the camera projection compute and can speed up perf
  7474. * if no parameter of the camera are meant to change
  7475. * @param projection Defines manually a projection if necessary
  7476. */
  7477. freezeProjectionMatrix(projection?: Matrix): void;
  7478. /**
  7479. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  7480. */
  7481. unfreezeProjectionMatrix(): void;
  7482. /**
  7483. * Gets the current projection matrix of the camera.
  7484. * @param force forces the camera to recompute the matrix without looking at the cached state
  7485. * @returns the projection matrix
  7486. */
  7487. getProjectionMatrix(force?: boolean): Matrix;
  7488. /**
  7489. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  7490. * @returns a Matrix
  7491. */
  7492. getTransformationMatrix(): Matrix;
  7493. private _updateFrustumPlanes;
  7494. /**
  7495. * Checks if a cullable object (mesh...) is in the camera frustum
  7496. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  7497. * @param target The object to check
  7498. * @returns true if the object is in frustum otherwise false
  7499. */
  7500. isInFrustum(target: ICullable): boolean;
  7501. /**
  7502. * Checks if a cullable object (mesh...) is in the camera frustum
  7503. * Unlike isInFrustum this cheks the full bounding box
  7504. * @param target The object to check
  7505. * @returns true if the object is in frustum otherwise false
  7506. */
  7507. isCompletelyInFrustum(target: ICullable): boolean;
  7508. /**
  7509. * Gets a ray in the forward direction from the camera.
  7510. * @param length Defines the length of the ray to create
  7511. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  7512. * @param origin Defines the start point of the ray which defaults to the camera position
  7513. * @returns the forward ray
  7514. */
  7515. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  7516. /**
  7517. * Releases resources associated with this node.
  7518. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7519. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7520. */
  7521. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7522. /**
  7523. * Gets the left camera of a rig setup in case of Rigged Camera
  7524. */
  7525. readonly leftCamera: Nullable<FreeCamera>;
  7526. /**
  7527. * Gets the right camera of a rig setup in case of Rigged Camera
  7528. */
  7529. readonly rightCamera: Nullable<FreeCamera>;
  7530. /**
  7531. * Gets the left camera target of a rig setup in case of Rigged Camera
  7532. * @returns the target position
  7533. */
  7534. getLeftTarget(): Nullable<Vector3>;
  7535. /**
  7536. * Gets the right camera target of a rig setup in case of Rigged Camera
  7537. * @returns the target position
  7538. */
  7539. getRightTarget(): Nullable<Vector3>;
  7540. /**
  7541. * @hidden
  7542. */
  7543. setCameraRigMode(mode: number, rigParams: any): void;
  7544. private _getVRProjectionMatrix;
  7545. protected _updateCameraRotationMatrix(): void;
  7546. protected _updateWebVRCameraRotationMatrix(): void;
  7547. /**
  7548. * This function MUST be overwritten by the different WebVR cameras available.
  7549. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7550. */
  7551. protected _getWebVRProjectionMatrix(): Matrix;
  7552. /**
  7553. * This function MUST be overwritten by the different WebVR cameras available.
  7554. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7555. */
  7556. protected _getWebVRViewMatrix(): Matrix;
  7557. /** @hidden */
  7558. setCameraRigParameter(name: string, value: any): void;
  7559. /**
  7560. * needs to be overridden by children so sub has required properties to be copied
  7561. * @hidden
  7562. */
  7563. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7564. /**
  7565. * May need to be overridden by children
  7566. * @hidden
  7567. */
  7568. _updateRigCameras(): void;
  7569. /** @hidden */
  7570. _setupInputs(): void;
  7571. /**
  7572. * Serialiaze the camera setup to a json represention
  7573. * @returns the JSON representation
  7574. */
  7575. serialize(): any;
  7576. /**
  7577. * Clones the current camera.
  7578. * @param name The cloned camera name
  7579. * @returns the cloned camera
  7580. */
  7581. clone(name: string): Camera;
  7582. /**
  7583. * Gets the direction of the camera relative to a given local axis.
  7584. * @param localAxis Defines the reference axis to provide a relative direction.
  7585. * @return the direction
  7586. */
  7587. getDirection(localAxis: Vector3): Vector3;
  7588. /**
  7589. * Gets the direction of the camera relative to a given local axis into a passed vector.
  7590. * @param localAxis Defines the reference axis to provide a relative direction.
  7591. * @param result Defines the vector to store the result in
  7592. */
  7593. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  7594. /**
  7595. * Gets a camera constructor for a given camera type
  7596. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  7597. * @param name The name of the camera the result will be able to instantiate
  7598. * @param scene The scene the result will construct the camera in
  7599. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  7600. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  7601. * @returns a factory method to construc the camera
  7602. */
  7603. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  7604. /**
  7605. * Compute the world matrix of the camera.
  7606. * @returns the camera workd matrix
  7607. */
  7608. computeWorldMatrix(): Matrix;
  7609. /**
  7610. * Parse a JSON and creates the camera from the parsed information
  7611. * @param parsedCamera The JSON to parse
  7612. * @param scene The scene to instantiate the camera in
  7613. * @returns the newly constructed camera
  7614. */
  7615. static Parse(parsedCamera: any, scene: Scene): Camera;
  7616. }
  7617. }
  7618. declare module BABYLON {
  7619. /**
  7620. * @ignore
  7621. * This is a list of all the different input types that are available in the application.
  7622. * Fo instance: ArcRotateCameraGamepadInput...
  7623. */
  7624. var CameraInputTypes: {};
  7625. /**
  7626. * This is the contract to implement in order to create a new input class.
  7627. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7628. */
  7629. interface ICameraInput<TCamera extends Camera> {
  7630. /**
  7631. * Defines the camera the input is attached to.
  7632. */
  7633. camera: Nullable<TCamera>;
  7634. /**
  7635. * Gets the class name of the current intput.
  7636. * @returns the class name
  7637. */
  7638. getClassName(): string;
  7639. /**
  7640. * Get the friendly name associated with the input class.
  7641. * @returns the input friendly name
  7642. */
  7643. getSimpleName(): string;
  7644. /**
  7645. * Attach the input controls to a specific dom element to get the input from.
  7646. * @param element Defines the element the controls should be listened from
  7647. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7648. */
  7649. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7650. /**
  7651. * Detach the current controls from the specified dom element.
  7652. * @param element Defines the element to stop listening the inputs from
  7653. */
  7654. detachControl(element: Nullable<HTMLElement>): void;
  7655. /**
  7656. * Update the current camera state depending on the inputs that have been used this frame.
  7657. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7658. */
  7659. checkInputs?: () => void;
  7660. }
  7661. /**
  7662. * Represents a map of input types to input instance or input index to input instance.
  7663. */
  7664. interface CameraInputsMap<TCamera extends Camera> {
  7665. /**
  7666. * Accessor to the input by input type.
  7667. */
  7668. [name: string]: ICameraInput<TCamera>;
  7669. /**
  7670. * Accessor to the input by input index.
  7671. */
  7672. [idx: number]: ICameraInput<TCamera>;
  7673. }
  7674. /**
  7675. * This represents the input manager used within a camera.
  7676. * It helps dealing with all the different kind of input attached to a camera.
  7677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7678. */
  7679. class CameraInputsManager<TCamera extends Camera> {
  7680. /**
  7681. * Defines the list of inputs attahed to the camera.
  7682. */
  7683. attached: CameraInputsMap<TCamera>;
  7684. /**
  7685. * Defines the dom element the camera is collecting inputs from.
  7686. * This is null if the controls have not been attached.
  7687. */
  7688. attachedElement: Nullable<HTMLElement>;
  7689. /**
  7690. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7691. */
  7692. noPreventDefault: boolean;
  7693. /**
  7694. * Defined the camera the input manager belongs to.
  7695. */
  7696. camera: TCamera;
  7697. /**
  7698. * Update the current camera state depending on the inputs that have been used this frame.
  7699. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7700. */
  7701. checkInputs: () => void;
  7702. /**
  7703. * Instantiate a new Camera Input Manager.
  7704. * @param camera Defines the camera the input manager blongs to
  7705. */
  7706. constructor(camera: TCamera);
  7707. /**
  7708. * Add an input method to a camera
  7709. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7710. * @param input camera input method
  7711. */
  7712. add(input: ICameraInput<TCamera>): void;
  7713. /**
  7714. * Remove a specific input method from a camera
  7715. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  7716. * @param inputToRemove camera input method
  7717. */
  7718. remove(inputToRemove: ICameraInput<TCamera>): void;
  7719. /**
  7720. * Remove a specific input type from a camera
  7721. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  7722. * @param inputType the type of the input to remove
  7723. */
  7724. removeByType(inputType: string): void;
  7725. private _addCheckInputs;
  7726. /**
  7727. * Attach the input controls to the currently attached dom element to listen the events from.
  7728. * @param input Defines the input to attach
  7729. */
  7730. attachInput(input: ICameraInput<TCamera>): void;
  7731. /**
  7732. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  7733. * @param element Defines the dom element to collect the events from
  7734. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7735. */
  7736. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  7737. /**
  7738. * Detach the current manager inputs controls from a specific dom element.
  7739. * @param element Defines the dom element to collect the events from
  7740. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  7741. */
  7742. detachElement(element: HTMLElement, disconnect?: boolean): void;
  7743. /**
  7744. * Rebuild the dynamic inputCheck function from the current list of
  7745. * defined inputs in the manager.
  7746. */
  7747. rebuildInputCheck(): void;
  7748. /**
  7749. * Remove all attached input methods from a camera
  7750. */
  7751. clear(): void;
  7752. /**
  7753. * Serialize the current input manager attached to a camera.
  7754. * This ensures than once parsed,
  7755. * the input associated to the camera will be identical to the current ones
  7756. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  7757. */
  7758. serialize(serializedCamera: any): void;
  7759. /**
  7760. * Parses an input manager serialized JSON to restore the previous list of inputs
  7761. * and states associated to a camera.
  7762. * @param parsedCamera Defines the JSON to parse
  7763. */
  7764. parse(parsedCamera: any): void;
  7765. }
  7766. }
  7767. declare module BABYLON {
  7768. /**
  7769. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  7770. * being tilted forward or back and left or right.
  7771. */
  7772. class DeviceOrientationCamera extends FreeCamera {
  7773. private _initialQuaternion;
  7774. private _quaternionCache;
  7775. /**
  7776. * Creates a new device orientation camera
  7777. * @param name The name of the camera
  7778. * @param position The start position camera
  7779. * @param scene The scene the camera belongs to
  7780. */
  7781. constructor(name: string, position: Vector3, scene: Scene);
  7782. /**
  7783. * Gets the current instance class name ("DeviceOrientationCamera").
  7784. * This helps avoiding instanceof at run time.
  7785. * @returns the class name
  7786. */
  7787. getClassName(): string;
  7788. /**
  7789. * @hidden
  7790. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  7791. */
  7792. _checkInputs(): void;
  7793. /**
  7794. * Reset the camera to its default orientation on the specified axis only.
  7795. * @param axis The axis to reset
  7796. */
  7797. resetToCurrentRotation(axis?: Axis): void;
  7798. }
  7799. }
  7800. declare module BABYLON {
  7801. /**
  7802. * This is a flying camera, designed for 3D movement and rotation in all directions,
  7803. * such as in a 3D Space Shooter or a Flight Simulator.
  7804. */
  7805. class FlyCamera extends TargetCamera {
  7806. /**
  7807. * Define the collision ellipsoid of the camera.
  7808. * This is helpful for simulating a camera body, like a player's body.
  7809. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7810. */
  7811. ellipsoid: Vector3;
  7812. /**
  7813. * Define an offset for the position of the ellipsoid around the camera.
  7814. * This can be helpful if the camera is attached away from the player's body center,
  7815. * such as at its head.
  7816. */
  7817. ellipsoidOffset: Vector3;
  7818. /**
  7819. * Enable or disable collisions of the camera with the rest of the scene objects.
  7820. */
  7821. checkCollisions: boolean;
  7822. /**
  7823. * Enable or disable gravity on the camera.
  7824. */
  7825. applyGravity: boolean;
  7826. /**
  7827. * Define the current direction the camera is moving to.
  7828. */
  7829. cameraDirection: Vector3;
  7830. /**
  7831. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  7832. * This overrides and empties cameraRotation.
  7833. */
  7834. rotationQuaternion: BABYLON.Quaternion;
  7835. /**
  7836. * Track Roll to maintain the wanted Rolling when looking around.
  7837. */
  7838. _trackRoll: number;
  7839. /**
  7840. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  7841. */
  7842. rollCorrect: number;
  7843. /**
  7844. * Mimic a banked turn, Rolling the camera when Yawing.
  7845. * It's recommended to use rollCorrect = 10 for faster banking correction.
  7846. */
  7847. bankedTurn: boolean;
  7848. /**
  7849. * Limit in radians for how much Roll banking will add. (Default: 90°)
  7850. */
  7851. bankedTurnLimit: number;
  7852. /**
  7853. * Value of 0 disables the banked Roll.
  7854. * Value of 1 is equal to the Yaw angle in radians.
  7855. */
  7856. bankedTurnMultiplier: number;
  7857. /**
  7858. * The inputs manager loads all the input sources, such as keyboard and mouse.
  7859. */
  7860. inputs: FlyCameraInputsManager;
  7861. /**
  7862. * Gets the input sensibility for mouse input.
  7863. * Higher values reduce sensitivity.
  7864. */
  7865. /**
  7866. * Sets the input sensibility for a mouse input.
  7867. * Higher values reduce sensitivity.
  7868. */
  7869. angularSensibility: number;
  7870. /**
  7871. * Get the keys for camera movement forward.
  7872. */
  7873. /**
  7874. * Set the keys for camera movement forward.
  7875. */
  7876. keysForward: number[];
  7877. /**
  7878. * Get the keys for camera movement backward.
  7879. */
  7880. keysBackward: number[];
  7881. /**
  7882. * Get the keys for camera movement up.
  7883. */
  7884. /**
  7885. * Set the keys for camera movement up.
  7886. */
  7887. keysUp: number[];
  7888. /**
  7889. * Get the keys for camera movement down.
  7890. */
  7891. /**
  7892. * Set the keys for camera movement down.
  7893. */
  7894. keysDown: number[];
  7895. /**
  7896. * Get the keys for camera movement left.
  7897. */
  7898. /**
  7899. * Set the keys for camera movement left.
  7900. */
  7901. keysLeft: number[];
  7902. /**
  7903. * Set the keys for camera movement right.
  7904. */
  7905. /**
  7906. * Set the keys for camera movement right.
  7907. */
  7908. keysRight: number[];
  7909. /**
  7910. * Event raised when the camera collides with a mesh in the scene.
  7911. */
  7912. onCollide: (collidedMesh: AbstractMesh) => void;
  7913. private _collider;
  7914. private _needMoveForGravity;
  7915. private _oldPosition;
  7916. private _diffPosition;
  7917. private _newPosition;
  7918. /** @hidden */
  7919. _localDirection: Vector3;
  7920. /** @hidden */
  7921. _transformedDirection: Vector3;
  7922. /**
  7923. * Instantiates a FlyCamera.
  7924. * This is a flying camera, designed for 3D movement and rotation in all directions,
  7925. * such as in a 3D Space Shooter or a Flight Simulator.
  7926. * @param name Define the name of the camera in the scene.
  7927. * @param position Define the starting position of the camera in the scene.
  7928. * @param scene Define the scene the camera belongs to.
  7929. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  7930. */
  7931. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7932. /**
  7933. * Attach a control to the HTML DOM element.
  7934. * @param element Defines the element that listens to the input events.
  7935. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  7936. */
  7937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7938. /**
  7939. * Detach a control from the HTML DOM element.
  7940. * The camera will stop reacting to that input.
  7941. * @param element Defines the element that listens to the input events.
  7942. */
  7943. detachControl(element: HTMLElement): void;
  7944. private _collisionMask;
  7945. /**
  7946. * Get the mask that the camera ignores in collision events.
  7947. */
  7948. /**
  7949. * Set the mask that the camera ignores in collision events.
  7950. */
  7951. collisionMask: number;
  7952. /** @hidden */
  7953. _collideWithWorld(displacement: Vector3): void;
  7954. /** @hidden */
  7955. private _onCollisionPositionChange;
  7956. /** @hidden */
  7957. _checkInputs(): void;
  7958. /** @hidden */
  7959. _decideIfNeedsToMove(): boolean;
  7960. /** @hidden */
  7961. _updatePosition(): void;
  7962. /**
  7963. * Restore the Roll to its target value at the rate specified.
  7964. * @param rate - Higher means slower restoring.
  7965. * @hidden
  7966. */
  7967. restoreRoll(rate: number): void;
  7968. /**
  7969. * Destroy the camera and release the current resources held by it.
  7970. */
  7971. dispose(): void;
  7972. /**
  7973. * Get the current object class name.
  7974. * @returns the class name.
  7975. */
  7976. getClassName(): string;
  7977. }
  7978. }
  7979. declare module BABYLON {
  7980. /**
  7981. * Default Inputs manager for the FlyCamera.
  7982. * It groups all the default supported inputs for ease of use.
  7983. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7984. */
  7985. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  7986. /**
  7987. * Instantiates a new FlyCameraInputsManager.
  7988. * @param camera Defines the camera the inputs belong to.
  7989. */
  7990. constructor(camera: FlyCamera);
  7991. /**
  7992. * Add keyboard input support to the input manager.
  7993. * @returns the new FlyCameraKeyboardMoveInput().
  7994. */
  7995. addKeyboard(): FlyCameraInputsManager;
  7996. /**
  7997. * Add mouse input support to the input manager.
  7998. * @param touchEnabled Enable touch screen support.
  7999. * @returns the new FlyCameraMouseInput().
  8000. */
  8001. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  8002. }
  8003. }
  8004. declare module BABYLON {
  8005. /**
  8006. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  8007. * an arc rotate version arcFollowCamera are available.
  8008. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8009. */
  8010. class FollowCamera extends TargetCamera {
  8011. /**
  8012. * Distance the follow camera should follow an object at
  8013. */
  8014. radius: number;
  8015. /**
  8016. * Define a rotation offset between the camera and the object it follows
  8017. */
  8018. rotationOffset: number;
  8019. /**
  8020. * Define a height offset between the camera and the object it follows.
  8021. * It can help following an object from the top (like a car chaing a plane)
  8022. */
  8023. heightOffset: number;
  8024. /**
  8025. * Define how fast the camera can accelerate to follow it s target.
  8026. */
  8027. cameraAcceleration: number;
  8028. /**
  8029. * Define the speed limit of the camera following an object.
  8030. */
  8031. maxCameraSpeed: number;
  8032. /**
  8033. * Define the target of the camera.
  8034. */
  8035. lockedTarget: Nullable<AbstractMesh>;
  8036. /**
  8037. * Instantiates the follow camera.
  8038. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8039. * @param name Define the name of the camera in the scene
  8040. * @param position Define the position of the camera
  8041. * @param scene Define the scene the camera belong to
  8042. * @param lockedTarget Define the target of the camera
  8043. */
  8044. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8045. private _follow;
  8046. /** @hidden */
  8047. _checkInputs(): void;
  8048. /**
  8049. * Gets the camera class name.
  8050. * @returns the class name
  8051. */
  8052. getClassName(): string;
  8053. }
  8054. /**
  8055. * Arc Rotate version of the follow camera.
  8056. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8057. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8058. */
  8059. class ArcFollowCamera extends TargetCamera {
  8060. /** The longitudinal angle of the camera */
  8061. alpha: number;
  8062. /** The latitudinal angle of the camera */
  8063. beta: number;
  8064. /** The radius of the camera from its target */
  8065. radius: number;
  8066. /** Define the camera target (the messh it should follow) */
  8067. target: Nullable<AbstractMesh>;
  8068. private _cartesianCoordinates;
  8069. /**
  8070. * Instantiates a new ArcFollowCamera
  8071. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8072. * @param name Define the name of the camera
  8073. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8074. * @param beta Define the rotation angle of the camera around the elevation axis
  8075. * @param radius Define the radius of the camera from its target point
  8076. * @param target Define the target of the camera
  8077. * @param scene Define the scene the camera belongs to
  8078. */
  8079. constructor(name: string,
  8080. /** The longitudinal angle of the camera */
  8081. alpha: number,
  8082. /** The latitudinal angle of the camera */
  8083. beta: number,
  8084. /** The radius of the camera from its target */
  8085. radius: number,
  8086. /** Define the camera target (the messh it should follow) */
  8087. target: Nullable<AbstractMesh>, scene: Scene);
  8088. private _follow;
  8089. /** @hidden */
  8090. _checkInputs(): void;
  8091. /**
  8092. * Returns the class name of the object.
  8093. * It is mostly used internally for serialization purposes.
  8094. */
  8095. getClassName(): string;
  8096. }
  8097. }
  8098. declare module BABYLON {
  8099. /**
  8100. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8101. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8102. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8103. */
  8104. class FreeCamera extends TargetCamera {
  8105. /**
  8106. * Define the collision ellipsoid of the camera.
  8107. * This is helpful to simulate a camera body like the player body around the camera
  8108. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8109. */
  8110. ellipsoid: Vector3;
  8111. /**
  8112. * Define an offset for the position of the ellipsoid around the camera.
  8113. * This can be helpful to determine the center of the body near the gravity center of the body
  8114. * instead of its head.
  8115. */
  8116. ellipsoidOffset: Vector3;
  8117. /**
  8118. * Enable or disable collisions of the camera with the rest of the scene objects.
  8119. */
  8120. checkCollisions: boolean;
  8121. /**
  8122. * Enable or disable gravity on the camera.
  8123. */
  8124. applyGravity: boolean;
  8125. /**
  8126. * Define the input manager associated to the camera.
  8127. */
  8128. inputs: FreeCameraInputsManager;
  8129. /**
  8130. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8131. * Higher values reduce sensitivity.
  8132. */
  8133. /**
  8134. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8135. * Higher values reduce sensitivity.
  8136. */
  8137. angularSensibility: number;
  8138. /**
  8139. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8140. */
  8141. keysUp: number[];
  8142. /**
  8143. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8144. */
  8145. keysDown: number[];
  8146. /**
  8147. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8148. */
  8149. keysLeft: number[];
  8150. /**
  8151. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8152. */
  8153. keysRight: number[];
  8154. /**
  8155. * Event raised when the camera collide with a mesh in the scene.
  8156. */
  8157. onCollide: (collidedMesh: AbstractMesh) => void;
  8158. private _collider;
  8159. private _needMoveForGravity;
  8160. private _oldPosition;
  8161. private _diffPosition;
  8162. private _newPosition;
  8163. /** @hidden */
  8164. _localDirection: Vector3;
  8165. /** @hidden */
  8166. _transformedDirection: Vector3;
  8167. /**
  8168. * Instantiates a Free Camera.
  8169. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8170. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8171. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8172. * @param name Define the name of the camera in the scene
  8173. * @param position Define the start position of the camera in the scene
  8174. * @param scene Define the scene the camera belongs to
  8175. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8176. */
  8177. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8178. /**
  8179. * Attached controls to the current camera.
  8180. * @param element Defines the element the controls should be listened from
  8181. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8182. */
  8183. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8184. /**
  8185. * Detach the current controls from the camera.
  8186. * The camera will stop reacting to inputs.
  8187. * @param element Defines the element to stop listening the inputs from
  8188. */
  8189. detachControl(element: HTMLElement): void;
  8190. private _collisionMask;
  8191. /**
  8192. * Define a collision mask to limit the list of object the camera can collide with
  8193. */
  8194. collisionMask: number;
  8195. /** @hidden */
  8196. _collideWithWorld(displacement: Vector3): void;
  8197. private _onCollisionPositionChange;
  8198. /** @hidden */
  8199. _checkInputs(): void;
  8200. /** @hidden */
  8201. _decideIfNeedsToMove(): boolean;
  8202. /** @hidden */
  8203. _updatePosition(): void;
  8204. /**
  8205. * Destroy the camera and release the current resources hold by it.
  8206. */
  8207. dispose(): void;
  8208. /**
  8209. * Gets the current object class name.
  8210. * @return the class name
  8211. */
  8212. getClassName(): string;
  8213. }
  8214. }
  8215. declare module BABYLON {
  8216. /**
  8217. * Default Inputs manager for the FreeCamera.
  8218. * It groups all the default supported inputs for ease of use.
  8219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8220. */
  8221. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8222. /**
  8223. * Instantiates a new FreeCameraInputsManager.
  8224. * @param camera Defines the camera the inputs belong to
  8225. */
  8226. constructor(camera: FreeCamera);
  8227. /**
  8228. * Add keyboard input support to the input manager.
  8229. * @returns the current input manager
  8230. */
  8231. addKeyboard(): FreeCameraInputsManager;
  8232. /**
  8233. * Add mouse input support to the input manager.
  8234. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8235. * @returns the current input manager
  8236. */
  8237. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8238. /**
  8239. * Add orientation input support to the input manager.
  8240. * @returns the current input manager
  8241. */
  8242. addDeviceOrientation(): FreeCameraInputsManager;
  8243. /**
  8244. * Add touch input support to the input manager.
  8245. * @returns the current input manager
  8246. */
  8247. addTouch(): FreeCameraInputsManager;
  8248. /**
  8249. * Add virtual joystick input support to the input manager.
  8250. * @returns the current input manager
  8251. */
  8252. addVirtualJoystick(): FreeCameraInputsManager;
  8253. }
  8254. }
  8255. declare module BABYLON {
  8256. /**
  8257. * This represents a FPS type of camera. This is only here for back compat purpose.
  8258. * Please use the UniversalCamera instead as both are identical.
  8259. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8260. */
  8261. class GamepadCamera extends UniversalCamera {
  8262. /**
  8263. * Instantiates a new Gamepad Camera
  8264. * This represents a FPS type of camera. This is only here for back compat purpose.
  8265. * Please use the UniversalCamera instead as both are identical.
  8266. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8267. * @param name Define the name of the camera in the scene
  8268. * @param position Define the start position of the camera in the scene
  8269. * @param scene Define the scene the camera belongs to
  8270. */
  8271. constructor(name: string, position: Vector3, scene: Scene);
  8272. /**
  8273. * Gets the current object class name.
  8274. * @return the class name
  8275. */
  8276. getClassName(): string;
  8277. }
  8278. }
  8279. declare module BABYLON {
  8280. /**
  8281. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8282. * This is the base of the follow, arc rotate cameras and Free camera
  8283. * @see http://doc.babylonjs.com/features/cameras
  8284. */
  8285. class TargetCamera extends Camera {
  8286. private static _RigCamTransformMatrix;
  8287. private static _TargetTransformMatrix;
  8288. /**
  8289. * Define the current direction the camera is moving to
  8290. */
  8291. cameraDirection: Vector3;
  8292. /**
  8293. * Define the current rotation the camera is rotating to
  8294. */
  8295. cameraRotation: Vector2;
  8296. /**
  8297. * When set, the up vector of the camera will be updated by the rotation of the camera
  8298. */
  8299. updateUpVectorFromRotation: boolean;
  8300. private _tmpQuaternion;
  8301. /**
  8302. * Define the current rotation of the camera
  8303. */
  8304. rotation: Vector3;
  8305. /**
  8306. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8307. */
  8308. rotationQuaternion: Quaternion;
  8309. /**
  8310. * Define the current speed of the camera
  8311. */
  8312. speed: number;
  8313. /**
  8314. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8315. * around all axis.
  8316. */
  8317. noRotationConstraint: boolean;
  8318. /**
  8319. * Define the current target of the camera as an object or a position.
  8320. */
  8321. lockedTarget: any;
  8322. /** @hidden */
  8323. _currentTarget: Vector3;
  8324. /** @hidden */
  8325. _viewMatrix: Matrix;
  8326. /** @hidden */
  8327. _camMatrix: Matrix;
  8328. /** @hidden */
  8329. _cameraTransformMatrix: Matrix;
  8330. /** @hidden */
  8331. _cameraRotationMatrix: Matrix;
  8332. /** @hidden */
  8333. _referencePoint: Vector3;
  8334. /** @hidden */
  8335. _transformedReferencePoint: Vector3;
  8336. protected _globalCurrentTarget: Vector3;
  8337. protected _globalCurrentUpVector: Vector3;
  8338. /** @hidden */
  8339. _reset: () => void;
  8340. private _defaultUp;
  8341. /**
  8342. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8343. * This is the base of the follow, arc rotate cameras and Free camera
  8344. * @see http://doc.babylonjs.com/features/cameras
  8345. * @param name Defines the name of the camera in the scene
  8346. * @param position Defines the start position of the camera in the scene
  8347. * @param scene Defines the scene the camera belongs to
  8348. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8349. */
  8350. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8351. /**
  8352. * Gets the position in front of the camera at a given distance.
  8353. * @param distance The distance from the camera we want the position to be
  8354. * @returns the position
  8355. */
  8356. getFrontPosition(distance: number): Vector3;
  8357. /** @hidden */
  8358. _getLockedTargetPosition(): Nullable<Vector3>;
  8359. private _storedPosition;
  8360. private _storedRotation;
  8361. private _storedRotationQuaternion;
  8362. /**
  8363. * Store current camera state of the camera (fov, position, rotation, etc..)
  8364. * @returns the camera
  8365. */
  8366. storeState(): Camera;
  8367. /**
  8368. * Restored camera state. You must call storeState() first
  8369. * @returns whether it was successful or not
  8370. * @hidden
  8371. */
  8372. _restoreStateValues(): boolean;
  8373. /** @hidden */
  8374. _initCache(): void;
  8375. /** @hidden */
  8376. _updateCache(ignoreParentClass?: boolean): void;
  8377. /** @hidden */
  8378. _isSynchronizedViewMatrix(): boolean;
  8379. /** @hidden */
  8380. _computeLocalCameraSpeed(): number;
  8381. /** @hidden */
  8382. setTarget(target: Vector3): void;
  8383. /**
  8384. * Return the current target position of the camera. This value is expressed in local space.
  8385. * @returns the target position
  8386. */
  8387. getTarget(): Vector3;
  8388. /** @hidden */
  8389. _decideIfNeedsToMove(): boolean;
  8390. /** @hidden */
  8391. _updatePosition(): void;
  8392. /** @hidden */
  8393. _checkInputs(): void;
  8394. protected _updateCameraRotationMatrix(): void;
  8395. /**
  8396. * 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)
  8397. * @returns the current camera
  8398. */
  8399. private _rotateUpVectorWithCameraRotationMatrix;
  8400. private _cachedRotationZ;
  8401. private _cachedQuaternionRotationZ;
  8402. /** @hidden */
  8403. _getViewMatrix(): Matrix;
  8404. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8405. /**
  8406. * @hidden
  8407. */
  8408. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8409. /**
  8410. * @hidden
  8411. */
  8412. _updateRigCameras(): void;
  8413. private _getRigCamPosition;
  8414. /**
  8415. * Gets the current object class name.
  8416. * @return the class name
  8417. */
  8418. getClassName(): string;
  8419. }
  8420. }
  8421. declare module BABYLON {
  8422. /**
  8423. * This represents a FPS type of camera controlled by touch.
  8424. * This is like a universal camera minus the Gamepad controls.
  8425. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8426. */
  8427. class TouchCamera extends FreeCamera {
  8428. /**
  8429. * Defines the touch sensibility for rotation.
  8430. * The higher the faster.
  8431. */
  8432. touchAngularSensibility: number;
  8433. /**
  8434. * Defines the touch sensibility for move.
  8435. * The higher the faster.
  8436. */
  8437. touchMoveSensibility: number;
  8438. /**
  8439. * Instantiates a new touch camera.
  8440. * This represents a FPS type of camera controlled by touch.
  8441. * This is like a universal camera minus the Gamepad controls.
  8442. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8443. * @param name Define the name of the camera in the scene
  8444. * @param position Define the start position of the camera in the scene
  8445. * @param scene Define the scene the camera belongs to
  8446. */
  8447. constructor(name: string, position: Vector3, scene: Scene);
  8448. /**
  8449. * Gets the current object class name.
  8450. * @return the class name
  8451. */
  8452. getClassName(): string;
  8453. /** @hidden */
  8454. _setupInputs(): void;
  8455. }
  8456. }
  8457. declare module BABYLON {
  8458. /**
  8459. * 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,
  8460. * which still works and will still be found in many Playgrounds.
  8461. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8462. */
  8463. class UniversalCamera extends TouchCamera {
  8464. /**
  8465. * Defines the gamepad rotation sensiblity.
  8466. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  8467. */
  8468. gamepadAngularSensibility: number;
  8469. /**
  8470. * Defines the gamepad move sensiblity.
  8471. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  8472. */
  8473. gamepadMoveSensibility: number;
  8474. /**
  8475. * 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,
  8476. * which still works and will still be found in many Playgrounds.
  8477. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8478. * @param name Define the name of the camera in the scene
  8479. * @param position Define the start position of the camera in the scene
  8480. * @param scene Define the scene the camera belongs to
  8481. */
  8482. constructor(name: string, position: Vector3, scene: Scene);
  8483. /**
  8484. * Gets the current object class name.
  8485. * @return the class name
  8486. */
  8487. getClassName(): string;
  8488. }
  8489. }
  8490. declare module BABYLON {
  8491. /**
  8492. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8493. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8494. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8495. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8496. */
  8497. class VirtualJoysticksCamera extends FreeCamera {
  8498. /**
  8499. * Intantiates a VirtualJoysticksCamera. It can be usefull in First Person Shooter game for instance.
  8500. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8501. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8502. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8503. * @param name Define the name of the camera in the scene
  8504. * @param position Define the start position of the camera in the scene
  8505. * @param scene Define the scene the camera belongs to
  8506. */
  8507. constructor(name: string, position: Vector3, scene: Scene);
  8508. /**
  8509. * Gets the current object class name.
  8510. * @return the class name
  8511. */
  8512. getClassName(): string;
  8513. }
  8514. }
  8515. interface VRDisplay extends EventTarget {
  8516. /**
  8517. * Dictionary of capabilities describing the VRDisplay.
  8518. */
  8519. readonly capabilities: VRDisplayCapabilities;
  8520. /**
  8521. * z-depth defining the far plane of the eye view frustum
  8522. * enables mapping of values in the render target depth
  8523. * attachment to scene coordinates. Initially set to 10000.0.
  8524. */
  8525. depthFar: number;
  8526. /**
  8527. * z-depth defining the near plane of the eye view frustum
  8528. * enables mapping of values in the render target depth
  8529. * attachment to scene coordinates. Initially set to 0.01.
  8530. */
  8531. depthNear: number;
  8532. /**
  8533. * An identifier for this distinct VRDisplay. Used as an
  8534. * association point in the Gamepad API.
  8535. */
  8536. readonly displayId: number;
  8537. /**
  8538. * A display name, a user-readable name identifying it.
  8539. */
  8540. readonly displayName: string;
  8541. readonly isConnected: boolean;
  8542. readonly isPresenting: boolean;
  8543. /**
  8544. * If this VRDisplay supports room-scale experiences, the optional
  8545. * stage attribute contains details on the room-scale parameters.
  8546. */
  8547. readonly stageParameters: VRStageParameters | null;
  8548. /**
  8549. * Passing the value returned by `requestAnimationFrame` to
  8550. * `cancelAnimationFrame` will unregister the callback.
  8551. * @param handle Define the hanle of the request to cancel
  8552. */
  8553. cancelAnimationFrame(handle: number): void;
  8554. /**
  8555. * Stops presenting to the VRDisplay.
  8556. * @returns a promise to know when it stopped
  8557. */
  8558. exitPresent(): Promise<void>;
  8559. /**
  8560. * Return the current VREyeParameters for the given eye.
  8561. * @param whichEye Define the eye we want the parameter for
  8562. * @returns the eye parameters
  8563. */
  8564. getEyeParameters(whichEye: string): VREyeParameters;
  8565. /**
  8566. * Populates the passed VRFrameData with the information required to render
  8567. * the current frame.
  8568. * @param frameData Define the data structure to populate
  8569. * @returns true if ok otherwise false
  8570. */
  8571. getFrameData(frameData: VRFrameData): boolean;
  8572. /**
  8573. * Get the layers currently being presented.
  8574. * @returns the list of VR layers
  8575. */
  8576. getLayers(): VRLayer[];
  8577. /**
  8578. * Return a VRPose containing the future predicted pose of the VRDisplay
  8579. * when the current frame will be presented. The value returned will not
  8580. * change until JavaScript has returned control to the browser.
  8581. *
  8582. * The VRPose will contain the position, orientation, velocity,
  8583. * and acceleration of each of these properties.
  8584. * @returns the pose object
  8585. */
  8586. getPose(): VRPose;
  8587. /**
  8588. * Return the current instantaneous pose of the VRDisplay, with no
  8589. * prediction applied.
  8590. * @returns the current instantaneous pose
  8591. */
  8592. getImmediatePose(): VRPose;
  8593. /**
  8594. * The callback passed to `requestAnimationFrame` will be called
  8595. * any time a new frame should be rendered. When the VRDisplay is
  8596. * presenting the callback will be called at the native refresh
  8597. * rate of the HMD. When not presenting this function acts
  8598. * identically to how window.requestAnimationFrame acts. Content should
  8599. * make no assumptions of frame rate or vsync behavior as the HMD runs
  8600. * asynchronously from other displays and at differing refresh rates.
  8601. * @param callback Define the eaction to run next frame
  8602. * @returns the request handle it
  8603. */
  8604. requestAnimationFrame(callback: FrameRequestCallback): number;
  8605. /**
  8606. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  8607. * Repeat calls while already presenting will update the VRLayers being displayed.
  8608. * @param layers Define the list of layer to present
  8609. * @returns a promise to know when the request has been fulfilled
  8610. */
  8611. requestPresent(layers: VRLayer[]): Promise<void>;
  8612. /**
  8613. * Reset the pose for this display, treating its current position and
  8614. * orientation as the "origin/zero" values. VRPose.position,
  8615. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  8616. * updated when calling resetPose(). This should be called in only
  8617. * sitting-space experiences.
  8618. */
  8619. resetPose(): void;
  8620. /**
  8621. * The VRLayer provided to the VRDisplay will be captured and presented
  8622. * in the HMD. Calling this function has the same effect on the source
  8623. * canvas as any other operation that uses its source image, and canvases
  8624. * created without preserveDrawingBuffer set to true will be cleared.
  8625. * @param pose Define the pose to submit
  8626. */
  8627. submitFrame(pose?: VRPose): void;
  8628. }
  8629. declare var VRDisplay: {
  8630. prototype: VRDisplay;
  8631. new (): VRDisplay;
  8632. };
  8633. interface VRLayer {
  8634. leftBounds?: number[] | Float32Array | null;
  8635. rightBounds?: number[] | Float32Array | null;
  8636. source?: HTMLCanvasElement | null;
  8637. }
  8638. interface VRDisplayCapabilities {
  8639. readonly canPresent: boolean;
  8640. readonly hasExternalDisplay: boolean;
  8641. readonly hasOrientation: boolean;
  8642. readonly hasPosition: boolean;
  8643. readonly maxLayers: number;
  8644. }
  8645. interface VREyeParameters {
  8646. /** @deprecated */
  8647. readonly fieldOfView: VRFieldOfView;
  8648. readonly offset: Float32Array;
  8649. readonly renderHeight: number;
  8650. readonly renderWidth: number;
  8651. }
  8652. interface VRFieldOfView {
  8653. readonly downDegrees: number;
  8654. readonly leftDegrees: number;
  8655. readonly rightDegrees: number;
  8656. readonly upDegrees: number;
  8657. }
  8658. interface VRFrameData {
  8659. readonly leftProjectionMatrix: Float32Array;
  8660. readonly leftViewMatrix: Float32Array;
  8661. readonly pose: VRPose;
  8662. readonly rightProjectionMatrix: Float32Array;
  8663. readonly rightViewMatrix: Float32Array;
  8664. readonly timestamp: number;
  8665. }
  8666. interface VRPose {
  8667. readonly angularAcceleration: Float32Array | null;
  8668. readonly angularVelocity: Float32Array | null;
  8669. readonly linearAcceleration: Float32Array | null;
  8670. readonly linearVelocity: Float32Array | null;
  8671. readonly orientation: Float32Array | null;
  8672. readonly position: Float32Array | null;
  8673. readonly timestamp: number;
  8674. }
  8675. interface VRStageParameters {
  8676. sittingToStandingTransform?: Float32Array;
  8677. sizeX?: number;
  8678. sizeY?: number;
  8679. }
  8680. interface Navigator {
  8681. getVRDisplays(): Promise<VRDisplay[]>;
  8682. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  8683. }
  8684. interface Window {
  8685. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  8686. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  8687. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  8688. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8689. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8690. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  8691. }
  8692. interface Gamepad {
  8693. readonly displayId: number;
  8694. }
  8695. declare module BABYLON {
  8696. /**
  8697. * Class used to store bounding box information
  8698. */
  8699. class BoundingBox implements ICullable {
  8700. /**
  8701. * Gets the 8 vectors representing the bounding box in local space
  8702. */
  8703. readonly vectors: Vector3[];
  8704. /**
  8705. * Gets the center of the bounding box in local space
  8706. */
  8707. readonly center: Vector3;
  8708. /**
  8709. * Gets the center of the bounding box in world space
  8710. */
  8711. readonly centerWorld: Vector3;
  8712. /**
  8713. * Gets the extend size in local space
  8714. */
  8715. readonly extendSize: Vector3;
  8716. /**
  8717. * Gets the extend size in world space
  8718. */
  8719. readonly extendSizeWorld: Vector3;
  8720. /**
  8721. * Gets the OBB (object bounding box) directions
  8722. */
  8723. readonly directions: Vector3[];
  8724. /**
  8725. * Gets the 8 vectors representing the bounding box in world space
  8726. */
  8727. readonly vectorsWorld: Vector3[];
  8728. /**
  8729. * Gets the minimum vector in world space
  8730. */
  8731. readonly minimumWorld: Vector3;
  8732. /**
  8733. * Gets the maximum vector in world space
  8734. */
  8735. readonly maximumWorld: Vector3;
  8736. /**
  8737. * Gets the minimum vector in local space
  8738. */
  8739. readonly minimum: Vector3;
  8740. /**
  8741. * Gets the maximum vector in local space
  8742. */
  8743. readonly maximum: Vector3;
  8744. private _worldMatrix;
  8745. private static readonly TmpVector3;
  8746. /**
  8747. * @hidden
  8748. */
  8749. _tag: number;
  8750. /**
  8751. * Creates a new bounding box
  8752. * @param min defines the minimum vector (in local space)
  8753. * @param max defines the maximum vector (in local space)
  8754. * @param worldMatrix defines the new world matrix
  8755. */
  8756. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  8757. /**
  8758. * Recreates the entire bounding box from scratch as if we call the constructor in place
  8759. * @param min defines the new minimum vector (in local space)
  8760. * @param max defines the new maximum vector (in local space)
  8761. * @param worldMatrix defines the new world matrix
  8762. */
  8763. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  8764. /**
  8765. * Scale the current bounding box by applying a scale factor
  8766. * @param factor defines the scale factor to apply
  8767. * @returns the current bounding box
  8768. */
  8769. scale(factor: number): BoundingBox;
  8770. /**
  8771. * Gets the world matrix of the bounding box
  8772. * @returns a matrix
  8773. */
  8774. getWorldMatrix(): DeepImmutable<Matrix>;
  8775. /** @hidden */
  8776. _update(world: DeepImmutable<Matrix>): void;
  8777. /**
  8778. * Tests if the bounding box is intersecting the frustum planes
  8779. * @param frustumPlanes defines the frustum planes to test
  8780. * @returns true if there is an intersection
  8781. */
  8782. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  8783. /**
  8784. * Tests if the bounding box is entirely inside the frustum planes
  8785. * @param frustumPlanes defines the frustum planes to test
  8786. * @returns true if there is an inclusion
  8787. */
  8788. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  8789. /**
  8790. * Tests if a point is inside the bounding box
  8791. * @param point defines the point to test
  8792. * @returns true if the point is inside the bounding box
  8793. */
  8794. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  8795. /**
  8796. * Tests if the bounding box intersects with a bounding sphere
  8797. * @param sphere defines the sphere to test
  8798. * @returns true if there is an intersection
  8799. */
  8800. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  8801. /**
  8802. * Tests if the bounding box intersects with a box defined by a min and max vectors
  8803. * @param min defines the min vector to use
  8804. * @param max defines the max vector to use
  8805. * @returns true if there is an intersection
  8806. */
  8807. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  8808. /**
  8809. * Tests if two bounding boxes are intersections
  8810. * @param box0 defines the first box to test
  8811. * @param box1 defines the second box to test
  8812. * @returns true if there is an intersection
  8813. */
  8814. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  8815. /**
  8816. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  8817. * @param minPoint defines the minimum vector of the bounding box
  8818. * @param maxPoint defines the maximum vector of the bounding box
  8819. * @param sphereCenter defines the sphere center
  8820. * @param sphereRadius defines the sphere radius
  8821. * @returns true if there is an intersection
  8822. */
  8823. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  8824. /**
  8825. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  8826. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  8827. * @param frustumPlanes defines the frustum planes to test
  8828. * @return true if there is an inclusion
  8829. */
  8830. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  8831. /**
  8832. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  8833. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  8834. * @param frustumPlanes defines the frustum planes to test
  8835. * @return true if there is an intersection
  8836. */
  8837. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  8838. }
  8839. }
  8840. declare module BABYLON {
  8841. /**
  8842. * Interface for cullable objects
  8843. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  8844. */
  8845. interface ICullable {
  8846. /**
  8847. * Checks if the object or part of the object is in the frustum
  8848. * @param frustumPlanes Camera near/planes
  8849. * @returns true if the object is in frustum otherwise false
  8850. */
  8851. isInFrustum(frustumPlanes: Plane[]): boolean;
  8852. /**
  8853. * Checks if a cullable object (mesh...) is in the camera frustum
  8854. * Unlike isInFrustum this cheks the full bounding box
  8855. * @param frustumPlanes Camera near/planes
  8856. * @returns true if the object is in frustum otherwise false
  8857. */
  8858. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  8859. }
  8860. /**
  8861. * Info for a bounding data of a mesh
  8862. */
  8863. class BoundingInfo implements ICullable {
  8864. /**
  8865. * Bounding box for the mesh
  8866. */
  8867. readonly boundingBox: BoundingBox;
  8868. /**
  8869. * Bounding sphere for the mesh
  8870. */
  8871. readonly boundingSphere: BoundingSphere;
  8872. private _isLocked;
  8873. private static readonly TmpVector3;
  8874. /**
  8875. * Constructs bounding info
  8876. * @param minimum min vector of the bounding box/sphere
  8877. * @param maximum max vector of the bounding box/sphere
  8878. * @param worldMatrix defines the new world matrix
  8879. */
  8880. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  8881. /**
  8882. * Recreates the entire bounding info from scratch as if we call the constructor in place
  8883. * @param min defines the new minimum vector (in local space)
  8884. * @param max defines the new maximum vector (in local space)
  8885. * @param worldMatrix defines the new world matrix
  8886. */
  8887. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  8888. /**
  8889. * min vector of the bounding box/sphere
  8890. */
  8891. readonly minimum: Vector3;
  8892. /**
  8893. * max vector of the bounding box/sphere
  8894. */
  8895. readonly maximum: Vector3;
  8896. /**
  8897. * If the info is locked and won't be updated to avoid perf overhead
  8898. */
  8899. isLocked: boolean;
  8900. /**
  8901. * Updates the bounding sphere and box
  8902. * @param world world matrix to be used to update
  8903. */
  8904. update(world: DeepImmutable<Matrix>): void;
  8905. /**
  8906. * Recreate the bounding info to be centered around a specific point given a specific extend.
  8907. * @param center New center of the bounding info
  8908. * @param extend New extend of the bounding info
  8909. * @returns the current bounding info
  8910. */
  8911. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  8912. /**
  8913. * Scale the current bounding info by applying a scale factor
  8914. * @param factor defines the scale factor to apply
  8915. * @returns the current bounding info
  8916. */
  8917. scale(factor: number): BoundingInfo;
  8918. /**
  8919. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  8920. * @param frustumPlanes defines the frustum to test
  8921. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  8922. * @returns true if the bounding info is in the frustum planes
  8923. */
  8924. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  8925. /**
  8926. * Gets the world distance between the min and max points of the bounding box
  8927. */
  8928. readonly diagonalLength: number;
  8929. /**
  8930. * Checks if a cullable object (mesh...) is in the camera frustum
  8931. * Unlike isInFrustum this cheks the full bounding box
  8932. * @param frustumPlanes Camera near/planes
  8933. * @returns true if the object is in frustum otherwise false
  8934. */
  8935. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  8936. /** @hidden */
  8937. _checkCollision(collider: Collider): boolean;
  8938. /**
  8939. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  8940. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  8941. * @param point the point to check intersection with
  8942. * @returns if the point intersects
  8943. */
  8944. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  8945. /**
  8946. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  8947. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  8948. * @param boundingInfo the bounding info to check intersection with
  8949. * @param precise if the intersection should be done using OBB
  8950. * @returns if the bounding info intersects
  8951. */
  8952. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  8953. }
  8954. }
  8955. declare module BABYLON {
  8956. /**
  8957. * Class used to store bounding sphere information
  8958. */
  8959. class BoundingSphere {
  8960. /**
  8961. * Gets the center of the bounding sphere in local space
  8962. */
  8963. readonly center: Vector3;
  8964. /**
  8965. * Radius of the bounding sphere in local space
  8966. */
  8967. radius: number;
  8968. /**
  8969. * Gets the center of the bounding sphere in world space
  8970. */
  8971. readonly centerWorld: Vector3;
  8972. /**
  8973. * Radius of the bounding sphere in world space
  8974. */
  8975. radiusWorld: number;
  8976. /**
  8977. * Gets the minimum vector in local space
  8978. */
  8979. readonly minimum: Vector3;
  8980. /**
  8981. * Gets the maximum vector in local space
  8982. */
  8983. readonly maximum: Vector3;
  8984. private _worldMatrix;
  8985. private static readonly TmpVector3;
  8986. /**
  8987. * Creates a new bounding sphere
  8988. * @param min defines the minimum vector (in local space)
  8989. * @param max defines the maximum vector (in local space)
  8990. * @param worldMatrix defines the new world matrix
  8991. */
  8992. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  8993. /**
  8994. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  8995. * @param min defines the new minimum vector (in local space)
  8996. * @param max defines the new maximum vector (in local space)
  8997. * @param worldMatrix defines the new world matrix
  8998. */
  8999. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  9000. /**
  9001. * Scale the current bounding sphere by applying a scale factor
  9002. * @param factor defines the scale factor to apply
  9003. * @returns the current bounding box
  9004. */
  9005. scale(factor: number): BoundingSphere;
  9006. /**
  9007. * Gets the world matrix of the bounding box
  9008. * @returns a matrix
  9009. */
  9010. getWorldMatrix(): DeepImmutable<Matrix>;
  9011. /** @hidden */
  9012. _update(worldMatrix: DeepImmutable<Matrix>): void;
  9013. /**
  9014. * Tests if the bounding sphere is intersecting the frustum planes
  9015. * @param frustumPlanes defines the frustum planes to test
  9016. * @returns true if there is an intersection
  9017. */
  9018. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9019. /**
  9020. * Tests if a point is inside the bounding sphere
  9021. * @param point defines the point to test
  9022. * @returns true if the point is inside the bounding sphere
  9023. */
  9024. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  9025. /**
  9026. * Checks if two sphere intersct
  9027. * @param sphere0 sphere 0
  9028. * @param sphere1 sphere 1
  9029. * @returns true if the speres intersect
  9030. */
  9031. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  9032. }
  9033. }
  9034. declare module BABYLON {
  9035. /**
  9036. * Class representing a ray with position and direction
  9037. */
  9038. class Ray {
  9039. /** origin point */
  9040. origin: Vector3;
  9041. /** direction */
  9042. direction: Vector3;
  9043. /** length of the ray */
  9044. length: number;
  9045. private static readonly TmpVector3;
  9046. private _tmpRay;
  9047. /**
  9048. * Creates a new ray
  9049. * @param origin origin point
  9050. * @param direction direction
  9051. * @param length length of the ray
  9052. */
  9053. constructor(
  9054. /** origin point */
  9055. origin: Vector3,
  9056. /** direction */
  9057. direction: Vector3,
  9058. /** length of the ray */
  9059. length?: number);
  9060. /**
  9061. * Checks if the ray intersects a box
  9062. * @param minimum bound of the box
  9063. * @param maximum bound of the box
  9064. * @param intersectionTreshold extra extend to be added to the box in all direction
  9065. * @returns if the box was hit
  9066. */
  9067. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9068. /**
  9069. * Checks if the ray intersects a box
  9070. * @param box the bounding box to check
  9071. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9072. * @returns if the box was hit
  9073. */
  9074. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9075. /**
  9076. * If the ray hits a sphere
  9077. * @param sphere the bounding sphere to check
  9078. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9079. * @returns true if it hits the sphere
  9080. */
  9081. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9082. /**
  9083. * If the ray hits a triange
  9084. * @param vertex0 triangle vertex
  9085. * @param vertex1 triangle vertex
  9086. * @param vertex2 triangle vertex
  9087. * @returns intersection information if hit
  9088. */
  9089. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9090. /**
  9091. * Checks if ray intersects a plane
  9092. * @param plane the plane to check
  9093. * @returns the distance away it was hit
  9094. */
  9095. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9096. /**
  9097. * Checks if ray intersects a mesh
  9098. * @param mesh the mesh to check
  9099. * @param fastCheck if only the bounding box should checked
  9100. * @returns picking info of the intersecton
  9101. */
  9102. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9103. /**
  9104. * Checks if ray intersects a mesh
  9105. * @param meshes the meshes to check
  9106. * @param fastCheck if only the bounding box should checked
  9107. * @param results array to store result in
  9108. * @returns Array of picking infos
  9109. */
  9110. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9111. private _comparePickingInfo;
  9112. private static smallnum;
  9113. private static rayl;
  9114. /**
  9115. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9116. * @param sega the first point of the segment to test the intersection against
  9117. * @param segb the second point of the segment to test the intersection against
  9118. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9119. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9120. */
  9121. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9122. /**
  9123. * Update the ray from viewport position
  9124. * @param x position
  9125. * @param y y position
  9126. * @param viewportWidth viewport width
  9127. * @param viewportHeight viewport height
  9128. * @param world world matrix
  9129. * @param view view matrix
  9130. * @param projection projection matrix
  9131. * @returns this ray updated
  9132. */
  9133. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9134. /**
  9135. * Creates a ray with origin and direction of 0,0,0
  9136. * @returns the new ray
  9137. */
  9138. static Zero(): Ray;
  9139. /**
  9140. * Creates a new ray from screen space and viewport
  9141. * @param x position
  9142. * @param y y position
  9143. * @param viewportWidth viewport width
  9144. * @param viewportHeight viewport height
  9145. * @param world world matrix
  9146. * @param view view matrix
  9147. * @param projection projection matrix
  9148. * @returns new ray
  9149. */
  9150. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9151. /**
  9152. * 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
  9153. * transformed to the given world matrix.
  9154. * @param origin The origin point
  9155. * @param end The end point
  9156. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9157. * @returns the new ray
  9158. */
  9159. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9160. /**
  9161. * Transforms a ray by a matrix
  9162. * @param ray ray to transform
  9163. * @param matrix matrix to apply
  9164. * @returns the resulting new ray
  9165. */
  9166. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9167. /**
  9168. * Transforms a ray by a matrix
  9169. * @param ray ray to transform
  9170. * @param matrix matrix to apply
  9171. * @param result ray to store result in
  9172. */
  9173. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9174. }
  9175. }
  9176. declare module BABYLON {
  9177. /** @hidden */
  9178. class Collider {
  9179. /** Define if a collision was found */
  9180. collisionFound: boolean;
  9181. /**
  9182. * Define last intersection point in local space
  9183. */
  9184. intersectionPoint: Vector3;
  9185. /**
  9186. * Define last collided mesh
  9187. */
  9188. collidedMesh: Nullable<AbstractMesh>;
  9189. private _collisionPoint;
  9190. private _planeIntersectionPoint;
  9191. private _tempVector;
  9192. private _tempVector2;
  9193. private _tempVector3;
  9194. private _tempVector4;
  9195. private _edge;
  9196. private _baseToVertex;
  9197. private _destinationPoint;
  9198. private _slidePlaneNormal;
  9199. private _displacementVector;
  9200. /** @hidden */
  9201. _radius: Vector3;
  9202. /** @hidden */
  9203. _retry: number;
  9204. private _velocity;
  9205. private _basePoint;
  9206. private _epsilon;
  9207. /** @hidden */
  9208. _velocityWorldLength: number;
  9209. /** @hidden */
  9210. _basePointWorld: Vector3;
  9211. private _velocityWorld;
  9212. private _normalizedVelocity;
  9213. /** @hidden */
  9214. _initialVelocity: Vector3;
  9215. /** @hidden */
  9216. _initialPosition: Vector3;
  9217. private _nearestDistance;
  9218. private _collisionMask;
  9219. collisionMask: number;
  9220. /**
  9221. * Gets the plane normal used to compute the sliding response (in local space)
  9222. */
  9223. readonly slidePlaneNormal: Vector3;
  9224. /** @hidden */
  9225. _initialize(source: Vector3, dir: Vector3, e: number): void;
  9226. /** @hidden */
  9227. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  9228. /** @hidden */
  9229. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  9230. /** @hidden */
  9231. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  9232. /** @hidden */
  9233. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  9234. /** @hidden */
  9235. _getResponse(pos: Vector3, vel: Vector3): void;
  9236. }
  9237. }
  9238. declare module BABYLON {
  9239. /** @hidden */
  9240. var CollisionWorker: string;
  9241. /** @hidden */
  9242. interface ICollisionCoordinator {
  9243. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9244. init(scene: Scene): void;
  9245. destroy(): void;
  9246. onMeshAdded(mesh: AbstractMesh): void;
  9247. onMeshUpdated(mesh: AbstractMesh): void;
  9248. onMeshRemoved(mesh: AbstractMesh): void;
  9249. onGeometryAdded(geometry: Geometry): void;
  9250. onGeometryUpdated(geometry: Geometry): void;
  9251. onGeometryDeleted(geometry: Geometry): void;
  9252. }
  9253. /** @hidden */
  9254. interface SerializedMesh {
  9255. id: string;
  9256. name: string;
  9257. uniqueId: number;
  9258. geometryId: Nullable<string>;
  9259. sphereCenter: Array<number>;
  9260. sphereRadius: number;
  9261. boxMinimum: Array<number>;
  9262. boxMaximum: Array<number>;
  9263. worldMatrixFromCache: any;
  9264. subMeshes: Array<SerializedSubMesh>;
  9265. checkCollisions: boolean;
  9266. }
  9267. /** @hidden */
  9268. interface SerializedSubMesh {
  9269. position: number;
  9270. verticesStart: number;
  9271. verticesCount: number;
  9272. indexStart: number;
  9273. indexCount: number;
  9274. hasMaterial: boolean;
  9275. sphereCenter: Array<number>;
  9276. sphereRadius: number;
  9277. boxMinimum: Array<number>;
  9278. boxMaximum: Array<number>;
  9279. }
  9280. /**
  9281. * Interface describing the value associated with a geometry.
  9282. * @hidden
  9283. */
  9284. interface SerializedGeometry {
  9285. /**
  9286. * Defines the unique ID of the geometry
  9287. */
  9288. id: string;
  9289. /**
  9290. * Defines the array containing the positions
  9291. */
  9292. positions: Float32Array;
  9293. /**
  9294. * Defines the array containing the indices
  9295. */
  9296. indices: Uint32Array;
  9297. /**
  9298. * Defines the array containing the normals
  9299. */
  9300. normals: Float32Array;
  9301. }
  9302. /** @hidden */
  9303. interface BabylonMessage {
  9304. taskType: WorkerTaskType;
  9305. payload: InitPayload | CollidePayload | UpdatePayload;
  9306. }
  9307. /** @hidden */
  9308. interface SerializedColliderToWorker {
  9309. position: Array<number>;
  9310. velocity: Array<number>;
  9311. radius: Array<number>;
  9312. }
  9313. /** Defines supported task for worker process */
  9314. enum WorkerTaskType {
  9315. /** Initialization */
  9316. INIT = 0,
  9317. /** Update of geometry */
  9318. UPDATE = 1,
  9319. /** Evaluate collision */
  9320. COLLIDE = 2
  9321. }
  9322. /** @hidden */
  9323. interface WorkerReply {
  9324. error: WorkerReplyType;
  9325. taskType: WorkerTaskType;
  9326. payload?: any;
  9327. }
  9328. /** @hidden */
  9329. interface CollisionReplyPayload {
  9330. newPosition: Array<number>;
  9331. collisionId: number;
  9332. collidedMeshUniqueId: number;
  9333. }
  9334. /** @hidden */
  9335. interface InitPayload {
  9336. }
  9337. /** @hidden */
  9338. interface CollidePayload {
  9339. collisionId: number;
  9340. collider: SerializedColliderToWorker;
  9341. maximumRetry: number;
  9342. excludedMeshUniqueId: Nullable<number>;
  9343. }
  9344. /** @hidden */
  9345. interface UpdatePayload {
  9346. updatedMeshes: {
  9347. [n: number]: SerializedMesh;
  9348. };
  9349. updatedGeometries: {
  9350. [s: string]: SerializedGeometry;
  9351. };
  9352. removedMeshes: Array<number>;
  9353. removedGeometries: Array<string>;
  9354. }
  9355. /** Defines kind of replies returned by worker */
  9356. enum WorkerReplyType {
  9357. /** Success */
  9358. SUCCESS = 0,
  9359. /** Unkown error */
  9360. UNKNOWN_ERROR = 1
  9361. }
  9362. /** @hidden */
  9363. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  9364. private _scene;
  9365. private _scaledPosition;
  9366. private _scaledVelocity;
  9367. private _collisionsCallbackArray;
  9368. private _init;
  9369. private _runningUpdated;
  9370. private _worker;
  9371. private _addUpdateMeshesList;
  9372. private _addUpdateGeometriesList;
  9373. private _toRemoveMeshesArray;
  9374. private _toRemoveGeometryArray;
  9375. constructor();
  9376. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  9377. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  9378. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9379. init(scene: Scene): void;
  9380. destroy(): void;
  9381. onMeshAdded(mesh: AbstractMesh): void;
  9382. onMeshUpdated: (transformNode: TransformNode) => void;
  9383. onMeshRemoved(mesh: AbstractMesh): void;
  9384. onGeometryAdded(geometry: Geometry): void;
  9385. onGeometryUpdated: (geometry: Geometry) => void;
  9386. onGeometryDeleted(geometry: Geometry): void;
  9387. private _afterRender;
  9388. private _onMessageFromWorker;
  9389. }
  9390. /** @hidden */
  9391. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  9392. private _scene;
  9393. private _scaledPosition;
  9394. private _scaledVelocity;
  9395. private _finalPosition;
  9396. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9397. init(scene: Scene): void;
  9398. destroy(): void;
  9399. onMeshAdded(mesh: AbstractMesh): void;
  9400. onMeshUpdated(mesh: AbstractMesh): void;
  9401. onMeshRemoved(mesh: AbstractMesh): void;
  9402. onGeometryAdded(geometry: Geometry): void;
  9403. onGeometryUpdated(geometry: Geometry): void;
  9404. onGeometryDeleted(geometry: Geometry): void;
  9405. private _collideWithWorld;
  9406. }
  9407. }
  9408. declare function importScripts(...urls: string[]): void;
  9409. declare const safePostMessage: any;
  9410. declare module BABYLON {
  9411. /** @hidden */
  9412. var WorkerIncluded: boolean;
  9413. /** @hidden */
  9414. class CollisionCache {
  9415. private _meshes;
  9416. private _geometries;
  9417. getMeshes(): {
  9418. [n: number]: SerializedMesh;
  9419. };
  9420. getGeometries(): {
  9421. [s: number]: SerializedGeometry;
  9422. };
  9423. getMesh(id: any): SerializedMesh;
  9424. addMesh(mesh: SerializedMesh): void;
  9425. removeMesh(uniqueId: number): void;
  9426. getGeometry(id: string): SerializedGeometry;
  9427. addGeometry(geometry: SerializedGeometry): void;
  9428. removeGeometry(id: string): void;
  9429. }
  9430. /** @hidden */
  9431. class CollideWorker {
  9432. collider: Collider;
  9433. private _collisionCache;
  9434. private finalPosition;
  9435. private collisionsScalingMatrix;
  9436. private collisionTranformationMatrix;
  9437. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  9438. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  9439. private checkCollision;
  9440. private processCollisionsForSubMeshes;
  9441. private collideForSubMesh;
  9442. private checkSubmeshCollision;
  9443. }
  9444. /** @hidden */
  9445. interface ICollisionDetector {
  9446. onInit(payload: InitPayload): void;
  9447. onUpdate(payload: UpdatePayload): void;
  9448. onCollision(payload: CollidePayload): void;
  9449. }
  9450. /** @hidden */
  9451. class CollisionDetectorTransferable implements ICollisionDetector {
  9452. private _collisionCache;
  9453. onInit(payload: InitPayload): void;
  9454. onUpdate(payload: UpdatePayload): void;
  9455. onCollision(payload: CollidePayload): void;
  9456. }
  9457. }
  9458. declare module BABYLON {
  9459. /**
  9460. * @hidden
  9461. */
  9462. class IntersectionInfo {
  9463. bu: Nullable<number>;
  9464. bv: Nullable<number>;
  9465. distance: number;
  9466. faceId: number;
  9467. subMeshId: number;
  9468. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  9469. }
  9470. /**
  9471. * Information about the result of picking within a scene
  9472. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  9473. */
  9474. class PickingInfo {
  9475. /**
  9476. * If the pick collided with an object
  9477. */
  9478. hit: boolean;
  9479. /**
  9480. * Distance away where the pick collided
  9481. */
  9482. distance: number;
  9483. /**
  9484. * The location of pick collision
  9485. */
  9486. pickedPoint: Nullable<Vector3>;
  9487. /**
  9488. * The mesh corresponding the the pick collision
  9489. */
  9490. pickedMesh: Nullable<AbstractMesh>;
  9491. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  9492. bu: number;
  9493. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  9494. bv: number;
  9495. /** The id of the face on the mesh that was picked */
  9496. faceId: number;
  9497. /** Id of the the submesh that was picked */
  9498. subMeshId: number;
  9499. /** If a sprite was picked, this will be the sprite the pick collided with */
  9500. pickedSprite: Nullable<Sprite>;
  9501. /**
  9502. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  9503. */
  9504. originMesh: Nullable<AbstractMesh>;
  9505. /**
  9506. * The ray that was used to perform the picking.
  9507. */
  9508. ray: Nullable<Ray>;
  9509. /**
  9510. * Gets the normal correspodning to the face the pick collided with
  9511. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  9512. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  9513. * @returns The normal correspodning to the face the pick collided with
  9514. */
  9515. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  9516. /**
  9517. * Gets the texture coordinates of where the pick occured
  9518. * @returns the vector containing the coordnates of the texture
  9519. */
  9520. getTextureCoordinates(): Nullable<Vector2>;
  9521. }
  9522. }
  9523. /**
  9524. * Module Debug contains the (visual) components to debug a scene correctly
  9525. */
  9526. declare module BABYLON.Debug {
  9527. /**
  9528. * The Axes viewer will show 3 axes in a specific point in space
  9529. */
  9530. class AxesViewer {
  9531. private _xline;
  9532. private _yline;
  9533. private _zline;
  9534. private _xmesh;
  9535. private _ymesh;
  9536. private _zmesh;
  9537. /**
  9538. * Gets the hosting scene
  9539. */
  9540. scene: Nullable<Scene>;
  9541. /**
  9542. * Gets or sets a number used to scale line length
  9543. */
  9544. scaleLines: number;
  9545. /**
  9546. * Creates a new AxesViewer
  9547. * @param scene defines the hosting scene
  9548. * @param scaleLines defines a number used to scale line length (1 by default)
  9549. */
  9550. constructor(scene: Scene, scaleLines?: number);
  9551. /**
  9552. * Force the viewer to update
  9553. * @param position defines the position of the viewer
  9554. * @param xaxis defines the x axis of the viewer
  9555. * @param yaxis defines the y axis of the viewer
  9556. * @param zaxis defines the z axis of the viewer
  9557. */
  9558. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9559. /** Releases resources */
  9560. dispose(): void;
  9561. }
  9562. }
  9563. declare module BABYLON.Debug {
  9564. /**
  9565. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9566. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9567. */
  9568. class BoneAxesViewer extends AxesViewer {
  9569. /**
  9570. * Gets or sets the target mesh where to display the axes viewer
  9571. */
  9572. mesh: Nullable<Mesh>;
  9573. /**
  9574. * Gets or sets the target bone where to display the axes viewer
  9575. */
  9576. bone: Nullable<Bone>;
  9577. /** Gets current position */
  9578. pos: Vector3;
  9579. /** Gets direction of X axis */
  9580. xaxis: Vector3;
  9581. /** Gets direction of Y axis */
  9582. yaxis: Vector3;
  9583. /** Gets direction of Z axis */
  9584. zaxis: Vector3;
  9585. /**
  9586. * Creates a new BoneAxesViewer
  9587. * @param scene defines the hosting scene
  9588. * @param bone defines the target bone
  9589. * @param mesh defines the target mesh
  9590. * @param scaleLines defines a scaling factor for line length (1 by default)
  9591. */
  9592. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9593. /**
  9594. * Force the viewer to update
  9595. */
  9596. update(): void;
  9597. /** Releases resources */
  9598. dispose(): void;
  9599. }
  9600. }
  9601. declare module BABYLON {
  9602. interface Scene {
  9603. /**
  9604. * @hidden
  9605. * Backing field
  9606. */
  9607. _debugLayer: DebugLayer;
  9608. /**
  9609. * Gets the debug layer (aka Inspector) associated with the scene
  9610. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9611. */
  9612. debugLayer: DebugLayer;
  9613. }
  9614. /**
  9615. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9616. * what is happening in your scene
  9617. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9618. */
  9619. class DebugLayer {
  9620. /**
  9621. * Define the url to get the inspector script from.
  9622. * By default it uses the babylonjs CDN.
  9623. * @ignoreNaming
  9624. */
  9625. static InspectorURL: string;
  9626. private _scene;
  9627. private _inspector;
  9628. private BJSINSPECTOR;
  9629. /**
  9630. * Observable triggered when a property is changed through the inspector.
  9631. */
  9632. onPropertyChangedObservable: Observable<{
  9633. object: any;
  9634. property: string;
  9635. value: any;
  9636. initialValue: any;
  9637. }>;
  9638. /**
  9639. * Instantiates a new debug layer.
  9640. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9641. * what is happening in your scene
  9642. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9643. * @param scene Defines the scene to inspect
  9644. */
  9645. constructor(scene: Scene);
  9646. /** Creates the inspector window. */
  9647. private _createInspector;
  9648. /**
  9649. * Get if the inspector is visible or not.
  9650. * @returns true if visible otherwise, false
  9651. */
  9652. isVisible(): boolean;
  9653. /**
  9654. * Hide the inspector and close its window.
  9655. */
  9656. hide(): void;
  9657. /**
  9658. *
  9659. * Launch the debugLayer.
  9660. *
  9661. * initialTab:
  9662. * | Value | Tab Name |
  9663. * | --- | --- |
  9664. * | 0 | Scene |
  9665. * | 1 | Console |
  9666. * | 2 | Stats |
  9667. * | 3 | Textures |
  9668. * | 4 | Mesh |
  9669. * | 5 | Light |
  9670. * | 6 | Material |
  9671. * | 7 | GLTF |
  9672. * | 8 | GUI |
  9673. * | 9 | Physics |
  9674. * | 10 | Camera |
  9675. * | 11 | Audio |
  9676. *
  9677. * @param config Define the configuration of the inspector
  9678. */
  9679. show(config?: {
  9680. popup?: boolean;
  9681. initialTab?: number | string;
  9682. parentElement?: HTMLElement;
  9683. newColors?: {
  9684. backgroundColor?: string;
  9685. backgroundColorLighter?: string;
  9686. backgroundColorLighter2?: string;
  9687. backgroundColorLighter3?: string;
  9688. color?: string;
  9689. colorTop?: string;
  9690. colorBot?: string;
  9691. };
  9692. }): void;
  9693. /**
  9694. * Gets the active tab
  9695. * @return the index of the active tab or -1 if the inspector is hidden
  9696. */
  9697. getActiveTab(): number;
  9698. }
  9699. }
  9700. declare module BABYLON.Debug {
  9701. /**
  9702. * Used to show the physics impostor around the specific mesh
  9703. */
  9704. class PhysicsViewer {
  9705. /** @hidden */
  9706. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9707. /** @hidden */
  9708. protected _meshes: Array<Nullable<AbstractMesh>>;
  9709. /** @hidden */
  9710. protected _scene: Nullable<Scene>;
  9711. /** @hidden */
  9712. protected _numMeshes: number;
  9713. /** @hidden */
  9714. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9715. private _renderFunction;
  9716. private _debugBoxMesh;
  9717. private _debugSphereMesh;
  9718. private _debugMaterial;
  9719. /**
  9720. * Creates a new PhysicsViewer
  9721. * @param scene defines the hosting scene
  9722. */
  9723. constructor(scene: Scene);
  9724. /** @hidden */
  9725. protected _updateDebugMeshes(): void;
  9726. /**
  9727. * Renders a specified physic impostor
  9728. * @param impostor defines the impostor to render
  9729. */
  9730. showImpostor(impostor: PhysicsImpostor): void;
  9731. /**
  9732. * Hides a specified physic impostor
  9733. * @param impostor defines the impostor to hide
  9734. */
  9735. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9736. private _getDebugMaterial;
  9737. private _getDebugBoxMesh;
  9738. private _getDebugSphereMesh;
  9739. private _getDebugMesh;
  9740. /** Releases all resources */
  9741. dispose(): void;
  9742. }
  9743. }
  9744. declare module BABYLON {
  9745. /**
  9746. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9747. * in order to better appreciate the issue one might have.
  9748. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9749. */
  9750. class RayHelper {
  9751. /**
  9752. * Defines the ray we are currently tryin to visualize.
  9753. */
  9754. ray: Nullable<Ray>;
  9755. private _renderPoints;
  9756. private _renderLine;
  9757. private _renderFunction;
  9758. private _scene;
  9759. private _updateToMeshFunction;
  9760. private _attachedToMesh;
  9761. private _meshSpaceDirection;
  9762. private _meshSpaceOrigin;
  9763. /**
  9764. * Helper function to create a colored helper in a scene in one line.
  9765. * @param ray Defines the ray we are currently tryin to visualize
  9766. * @param scene Defines the scene the ray is used in
  9767. * @param color Defines the color we want to see the ray in
  9768. * @returns The newly created ray helper.
  9769. */
  9770. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9771. /**
  9772. * Instantiate a new ray helper.
  9773. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9774. * in order to better appreciate the issue one might have.
  9775. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9776. * @param ray Defines the ray we are currently tryin to visualize
  9777. */
  9778. constructor(ray: Ray);
  9779. /**
  9780. * Shows the ray we are willing to debug.
  9781. * @param scene Defines the scene the ray needs to be rendered in
  9782. * @param color Defines the color the ray needs to be rendered in
  9783. */
  9784. show(scene: Scene, color?: Color3): void;
  9785. /**
  9786. * Hides the ray we are debugging.
  9787. */
  9788. hide(): void;
  9789. private _render;
  9790. /**
  9791. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  9792. * @param mesh Defines the mesh we want the helper attached to
  9793. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  9794. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  9795. * @param length Defines the length of the ray
  9796. */
  9797. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9798. /**
  9799. * Detach the ray helper from the mesh it has previously been attached to.
  9800. */
  9801. detachFromMesh(): void;
  9802. private _updateToMesh;
  9803. /**
  9804. * Dispose the helper and release its associated resources.
  9805. */
  9806. dispose(): void;
  9807. }
  9808. }
  9809. declare module BABYLON.Debug {
  9810. /**
  9811. * Class used to render a debug view of a given skeleton
  9812. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9813. */
  9814. class SkeletonViewer {
  9815. /** defines the skeleton to render */
  9816. skeleton: Skeleton;
  9817. /** defines the mesh attached to the skeleton */
  9818. mesh: AbstractMesh;
  9819. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9820. autoUpdateBonesMatrices: boolean;
  9821. /** defines the rendering group id to use with the viewer */
  9822. renderingGroupId: number;
  9823. /** defines an optional utility layer to render the helper on */
  9824. utilityLayerRenderer?: UtilityLayerRenderer | undefined;
  9825. /** Gets or sets the color used to render the skeleton */
  9826. color: Color3;
  9827. private _scene;
  9828. private _debugLines;
  9829. private _debugMesh;
  9830. private _isEnabled;
  9831. private _renderFunction;
  9832. /**
  9833. * Returns the mesh used to render the bones
  9834. */
  9835. readonly debugMesh: Nullable<LinesMesh>;
  9836. /**
  9837. * Creates a new SkeletonViewer
  9838. * @param skeleton defines the skeleton to render
  9839. * @param mesh defines the mesh attached to the skeleton
  9840. * @param scene defines the hosting scene
  9841. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9842. * @param renderingGroupId defines the rendering group id to use with the viewer
  9843. * @param utilityLayerRenderer defines an optional utility layer to render the helper on
  9844. */
  9845. constructor(
  9846. /** defines the skeleton to render */
  9847. skeleton: Skeleton,
  9848. /** defines the mesh attached to the skeleton */
  9849. mesh: AbstractMesh, scene: Scene,
  9850. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9851. autoUpdateBonesMatrices?: boolean,
  9852. /** defines the rendering group id to use with the viewer */
  9853. renderingGroupId?: number,
  9854. /** defines an optional utility layer to render the helper on */
  9855. utilityLayerRenderer?: UtilityLayerRenderer | undefined);
  9856. /** Gets or sets a boolean indicating if the viewer is enabled */
  9857. isEnabled: boolean;
  9858. private _getBonePosition;
  9859. private _getLinesForBonesWithLength;
  9860. private _getLinesForBonesNoLength;
  9861. /** Update the viewer to sync with current skeleton state */
  9862. update(): void;
  9863. /** Release associated resources */
  9864. dispose(): void;
  9865. }
  9866. }
  9867. declare module BABYLON {
  9868. /**
  9869. * Interface for attribute information associated with buffer instanciation
  9870. */
  9871. class InstancingAttributeInfo {
  9872. /**
  9873. * Index/offset of the attribute in the vertex shader
  9874. */
  9875. index: number;
  9876. /**
  9877. * size of the attribute, 1, 2, 3 or 4
  9878. */
  9879. attributeSize: number;
  9880. /**
  9881. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9882. * default is FLOAT
  9883. */
  9884. attribyteType: number;
  9885. /**
  9886. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9887. */
  9888. normalized: boolean;
  9889. /**
  9890. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9891. */
  9892. offset: number;
  9893. /**
  9894. * Name of the GLSL attribute, for debugging purpose only
  9895. */
  9896. attributeName: string;
  9897. }
  9898. /**
  9899. * Define options used to create a render target texture
  9900. */
  9901. class RenderTargetCreationOptions {
  9902. /**
  9903. * Specifies is mipmaps must be generated
  9904. */
  9905. generateMipMaps?: boolean;
  9906. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9907. generateDepthBuffer?: boolean;
  9908. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9909. generateStencilBuffer?: boolean;
  9910. /** Defines texture type (int by default) */
  9911. type?: number;
  9912. /** Defines sampling mode (trilinear by default) */
  9913. samplingMode?: number;
  9914. /** Defines format (RGBA by default) */
  9915. format?: number;
  9916. }
  9917. /**
  9918. * Define options used to create a depth texture
  9919. */
  9920. class DepthTextureCreationOptions {
  9921. /** Specifies whether or not a stencil should be allocated in the texture */
  9922. generateStencil?: boolean;
  9923. /** Specifies whether or not bilinear filtering is enable on the texture */
  9924. bilinearFiltering?: boolean;
  9925. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  9926. comparisonFunction?: number;
  9927. /** Specifies if the created texture is a cube texture */
  9928. isCube?: boolean;
  9929. }
  9930. /**
  9931. * Class used to describe the capabilities of the engine relatively to the current browser
  9932. */
  9933. class EngineCapabilities {
  9934. /** Maximum textures units per fragment shader */
  9935. maxTexturesImageUnits: number;
  9936. /** Maximum texture units per vertex shader */
  9937. maxVertexTextureImageUnits: number;
  9938. /** Maximum textures units in the entire pipeline */
  9939. maxCombinedTexturesImageUnits: number;
  9940. /** Maximum texture size */
  9941. maxTextureSize: number;
  9942. /** Maximum cube texture size */
  9943. maxCubemapTextureSize: number;
  9944. /** Maximum render texture size */
  9945. maxRenderTextureSize: number;
  9946. /** Maximum number of vertex attributes */
  9947. maxVertexAttribs: number;
  9948. /** Maximum number of varyings */
  9949. maxVaryingVectors: number;
  9950. /** Maximum number of uniforms per vertex shader */
  9951. maxVertexUniformVectors: number;
  9952. /** Maximum number of uniforms per fragment shader */
  9953. maxFragmentUniformVectors: number;
  9954. /** Defines if standard derivates (dx/dy) are supported */
  9955. standardDerivatives: boolean;
  9956. /** Defines if s3tc texture compression is supported */
  9957. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  9958. /** Defines if pvrtc texture compression is supported */
  9959. pvrtc: any;
  9960. /** Defines if etc1 texture compression is supported */
  9961. etc1: any;
  9962. /** Defines if etc2 texture compression is supported */
  9963. etc2: any;
  9964. /** Defines if astc texture compression is supported */
  9965. astc: any;
  9966. /** Defines if float textures are supported */
  9967. textureFloat: boolean;
  9968. /** Defines if vertex array objects are supported */
  9969. vertexArrayObject: boolean;
  9970. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  9971. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  9972. /** Gets the maximum level of anisotropy supported */
  9973. maxAnisotropy: number;
  9974. /** Defines if instancing is supported */
  9975. instancedArrays: boolean;
  9976. /** Defines if 32 bits indices are supported */
  9977. uintIndices: boolean;
  9978. /** Defines if high precision shaders are supported */
  9979. highPrecisionShaderSupported: boolean;
  9980. /** Defines if depth reading in the fragment shader is supported */
  9981. fragmentDepthSupported: boolean;
  9982. /** Defines if float texture linear filtering is supported*/
  9983. textureFloatLinearFiltering: boolean;
  9984. /** Defines if rendering to float textures is supported */
  9985. textureFloatRender: boolean;
  9986. /** Defines if half float textures are supported*/
  9987. textureHalfFloat: boolean;
  9988. /** Defines if half float texture linear filtering is supported*/
  9989. textureHalfFloatLinearFiltering: boolean;
  9990. /** Defines if rendering to half float textures is supported */
  9991. textureHalfFloatRender: boolean;
  9992. /** Defines if textureLOD shader command is supported */
  9993. textureLOD: boolean;
  9994. /** Defines if draw buffers extension is supported */
  9995. drawBuffersExtension: boolean;
  9996. /** Defines if depth textures are supported */
  9997. depthTextureExtension: boolean;
  9998. /** Defines if float color buffer are supported */
  9999. colorBufferFloat: boolean;
  10000. /** Gets disjoint timer query extension (null if not supported) */
  10001. timerQuery: EXT_disjoint_timer_query;
  10002. /** Defines if timestamp can be used with timer query */
  10003. canUseTimestampForTimerQuery: boolean;
  10004. /** Function used to let the system compiles shaders in background */
  10005. parallelShaderCompile: {
  10006. MAX_SHADER_COMPILER_THREADS_KHR: number;
  10007. maxShaderCompilerThreadsKHR: (thread: number) => void;
  10008. COMPLETION_STATUS_KHR: number;
  10009. };
  10010. }
  10011. /** Interface defining initialization parameters for Engine class */
  10012. interface EngineOptions extends WebGLContextAttributes {
  10013. /**
  10014. * Defines if the engine should no exceed a specified device ratio
  10015. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  10016. */
  10017. limitDeviceRatio?: number;
  10018. /**
  10019. * Defines if webvr should be enabled automatically
  10020. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10021. */
  10022. autoEnableWebVR?: boolean;
  10023. /**
  10024. * Defines if webgl2 should be turned off even if supported
  10025. * @see http://doc.babylonjs.com/features/webgl2
  10026. */
  10027. disableWebGL2Support?: boolean;
  10028. /**
  10029. * Defines if webaudio should be initialized as well
  10030. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10031. */
  10032. audioEngine?: boolean;
  10033. /**
  10034. * Defines if animations should run using a deterministic lock step
  10035. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10036. */
  10037. deterministicLockstep?: boolean;
  10038. /** Defines the maximum steps to use with deterministic lock step mode */
  10039. lockstepMaxSteps?: number;
  10040. /**
  10041. * Defines that engine should ignore context lost events
  10042. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  10043. */
  10044. doNotHandleContextLost?: boolean;
  10045. }
  10046. /**
  10047. * Defines the interface used by display changed events
  10048. */
  10049. interface IDisplayChangedEventArgs {
  10050. /** Gets the vrDisplay object (if any) */
  10051. vrDisplay: Nullable<any>;
  10052. /** Gets a boolean indicating if webVR is supported */
  10053. vrSupported: boolean;
  10054. }
  10055. /**
  10056. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  10057. */
  10058. class Engine {
  10059. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  10060. static ExceptionList: ({
  10061. key: string;
  10062. capture: string;
  10063. captureConstraint: number;
  10064. targets: string[];
  10065. } | {
  10066. key: string;
  10067. capture: null;
  10068. captureConstraint: null;
  10069. targets: string[];
  10070. })[];
  10071. /** Gets the list of created engines */
  10072. static Instances: Engine[];
  10073. /**
  10074. * Gets the latest created engine
  10075. */
  10076. static readonly LastCreatedEngine: Nullable<Engine>;
  10077. /**
  10078. * Gets the latest created scene
  10079. */
  10080. static readonly LastCreatedScene: Nullable<Scene>;
  10081. /**
  10082. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  10083. * @param flag defines which part of the materials must be marked as dirty
  10084. * @param predicate defines a predicate used to filter which materials should be affected
  10085. */
  10086. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  10087. /**
  10088. * Hidden
  10089. */
  10090. static _TextureLoaders: IInternalTextureLoader[];
  10091. /** Defines that alpha blending is disabled */
  10092. static readonly ALPHA_DISABLE: number;
  10093. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  10094. static readonly ALPHA_ADD: number;
  10095. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  10096. static readonly ALPHA_COMBINE: number;
  10097. /** Defines that alpha blending to DEST - SRC * DEST */
  10098. static readonly ALPHA_SUBTRACT: number;
  10099. /** Defines that alpha blending to SRC * DEST */
  10100. static readonly ALPHA_MULTIPLY: number;
  10101. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  10102. static readonly ALPHA_MAXIMIZED: number;
  10103. /** Defines that alpha blending to SRC + DEST */
  10104. static readonly ALPHA_ONEONE: number;
  10105. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  10106. static readonly ALPHA_PREMULTIPLIED: number;
  10107. /**
  10108. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  10109. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  10110. */
  10111. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  10112. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  10113. static readonly ALPHA_INTERPOLATE: number;
  10114. /**
  10115. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  10116. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  10117. */
  10118. static readonly ALPHA_SCREENMODE: number;
  10119. /** Defines that the ressource is not delayed*/
  10120. static readonly DELAYLOADSTATE_NONE: number;
  10121. /** Defines that the ressource was successfully delay loaded */
  10122. static readonly DELAYLOADSTATE_LOADED: number;
  10123. /** Defines that the ressource is currently delay loading */
  10124. static readonly DELAYLOADSTATE_LOADING: number;
  10125. /** Defines that the ressource is delayed and has not started loading */
  10126. static readonly DELAYLOADSTATE_NOTLOADED: number;
  10127. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  10128. static readonly NEVER: number;
  10129. /** 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 */
  10130. static readonly ALWAYS: number;
  10131. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  10132. static readonly LESS: number;
  10133. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  10134. static readonly EQUAL: number;
  10135. /** 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 */
  10136. static readonly LEQUAL: number;
  10137. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  10138. static readonly GREATER: number;
  10139. /** 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 */
  10140. static readonly GEQUAL: number;
  10141. /** 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 */
  10142. static readonly NOTEQUAL: number;
  10143. /** Passed to stencilOperation to specify that stencil value must be kept */
  10144. static readonly KEEP: number;
  10145. /** Passed to stencilOperation to specify that stencil value must be replaced */
  10146. static readonly REPLACE: number;
  10147. /** Passed to stencilOperation to specify that stencil value must be incremented */
  10148. static readonly INCR: number;
  10149. /** Passed to stencilOperation to specify that stencil value must be decremented */
  10150. static readonly DECR: number;
  10151. /** Passed to stencilOperation to specify that stencil value must be inverted */
  10152. static readonly INVERT: number;
  10153. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10154. static readonly INCR_WRAP: number;
  10155. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10156. static readonly DECR_WRAP: number;
  10157. /** Texture is not repeating outside of 0..1 UVs */
  10158. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10159. /** Texture is repeating outside of 0..1 UVs */
  10160. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10161. /** Texture is repeating and mirrored */
  10162. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10163. /** ALPHA */
  10164. static readonly TEXTUREFORMAT_ALPHA: number;
  10165. /** LUMINANCE */
  10166. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10167. /** LUMINANCE_ALPHA */
  10168. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10169. /** RGB */
  10170. static readonly TEXTUREFORMAT_RGB: number;
  10171. /** RGBA */
  10172. static readonly TEXTUREFORMAT_RGBA: number;
  10173. /** RED */
  10174. static readonly TEXTUREFORMAT_RED: number;
  10175. /** RED (2nd reference) */
  10176. static readonly TEXTUREFORMAT_R: number;
  10177. /** RG */
  10178. static readonly TEXTUREFORMAT_RG: number;
  10179. /** RED_INTEGER */
  10180. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10181. /** RED_INTEGER (2nd reference) */
  10182. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10183. /** RG_INTEGER */
  10184. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10185. /** RGB_INTEGER */
  10186. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10187. /** RGBA_INTEGER */
  10188. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10189. /** UNSIGNED_BYTE */
  10190. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10191. /** UNSIGNED_BYTE (2nd reference) */
  10192. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10193. /** FLOAT */
  10194. static readonly TEXTURETYPE_FLOAT: number;
  10195. /** HALF_FLOAT */
  10196. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10197. /** BYTE */
  10198. static readonly TEXTURETYPE_BYTE: number;
  10199. /** SHORT */
  10200. static readonly TEXTURETYPE_SHORT: number;
  10201. /** UNSIGNED_SHORT */
  10202. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10203. /** INT */
  10204. static readonly TEXTURETYPE_INT: number;
  10205. /** UNSIGNED_INT */
  10206. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10207. /** UNSIGNED_SHORT_4_4_4_4 */
  10208. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10209. /** UNSIGNED_SHORT_5_5_5_1 */
  10210. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10211. /** UNSIGNED_SHORT_5_6_5 */
  10212. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10213. /** UNSIGNED_INT_2_10_10_10_REV */
  10214. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10215. /** UNSIGNED_INT_24_8 */
  10216. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10217. /** UNSIGNED_INT_10F_11F_11F_REV */
  10218. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10219. /** UNSIGNED_INT_5_9_9_9_REV */
  10220. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10221. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10222. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10223. /** nearest is mag = nearest and min = nearest and mip = linear */
  10224. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10225. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10226. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10227. /** Trilinear is mag = linear and min = linear and mip = linear */
  10228. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10229. /** nearest is mag = nearest and min = nearest and mip = linear */
  10230. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10231. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10232. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10233. /** Trilinear is mag = linear and min = linear and mip = linear */
  10234. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10235. /** mag = nearest and min = nearest and mip = nearest */
  10236. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10237. /** mag = nearest and min = linear and mip = nearest */
  10238. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10239. /** mag = nearest and min = linear and mip = linear */
  10240. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10241. /** mag = nearest and min = linear and mip = none */
  10242. static readonly TEXTURE_NEAREST_LINEAR: number;
  10243. /** mag = nearest and min = nearest and mip = none */
  10244. static readonly TEXTURE_NEAREST_NEAREST: number;
  10245. /** mag = linear and min = nearest and mip = nearest */
  10246. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10247. /** mag = linear and min = nearest and mip = linear */
  10248. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10249. /** mag = linear and min = linear and mip = none */
  10250. static readonly TEXTURE_LINEAR_LINEAR: number;
  10251. /** mag = linear and min = nearest and mip = none */
  10252. static readonly TEXTURE_LINEAR_NEAREST: number;
  10253. /** Explicit coordinates mode */
  10254. static readonly TEXTURE_EXPLICIT_MODE: number;
  10255. /** Spherical coordinates mode */
  10256. static readonly TEXTURE_SPHERICAL_MODE: number;
  10257. /** Planar coordinates mode */
  10258. static readonly TEXTURE_PLANAR_MODE: number;
  10259. /** Cubic coordinates mode */
  10260. static readonly TEXTURE_CUBIC_MODE: number;
  10261. /** Projection coordinates mode */
  10262. static readonly TEXTURE_PROJECTION_MODE: number;
  10263. /** Skybox coordinates mode */
  10264. static readonly TEXTURE_SKYBOX_MODE: number;
  10265. /** Inverse Cubic coordinates mode */
  10266. static readonly TEXTURE_INVCUBIC_MODE: number;
  10267. /** Equirectangular coordinates mode */
  10268. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10269. /** Equirectangular Fixed coordinates mode */
  10270. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10271. /** Equirectangular Fixed Mirrored coordinates mode */
  10272. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10273. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10274. static readonly SCALEMODE_FLOOR: number;
  10275. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10276. static readonly SCALEMODE_NEAREST: number;
  10277. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10278. static readonly SCALEMODE_CEILING: number;
  10279. /**
  10280. * Returns the current version of the framework
  10281. */
  10282. static readonly Version: string;
  10283. /**
  10284. * Returns a string describing the current engine
  10285. */
  10286. readonly description: string;
  10287. /**
  10288. * Gets or sets the epsilon value used by collision engine
  10289. */
  10290. static CollisionsEpsilon: number;
  10291. /**
  10292. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10293. */
  10294. static CodeRepository: string;
  10295. /**
  10296. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10297. */
  10298. static ShadersRepository: string;
  10299. /**
  10300. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10301. */
  10302. forcePOTTextures: boolean;
  10303. /**
  10304. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10305. */
  10306. isFullscreen: boolean;
  10307. /**
  10308. * Gets a boolean indicating if the pointer is currently locked
  10309. */
  10310. isPointerLock: boolean;
  10311. /**
  10312. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10313. */
  10314. cullBackFaces: boolean;
  10315. /**
  10316. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10317. */
  10318. renderEvenInBackground: boolean;
  10319. /**
  10320. * Gets or sets a boolean indicating that cache can be kept between frames
  10321. */
  10322. preventCacheWipeBetweenFrames: boolean;
  10323. /**
  10324. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10325. **/
  10326. enableOfflineSupport: boolean;
  10327. /**
  10328. * 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)
  10329. **/
  10330. disableManifestCheck: boolean;
  10331. /**
  10332. * Gets the list of created scenes
  10333. */
  10334. scenes: Scene[];
  10335. /**
  10336. * Event raised when a new scene is created
  10337. */
  10338. onNewSceneAddedObservable: Observable<Scene>;
  10339. /**
  10340. * Gets the list of created postprocesses
  10341. */
  10342. postProcesses: PostProcess[];
  10343. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10344. validateShaderPrograms: boolean;
  10345. /**
  10346. * Observable event triggered each time the rendering canvas is resized
  10347. */
  10348. onResizeObservable: Observable<Engine>;
  10349. /**
  10350. * Observable event triggered each time the canvas loses focus
  10351. */
  10352. onCanvasBlurObservable: Observable<Engine>;
  10353. /**
  10354. * Observable event triggered each time the canvas gains focus
  10355. */
  10356. onCanvasFocusObservable: Observable<Engine>;
  10357. /**
  10358. * Observable event triggered each time the canvas receives pointerout event
  10359. */
  10360. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10361. /**
  10362. * Observable event triggered before each texture is initialized
  10363. */
  10364. onBeforeTextureInitObservable: Observable<Texture>;
  10365. private _vrDisplay;
  10366. private _vrSupported;
  10367. private _oldSize;
  10368. private _oldHardwareScaleFactor;
  10369. private _vrExclusivePointerMode;
  10370. private _webVRInitPromise;
  10371. /**
  10372. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10373. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10374. */
  10375. readonly isInVRExclusivePointerMode: boolean;
  10376. /**
  10377. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10378. */
  10379. disableUniformBuffers: boolean;
  10380. /** @hidden */
  10381. _uniformBuffers: UniformBuffer[];
  10382. /**
  10383. * Gets a boolean indicating that the engine supports uniform buffers
  10384. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10385. */
  10386. readonly supportsUniformBuffers: boolean;
  10387. /**
  10388. * Observable raised when the engine begins a new frame
  10389. */
  10390. onBeginFrameObservable: Observable<Engine>;
  10391. /**
  10392. * If set, will be used to request the next animation frame for the render loop
  10393. */
  10394. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  10395. /**
  10396. * Observable raised when the engine ends the current frame
  10397. */
  10398. onEndFrameObservable: Observable<Engine>;
  10399. /**
  10400. * Observable raised when the engine is about to compile a shader
  10401. */
  10402. onBeforeShaderCompilationObservable: Observable<Engine>;
  10403. /**
  10404. * Observable raised when the engine has jsut compiled a shader
  10405. */
  10406. onAfterShaderCompilationObservable: Observable<Engine>;
  10407. /** @hidden */
  10408. _gl: WebGLRenderingContext;
  10409. private _renderingCanvas;
  10410. private _windowIsBackground;
  10411. private _webGLVersion;
  10412. /**
  10413. * Gets a boolean indicating that only power of 2 textures are supported
  10414. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10415. */
  10416. readonly needPOTTextures: boolean;
  10417. /** @hidden */
  10418. _badOS: boolean;
  10419. /** @hidden */
  10420. _badDesktopOS: boolean;
  10421. /**
  10422. * Gets or sets a value indicating if we want to disable texture binding optimization.
  10423. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10424. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10425. */
  10426. disableTextureBindingOptimization: boolean;
  10427. /**
  10428. * Gets the audio engine
  10429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10430. * @ignorenaming
  10431. */
  10432. static audioEngine: IAudioEngine;
  10433. /**
  10434. * Default AudioEngine factory responsible of creating the Audio Engine.
  10435. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  10436. */
  10437. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10438. /**
  10439. * Default offline support factory responsible of creating a tool used to store data locally.
  10440. * By default, this will create a Database object if the workload has been embedded.
  10441. */
  10442. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  10443. private _onFocus;
  10444. private _onBlur;
  10445. private _onCanvasPointerOut;
  10446. private _onCanvasBlur;
  10447. private _onCanvasFocus;
  10448. private _onFullscreenChange;
  10449. private _onPointerLockChange;
  10450. private _onVRDisplayPointerRestricted;
  10451. private _onVRDisplayPointerUnrestricted;
  10452. private _onVrDisplayConnect;
  10453. private _onVrDisplayDisconnect;
  10454. private _onVrDisplayPresentChange;
  10455. /**
  10456. * Observable signaled when VR display mode changes
  10457. */
  10458. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10459. /**
  10460. * Observable signaled when VR request present is complete
  10461. */
  10462. onVRRequestPresentComplete: Observable<boolean>;
  10463. /**
  10464. * Observable signaled when VR request present starts
  10465. */
  10466. onVRRequestPresentStart: Observable<Engine>;
  10467. private _hardwareScalingLevel;
  10468. /** @hidden */
  10469. protected _caps: EngineCapabilities;
  10470. private _pointerLockRequested;
  10471. private _isStencilEnable;
  10472. private _colorWrite;
  10473. private _loadingScreen;
  10474. /** @hidden */
  10475. _drawCalls: PerfCounter;
  10476. /** @hidden */
  10477. _textureCollisions: PerfCounter;
  10478. private _glVersion;
  10479. private _glRenderer;
  10480. private _glVendor;
  10481. private _videoTextureSupported;
  10482. private _renderingQueueLaunched;
  10483. private _activeRenderLoops;
  10484. private _deterministicLockstep;
  10485. private _lockstepMaxSteps;
  10486. /**
  10487. * Observable signaled when a context lost event is raised
  10488. */
  10489. onContextLostObservable: Observable<Engine>;
  10490. /**
  10491. * Observable signaled when a context restored event is raised
  10492. */
  10493. onContextRestoredObservable: Observable<Engine>;
  10494. private _onContextLost;
  10495. private _onContextRestored;
  10496. private _contextWasLost;
  10497. private _doNotHandleContextLost;
  10498. /**
  10499. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10500. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10501. */
  10502. doNotHandleContextLost: boolean;
  10503. private _performanceMonitor;
  10504. private _fps;
  10505. private _deltaTime;
  10506. /**
  10507. * Turn this value on if you want to pause FPS computation when in background
  10508. */
  10509. disablePerformanceMonitorInBackground: boolean;
  10510. /**
  10511. * Gets the performance monitor attached to this engine
  10512. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10513. */
  10514. readonly performanceMonitor: PerformanceMonitor;
  10515. /** @hidden */
  10516. protected _depthCullingState: _DepthCullingState;
  10517. /** @hidden */
  10518. protected _stencilState: _StencilState;
  10519. /** @hidden */
  10520. protected _alphaState: _AlphaState;
  10521. /** @hidden */
  10522. protected _alphaMode: number;
  10523. protected _internalTexturesCache: InternalTexture[];
  10524. /** @hidden */
  10525. protected _activeChannel: number;
  10526. private _currentTextureChannel;
  10527. /** @hidden */
  10528. protected _boundTexturesCache: {
  10529. [key: string]: Nullable<InternalTexture>;
  10530. };
  10531. /** @hidden */
  10532. protected _currentEffect: Nullable<Effect>;
  10533. /** @hidden */
  10534. protected _currentProgram: Nullable<WebGLProgram>;
  10535. private _compiledEffects;
  10536. private _vertexAttribArraysEnabled;
  10537. /** @hidden */
  10538. protected _cachedViewport: Nullable<Viewport>;
  10539. private _cachedVertexArrayObject;
  10540. /** @hidden */
  10541. protected _cachedVertexBuffers: any;
  10542. /** @hidden */
  10543. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10544. /** @hidden */
  10545. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10546. /** @hidden */
  10547. protected _currentRenderTarget: Nullable<InternalTexture>;
  10548. private _uintIndicesCurrentlySet;
  10549. private _currentBoundBuffer;
  10550. /** @hidden */
  10551. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10552. private _currentBufferPointers;
  10553. private _currentInstanceLocations;
  10554. private _currentInstanceBuffers;
  10555. private _textureUnits;
  10556. private _firstBoundInternalTextureTracker;
  10557. private _lastBoundInternalTextureTracker;
  10558. private _workingCanvas;
  10559. private _workingContext;
  10560. private _rescalePostProcess;
  10561. private _dummyFramebuffer;
  10562. private _externalData;
  10563. private _bindedRenderFunction;
  10564. private _vaoRecordInProgress;
  10565. private _mustWipeVertexAttributes;
  10566. private _emptyTexture;
  10567. private _emptyCubeTexture;
  10568. private _emptyTexture3D;
  10569. /** @hidden */
  10570. _frameHandler: number;
  10571. private _nextFreeTextureSlots;
  10572. private _maxSimultaneousTextures;
  10573. private _activeRequests;
  10574. private _texturesSupported;
  10575. private _textureFormatInUse;
  10576. /**
  10577. * Gets the list of texture formats supported
  10578. */
  10579. readonly texturesSupported: Array<string>;
  10580. /**
  10581. * Gets the list of texture formats in use
  10582. */
  10583. readonly textureFormatInUse: Nullable<string>;
  10584. /**
  10585. * Gets the current viewport
  10586. */
  10587. readonly currentViewport: Nullable<Viewport>;
  10588. /**
  10589. * Gets the default empty texture
  10590. */
  10591. readonly emptyTexture: InternalTexture;
  10592. /**
  10593. * Gets the default empty 3D texture
  10594. */
  10595. readonly emptyTexture3D: InternalTexture;
  10596. /**
  10597. * Gets the default empty cube texture
  10598. */
  10599. readonly emptyCubeTexture: InternalTexture;
  10600. /**
  10601. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10602. */
  10603. readonly premultipliedAlpha: boolean;
  10604. /**
  10605. * Creates a new engine
  10606. * @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
  10607. * @param antialias defines enable antialiasing (default: false)
  10608. * @param options defines further options to be sent to the getContext() function
  10609. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10610. */
  10611. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10612. private _rebuildInternalTextures;
  10613. private _rebuildEffects;
  10614. /**
  10615. * Gets a boolean indicating if all created effects are ready
  10616. * @returns true if all effects are ready
  10617. */
  10618. areAllEffectsReady(): boolean;
  10619. private _rebuildBuffers;
  10620. private _initGLContext;
  10621. /**
  10622. * Gets version of the current webGL context
  10623. */
  10624. readonly webGLVersion: number;
  10625. /**
  10626. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10627. */
  10628. readonly isStencilEnable: boolean;
  10629. private _prepareWorkingCanvas;
  10630. /**
  10631. * Reset the texture cache to empty state
  10632. */
  10633. resetTextureCache(): void;
  10634. /**
  10635. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10636. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10637. * @returns true if engine is in deterministic lock step mode
  10638. */
  10639. isDeterministicLockStep(): boolean;
  10640. /**
  10641. * Gets the max steps when engine is running in deterministic lock step
  10642. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10643. * @returns the max steps
  10644. */
  10645. getLockstepMaxSteps(): number;
  10646. /**
  10647. * Gets an object containing information about the current webGL context
  10648. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10649. */
  10650. getGlInfo(): {
  10651. vendor: string;
  10652. renderer: string;
  10653. version: string;
  10654. };
  10655. /**
  10656. * Gets current aspect ratio
  10657. * @param camera defines the camera to use to get the aspect ratio
  10658. * @param useScreen defines if screen size must be used (or the current render target if any)
  10659. * @returns a number defining the aspect ratio
  10660. */
  10661. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10662. /**
  10663. * Gets current screen aspect ratio
  10664. * @returns a number defining the aspect ratio
  10665. */
  10666. getScreenAspectRatio(): number;
  10667. /**
  10668. * Gets the current render width
  10669. * @param useScreen defines if screen size must be used (or the current render target if any)
  10670. * @returns a number defining the current render width
  10671. */
  10672. getRenderWidth(useScreen?: boolean): number;
  10673. /**
  10674. * Gets the current render height
  10675. * @param useScreen defines if screen size must be used (or the current render target if any)
  10676. * @returns a number defining the current render height
  10677. */
  10678. getRenderHeight(useScreen?: boolean): number;
  10679. /**
  10680. * Gets the HTML canvas attached with the current webGL context
  10681. * @returns a HTML canvas
  10682. */
  10683. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10684. /**
  10685. * Gets the client rect of the HTML canvas attached with the current webGL context
  10686. * @returns a client rectanglee
  10687. */
  10688. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10689. /**
  10690. * Defines the hardware scaling level.
  10691. * By default the hardware scaling level is computed from the window device ratio.
  10692. * 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.
  10693. * @param level defines the level to use
  10694. */
  10695. setHardwareScalingLevel(level: number): void;
  10696. /**
  10697. * Gets the current hardware scaling level.
  10698. * By default the hardware scaling level is computed from the window device ratio.
  10699. * 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.
  10700. * @returns a number indicating the current hardware scaling level
  10701. */
  10702. getHardwareScalingLevel(): number;
  10703. /**
  10704. * Gets the list of loaded textures
  10705. * @returns an array containing all loaded textures
  10706. */
  10707. getLoadedTexturesCache(): InternalTexture[];
  10708. /**
  10709. * Gets the object containing all engine capabilities
  10710. * @returns the EngineCapabilities object
  10711. */
  10712. getCaps(): EngineCapabilities;
  10713. /**
  10714. * Gets the current depth function
  10715. * @returns a number defining the depth function
  10716. */
  10717. getDepthFunction(): Nullable<number>;
  10718. /**
  10719. * Sets the current depth function
  10720. * @param depthFunc defines the function to use
  10721. */
  10722. setDepthFunction(depthFunc: number): void;
  10723. /**
  10724. * Sets the current depth function to GREATER
  10725. */
  10726. setDepthFunctionToGreater(): void;
  10727. /**
  10728. * Sets the current depth function to GEQUAL
  10729. */
  10730. setDepthFunctionToGreaterOrEqual(): void;
  10731. /**
  10732. * Sets the current depth function to LESS
  10733. */
  10734. setDepthFunctionToLess(): void;
  10735. /**
  10736. * Sets the current depth function to LEQUAL
  10737. */
  10738. setDepthFunctionToLessOrEqual(): void;
  10739. /**
  10740. * Gets a boolean indicating if stencil buffer is enabled
  10741. * @returns the current stencil buffer state
  10742. */
  10743. getStencilBuffer(): boolean;
  10744. /**
  10745. * Enable or disable the stencil buffer
  10746. * @param enable defines if the stencil buffer must be enabled or disabled
  10747. */
  10748. setStencilBuffer(enable: boolean): void;
  10749. /**
  10750. * Gets the current stencil mask
  10751. * @returns a number defining the new stencil mask to use
  10752. */
  10753. getStencilMask(): number;
  10754. /**
  10755. * Sets the current stencil mask
  10756. * @param mask defines the new stencil mask to use
  10757. */
  10758. setStencilMask(mask: number): void;
  10759. /**
  10760. * Gets the current stencil function
  10761. * @returns a number defining the stencil function to use
  10762. */
  10763. getStencilFunction(): number;
  10764. /**
  10765. * Gets the current stencil reference value
  10766. * @returns a number defining the stencil reference value to use
  10767. */
  10768. getStencilFunctionReference(): number;
  10769. /**
  10770. * Gets the current stencil mask
  10771. * @returns a number defining the stencil mask to use
  10772. */
  10773. getStencilFunctionMask(): number;
  10774. /**
  10775. * Sets the current stencil function
  10776. * @param stencilFunc defines the new stencil function to use
  10777. */
  10778. setStencilFunction(stencilFunc: number): void;
  10779. /**
  10780. * Sets the current stencil reference
  10781. * @param reference defines the new stencil reference to use
  10782. */
  10783. setStencilFunctionReference(reference: number): void;
  10784. /**
  10785. * Sets the current stencil mask
  10786. * @param mask defines the new stencil mask to use
  10787. */
  10788. setStencilFunctionMask(mask: number): void;
  10789. /**
  10790. * Gets the current stencil operation when stencil fails
  10791. * @returns a number defining stencil operation to use when stencil fails
  10792. */
  10793. getStencilOperationFail(): number;
  10794. /**
  10795. * Gets the current stencil operation when depth fails
  10796. * @returns a number defining stencil operation to use when depth fails
  10797. */
  10798. getStencilOperationDepthFail(): number;
  10799. /**
  10800. * Gets the current stencil operation when stencil passes
  10801. * @returns a number defining stencil operation to use when stencil passes
  10802. */
  10803. getStencilOperationPass(): number;
  10804. /**
  10805. * Sets the stencil operation to use when stencil fails
  10806. * @param operation defines the stencil operation to use when stencil fails
  10807. */
  10808. setStencilOperationFail(operation: number): void;
  10809. /**
  10810. * Sets the stencil operation to use when depth fails
  10811. * @param operation defines the stencil operation to use when depth fails
  10812. */
  10813. setStencilOperationDepthFail(operation: number): void;
  10814. /**
  10815. * Sets the stencil operation to use when stencil passes
  10816. * @param operation defines the stencil operation to use when stencil passes
  10817. */
  10818. setStencilOperationPass(operation: number): void;
  10819. /**
  10820. * Sets a boolean indicating if the dithering state is enabled or disabled
  10821. * @param value defines the dithering state
  10822. */
  10823. setDitheringState(value: boolean): void;
  10824. /**
  10825. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10826. * @param value defines the rasterizer state
  10827. */
  10828. setRasterizerState(value: boolean): void;
  10829. /**
  10830. * stop executing a render loop function and remove it from the execution array
  10831. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10832. */
  10833. stopRenderLoop(renderFunction?: () => void): void;
  10834. /** @hidden */
  10835. _renderLoop(): void;
  10836. /**
  10837. * Register and execute a render loop. The engine can have more than one render function
  10838. * @param renderFunction defines the function to continuously execute
  10839. */
  10840. runRenderLoop(renderFunction: () => void): void;
  10841. /**
  10842. * Toggle full screen mode
  10843. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10844. */
  10845. switchFullscreen(requestPointerLock: boolean): void;
  10846. /**
  10847. * Clear the current render buffer or the current render target (if any is set up)
  10848. * @param color defines the color to use
  10849. * @param backBuffer defines if the back buffer must be cleared
  10850. * @param depth defines if the depth buffer must be cleared
  10851. * @param stencil defines if the stencil buffer must be cleared
  10852. */
  10853. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10854. /**
  10855. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10856. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10857. * @param y defines the y-coordinate of the corner of the clear rectangle
  10858. * @param width defines the width of the clear rectangle
  10859. * @param height defines the height of the clear rectangle
  10860. * @param clearColor defines the clear color
  10861. */
  10862. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10863. private _viewportCached;
  10864. /** @hidden */
  10865. _viewport(x: number, y: number, width: number, height: number): void;
  10866. /**
  10867. * Set the WebGL's viewport
  10868. * @param viewport defines the viewport element to be used
  10869. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10870. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10871. */
  10872. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10873. /**
  10874. * Directly set the WebGL Viewport
  10875. * @param x defines the x coordinate of the viewport (in screen space)
  10876. * @param y defines the y coordinate of the viewport (in screen space)
  10877. * @param width defines the width of the viewport (in screen space)
  10878. * @param height defines the height of the viewport (in screen space)
  10879. * @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
  10880. */
  10881. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10882. /**
  10883. * Begin a new frame
  10884. */
  10885. beginFrame(): void;
  10886. /**
  10887. * Enf the current frame
  10888. */
  10889. endFrame(): void;
  10890. /**
  10891. * Resize the view according to the canvas' size
  10892. */
  10893. resize(): void;
  10894. /**
  10895. * Force a specific size of the canvas
  10896. * @param width defines the new canvas' width
  10897. * @param height defines the new canvas' height
  10898. */
  10899. setSize(width: number, height: number): void;
  10900. /**
  10901. * Gets a boolean indicating if a webVR device was detected
  10902. * @returns true if a webVR device was detected
  10903. */
  10904. isVRDevicePresent(): boolean;
  10905. /**
  10906. * Gets the current webVR device
  10907. * @returns the current webVR device (or null)
  10908. */
  10909. getVRDevice(): any;
  10910. /**
  10911. * Initializes a webVR display and starts listening to display change events
  10912. * The onVRDisplayChangedObservable will be notified upon these changes
  10913. * @returns The onVRDisplayChangedObservable
  10914. */
  10915. initWebVR(): Observable<IDisplayChangedEventArgs>;
  10916. /**
  10917. * Initializes a webVR display and starts listening to display change events
  10918. * The onVRDisplayChangedObservable will be notified upon these changes
  10919. * @returns A promise containing a VRDisplay and if vr is supported
  10920. */
  10921. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  10922. /**
  10923. * Call this function to switch to webVR mode
  10924. * Will do nothing if webVR is not supported or if there is no webVR device
  10925. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10926. */
  10927. enableVR(): void;
  10928. /**
  10929. * Call this function to leave webVR mode
  10930. * Will do nothing if webVR is not supported or if there is no webVR device
  10931. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10932. */
  10933. disableVR(): void;
  10934. private _onVRFullScreenTriggered;
  10935. private _getVRDisplaysAsync;
  10936. /**
  10937. * Binds the frame buffer to the specified texture.
  10938. * @param texture The texture to render to or null for the default canvas
  10939. * @param faceIndex The face of the texture to render to in case of cube texture
  10940. * @param requiredWidth The width of the target to render to
  10941. * @param requiredHeight The height of the target to render to
  10942. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  10943. * @param depthStencilTexture The depth stencil texture to use to render
  10944. * @param lodLevel defines le lod level to bind to the frame buffer
  10945. */
  10946. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  10947. private bindUnboundFramebuffer;
  10948. /**
  10949. * Unbind the current render target texture from the webGL context
  10950. * @param texture defines the render target texture to unbind
  10951. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10952. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10953. */
  10954. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10955. /**
  10956. * Unbind a list of render target textures from the webGL context
  10957. * This is used only when drawBuffer extension or webGL2 are active
  10958. * @param textures defines the render target textures to unbind
  10959. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10960. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10961. */
  10962. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10963. /**
  10964. * Force the mipmap generation for the given render target texture
  10965. * @param texture defines the render target texture to use
  10966. */
  10967. generateMipMapsForCubemap(texture: InternalTexture): void;
  10968. /**
  10969. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  10970. */
  10971. flushFramebuffer(): void;
  10972. /**
  10973. * Unbind the current render target and bind the default framebuffer
  10974. */
  10975. restoreDefaultFramebuffer(): void;
  10976. /**
  10977. * Create an uniform buffer
  10978. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10979. * @param elements defines the content of the uniform buffer
  10980. * @returns the webGL uniform buffer
  10981. */
  10982. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  10983. /**
  10984. * Create a dynamic uniform buffer
  10985. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10986. * @param elements defines the content of the uniform buffer
  10987. * @returns the webGL uniform buffer
  10988. */
  10989. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  10990. /**
  10991. * Update an existing uniform buffer
  10992. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10993. * @param uniformBuffer defines the target uniform buffer
  10994. * @param elements defines the content to update
  10995. * @param offset defines the offset in the uniform buffer where update should start
  10996. * @param count defines the size of the data to update
  10997. */
  10998. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  10999. private _resetVertexBufferBinding;
  11000. /**
  11001. * Creates a vertex buffer
  11002. * @param data the data for the vertex buffer
  11003. * @returns the new WebGL static buffer
  11004. */
  11005. createVertexBuffer(data: DataArray): WebGLBuffer;
  11006. /**
  11007. * Creates a dynamic vertex buffer
  11008. * @param data the data for the dynamic vertex buffer
  11009. * @returns the new WebGL dynamic buffer
  11010. */
  11011. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  11012. /**
  11013. * Update a dynamic index buffer
  11014. * @param indexBuffer defines the target index buffer
  11015. * @param indices defines the data to update
  11016. * @param offset defines the offset in the target index buffer where update should start
  11017. */
  11018. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11019. /**
  11020. * Updates a dynamic vertex buffer.
  11021. * @param vertexBuffer the vertex buffer to update
  11022. * @param data the data used to update the vertex buffer
  11023. * @param byteOffset the byte offset of the data
  11024. * @param byteLength the byte length of the data
  11025. */
  11026. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11027. private _resetIndexBufferBinding;
  11028. /**
  11029. * Creates a new index buffer
  11030. * @param indices defines the content of the index buffer
  11031. * @param updatable defines if the index buffer must be updatable
  11032. * @returns a new webGL buffer
  11033. */
  11034. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  11035. /**
  11036. * Bind a webGL buffer to the webGL context
  11037. * @param buffer defines the buffer to bind
  11038. */
  11039. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  11040. /**
  11041. * Bind an uniform buffer to the current webGL context
  11042. * @param buffer defines the buffer to bind
  11043. */
  11044. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  11045. /**
  11046. * Bind a buffer to the current webGL context at a given location
  11047. * @param buffer defines the buffer to bind
  11048. * @param location defines the index where to bind the buffer
  11049. */
  11050. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  11051. /**
  11052. * Bind a specific block at a given index in a specific shader program
  11053. * @param shaderProgram defines the shader program
  11054. * @param blockName defines the block name
  11055. * @param index defines the index where to bind the block
  11056. */
  11057. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  11058. private bindIndexBuffer;
  11059. private bindBuffer;
  11060. /**
  11061. * update the bound buffer with the given data
  11062. * @param data defines the data to update
  11063. */
  11064. updateArrayBuffer(data: Float32Array): void;
  11065. private _vertexAttribPointer;
  11066. private _bindIndexBufferWithCache;
  11067. private _bindVertexBuffersAttributes;
  11068. /**
  11069. * Records a vertex array object
  11070. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11071. * @param vertexBuffers defines the list of vertex buffers to store
  11072. * @param indexBuffer defines the index buffer to store
  11073. * @param effect defines the effect to store
  11074. * @returns the new vertex array object
  11075. */
  11076. recordVertexArrayObject(vertexBuffers: {
  11077. [key: string]: VertexBuffer;
  11078. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  11079. /**
  11080. * Bind a specific vertex array object
  11081. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11082. * @param vertexArrayObject defines the vertex array object to bind
  11083. * @param indexBuffer defines the index buffer to bind
  11084. */
  11085. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  11086. /**
  11087. * Bind webGl buffers directly to the webGL context
  11088. * @param vertexBuffer defines the vertex buffer to bind
  11089. * @param indexBuffer defines the index buffer to bind
  11090. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  11091. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  11092. * @param effect defines the effect associated with the vertex buffer
  11093. */
  11094. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  11095. private _unbindVertexArrayObject;
  11096. /**
  11097. * Bind a list of vertex buffers to the webGL context
  11098. * @param vertexBuffers defines the list of vertex buffers to bind
  11099. * @param indexBuffer defines the index buffer to bind
  11100. * @param effect defines the effect associated with the vertex buffers
  11101. */
  11102. bindBuffers(vertexBuffers: {
  11103. [key: string]: Nullable<VertexBuffer>;
  11104. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  11105. /**
  11106. * Unbind all instance attributes
  11107. */
  11108. unbindInstanceAttributes(): void;
  11109. /**
  11110. * Release and free the memory of a vertex array object
  11111. * @param vao defines the vertex array object to delete
  11112. */
  11113. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  11114. /** @hidden */
  11115. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11116. /**
  11117. * Creates a webGL buffer to use with instanciation
  11118. * @param capacity defines the size of the buffer
  11119. * @returns the webGL buffer
  11120. */
  11121. createInstancesBuffer(capacity: number): WebGLBuffer;
  11122. /**
  11123. * Delete a webGL buffer used with instanciation
  11124. * @param buffer defines the webGL buffer to delete
  11125. */
  11126. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  11127. /**
  11128. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  11129. * @param instancesBuffer defines the webGL buffer to update and bind
  11130. * @param data defines the data to store in the buffer
  11131. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  11132. */
  11133. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  11134. /**
  11135. * Apply all cached states (depth, culling, stencil and alpha)
  11136. */
  11137. applyStates(): void;
  11138. /**
  11139. * Send a draw order
  11140. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11141. * @param indexStart defines the starting index
  11142. * @param indexCount defines the number of index to draw
  11143. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11144. */
  11145. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11146. /**
  11147. * Draw a list of points
  11148. * @param verticesStart defines the index of first vertex to draw
  11149. * @param verticesCount defines the count of vertices to draw
  11150. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11151. */
  11152. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11153. /**
  11154. * Draw a list of unindexed primitives
  11155. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11156. * @param verticesStart defines the index of first vertex to draw
  11157. * @param verticesCount defines the count of vertices to draw
  11158. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11159. */
  11160. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11161. /**
  11162. * Draw a list of indexed primitives
  11163. * @param fillMode defines the primitive to use
  11164. * @param indexStart defines the starting index
  11165. * @param indexCount defines the number of index to draw
  11166. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11167. */
  11168. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11169. /**
  11170. * Draw a list of unindexed primitives
  11171. * @param fillMode defines the primitive to use
  11172. * @param verticesStart defines the index of first vertex to draw
  11173. * @param verticesCount defines the count of vertices to draw
  11174. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11175. */
  11176. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11177. private _drawMode;
  11178. /** @hidden */
  11179. _releaseEffect(effect: Effect): void;
  11180. /** @hidden */
  11181. _deleteProgram(program: WebGLProgram): void;
  11182. /**
  11183. * Create a new effect (used to store vertex/fragment shaders)
  11184. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11185. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11186. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11187. * @param samplers defines an array of string used to represent textures
  11188. * @param defines defines the string containing the defines to use to compile the shaders
  11189. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11190. * @param onCompiled defines a function to call when the effect creation is successful
  11191. * @param onError defines a function to call when the effect creation has failed
  11192. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11193. * @returns the new Effect
  11194. */
  11195. 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;
  11196. private _compileShader;
  11197. private _compileRawShader;
  11198. /**
  11199. * Directly creates a webGL program
  11200. * @param vertexCode defines the vertex shader code to use
  11201. * @param fragmentCode defines the fragment shader code to use
  11202. * @param context defines the webGL context to use (if not set, the current one will be used)
  11203. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11204. * @returns the new webGL program
  11205. */
  11206. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11207. /**
  11208. * Creates a webGL program
  11209. * @param vertexCode defines the vertex shader code to use
  11210. * @param fragmentCode defines the fragment shader code to use
  11211. * @param defines defines the string containing the defines to use to compile the shaders
  11212. * @param context defines the webGL context to use (if not set, the current one will be used)
  11213. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11214. * @returns the new webGL program
  11215. */
  11216. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11217. private _createShaderProgram;
  11218. private _finalizeProgram;
  11219. /** @hidden */
  11220. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11221. /** @hidden */
  11222. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11223. /**
  11224. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11225. * @param shaderProgram defines the webGL program to use
  11226. * @param uniformsNames defines the list of uniform names
  11227. * @returns an array of webGL uniform locations
  11228. */
  11229. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11230. /**
  11231. * Gets the lsit of active attributes for a given webGL program
  11232. * @param shaderProgram defines the webGL program to use
  11233. * @param attributesNames defines the list of attribute names to get
  11234. * @returns an array of indices indicating the offset of each attribute
  11235. */
  11236. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11237. /**
  11238. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11239. * @param effect defines the effect to activate
  11240. */
  11241. enableEffect(effect: Nullable<Effect>): void;
  11242. /**
  11243. * Set the value of an uniform to an array of int32
  11244. * @param uniform defines the webGL uniform location where to store the value
  11245. * @param array defines the array of int32 to store
  11246. */
  11247. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11248. /**
  11249. * Set the value of an uniform to an array of int32 (stored as vec2)
  11250. * @param uniform defines the webGL uniform location where to store the value
  11251. * @param array defines the array of int32 to store
  11252. */
  11253. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11254. /**
  11255. * Set the value of an uniform to an array of int32 (stored as vec3)
  11256. * @param uniform defines the webGL uniform location where to store the value
  11257. * @param array defines the array of int32 to store
  11258. */
  11259. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11260. /**
  11261. * Set the value of an uniform to an array of int32 (stored as vec4)
  11262. * @param uniform defines the webGL uniform location where to store the value
  11263. * @param array defines the array of int32 to store
  11264. */
  11265. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11266. /**
  11267. * Set the value of an uniform to an array of float32
  11268. * @param uniform defines the webGL uniform location where to store the value
  11269. * @param array defines the array of float32 to store
  11270. */
  11271. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11272. /**
  11273. * Set the value of an uniform to an array of float32 (stored as vec2)
  11274. * @param uniform defines the webGL uniform location where to store the value
  11275. * @param array defines the array of float32 to store
  11276. */
  11277. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11278. /**
  11279. * Set the value of an uniform to an array of float32 (stored as vec3)
  11280. * @param uniform defines the webGL uniform location where to store the value
  11281. * @param array defines the array of float32 to store
  11282. */
  11283. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11284. /**
  11285. * Set the value of an uniform to an array of float32 (stored as vec4)
  11286. * @param uniform defines the webGL uniform location where to store the value
  11287. * @param array defines the array of float32 to store
  11288. */
  11289. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11290. /**
  11291. * Set the value of an uniform to an array of number
  11292. * @param uniform defines the webGL uniform location where to store the value
  11293. * @param array defines the array of number to store
  11294. */
  11295. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11296. /**
  11297. * Set the value of an uniform to an array of number (stored as vec2)
  11298. * @param uniform defines the webGL uniform location where to store the value
  11299. * @param array defines the array of number to store
  11300. */
  11301. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11302. /**
  11303. * Set the value of an uniform to an array of number (stored as vec3)
  11304. * @param uniform defines the webGL uniform location where to store the value
  11305. * @param array defines the array of number to store
  11306. */
  11307. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11308. /**
  11309. * Set the value of an uniform to an array of number (stored as vec4)
  11310. * @param uniform defines the webGL uniform location where to store the value
  11311. * @param array defines the array of number to store
  11312. */
  11313. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11314. /**
  11315. * Set the value of an uniform to an array of float32 (stored as matrices)
  11316. * @param uniform defines the webGL uniform location where to store the value
  11317. * @param matrices defines the array of float32 to store
  11318. */
  11319. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11320. /**
  11321. * Set the value of an uniform to a matrix
  11322. * @param uniform defines the webGL uniform location where to store the value
  11323. * @param matrix defines the matrix to store
  11324. */
  11325. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11326. /**
  11327. * Set the value of an uniform to a matrix (3x3)
  11328. * @param uniform defines the webGL uniform location where to store the value
  11329. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11330. */
  11331. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11332. /**
  11333. * Set the value of an uniform to a matrix (2x2)
  11334. * @param uniform defines the webGL uniform location where to store the value
  11335. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11336. */
  11337. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11338. /**
  11339. * Set the value of an uniform to a number (int)
  11340. * @param uniform defines the webGL uniform location where to store the value
  11341. * @param value defines the int number to store
  11342. */
  11343. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11344. /**
  11345. * Set the value of an uniform to a number (float)
  11346. * @param uniform defines the webGL uniform location where to store the value
  11347. * @param value defines the float number to store
  11348. */
  11349. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11350. /**
  11351. * Set the value of an uniform to a vec2
  11352. * @param uniform defines the webGL uniform location where to store the value
  11353. * @param x defines the 1st component of the value
  11354. * @param y defines the 2nd component of the value
  11355. */
  11356. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11357. /**
  11358. * Set the value of an uniform to a vec3
  11359. * @param uniform defines the webGL uniform location where to store the value
  11360. * @param x defines the 1st component of the value
  11361. * @param y defines the 2nd component of the value
  11362. * @param z defines the 3rd component of the value
  11363. */
  11364. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11365. /**
  11366. * Set the value of an uniform to a boolean
  11367. * @param uniform defines the webGL uniform location where to store the value
  11368. * @param bool defines the boolean to store
  11369. */
  11370. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11371. /**
  11372. * Set the value of an uniform to a vec4
  11373. * @param uniform defines the webGL uniform location where to store the value
  11374. * @param x defines the 1st component of the value
  11375. * @param y defines the 2nd component of the value
  11376. * @param z defines the 3rd component of the value
  11377. * @param w defines the 4th component of the value
  11378. */
  11379. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11380. /**
  11381. * Set the value of an uniform to a Color3
  11382. * @param uniform defines the webGL uniform location where to store the value
  11383. * @param color3 defines the color to store
  11384. */
  11385. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11386. /**
  11387. * Set the value of an uniform to a Color3 and an alpha value
  11388. * @param uniform defines the webGL uniform location where to store the value
  11389. * @param color3 defines the color to store
  11390. * @param alpha defines the alpha component to store
  11391. */
  11392. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11393. /**
  11394. * Sets a Color4 on a uniform variable
  11395. * @param uniform defines the uniform location
  11396. * @param color4 defines the value to be set
  11397. */
  11398. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11399. /**
  11400. * Set various states to the webGL context
  11401. * @param culling defines backface culling state
  11402. * @param zOffset defines the value to apply to zOffset (0 by default)
  11403. * @param force defines if states must be applied even if cache is up to date
  11404. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11405. */
  11406. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11407. /**
  11408. * Set the z offset to apply to current rendering
  11409. * @param value defines the offset to apply
  11410. */
  11411. setZOffset(value: number): void;
  11412. /**
  11413. * Gets the current value of the zOffset
  11414. * @returns the current zOffset state
  11415. */
  11416. getZOffset(): number;
  11417. /**
  11418. * Enable or disable depth buffering
  11419. * @param enable defines the state to set
  11420. */
  11421. setDepthBuffer(enable: boolean): void;
  11422. /**
  11423. * Gets a boolean indicating if depth writing is enabled
  11424. * @returns the current depth writing state
  11425. */
  11426. getDepthWrite(): boolean;
  11427. /**
  11428. * Enable or disable depth writing
  11429. * @param enable defines the state to set
  11430. */
  11431. setDepthWrite(enable: boolean): void;
  11432. /**
  11433. * Enable or disable color writing
  11434. * @param enable defines the state to set
  11435. */
  11436. setColorWrite(enable: boolean): void;
  11437. /**
  11438. * Gets a boolean indicating if color writing is enabled
  11439. * @returns the current color writing state
  11440. */
  11441. getColorWrite(): boolean;
  11442. /**
  11443. * Sets alpha constants used by some alpha blending modes
  11444. * @param r defines the red component
  11445. * @param g defines the green component
  11446. * @param b defines the blue component
  11447. * @param a defines the alpha component
  11448. */
  11449. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11450. /**
  11451. * Sets the current alpha mode
  11452. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11453. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11454. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11455. */
  11456. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11457. /**
  11458. * Gets the current alpha mode
  11459. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11460. * @returns the current alpha mode
  11461. */
  11462. getAlphaMode(): number;
  11463. /**
  11464. * Clears the list of texture accessible through engine.
  11465. * This can help preventing texture load conflict due to name collision.
  11466. */
  11467. clearInternalTexturesCache(): void;
  11468. /**
  11469. * Force the entire cache to be cleared
  11470. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11471. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11472. */
  11473. wipeCaches(bruteForce?: boolean): void;
  11474. /**
  11475. * Set the compressed texture format to use, based on the formats you have, and the formats
  11476. * supported by the hardware / browser.
  11477. *
  11478. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11479. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11480. * to API arguments needed to compressed textures. This puts the burden on the container
  11481. * generator to house the arcane code for determining these for current & future formats.
  11482. *
  11483. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11484. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11485. *
  11486. * Note: The result of this call is not taken into account when a texture is base64.
  11487. *
  11488. * @param formatsAvailable defines the list of those format families you have created
  11489. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11490. *
  11491. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11492. * @returns The extension selected.
  11493. */
  11494. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11495. private _getSamplingParameters;
  11496. private _partialLoadImg;
  11497. private _cascadeLoadImgs;
  11498. /** @hidden */
  11499. _createTexture(): WebGLTexture;
  11500. /**
  11501. * Usually called from BABYLON.Texture.ts.
  11502. * Passed information to create a WebGLTexture
  11503. * @param urlArg defines a value which contains one of the following:
  11504. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11505. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11506. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11507. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11508. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  11509. * @param scene needed for loading to the correct scene
  11510. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11511. * @param onLoad optional callback to be called upon successful completion
  11512. * @param onError optional callback to be called upon failure
  11513. * @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
  11514. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11515. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11516. * @param forcedExtension defines the extension to use to pick the right loader
  11517. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  11518. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11519. */
  11520. 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;
  11521. private _rescaleTexture;
  11522. /**
  11523. * Update a raw texture
  11524. * @param texture defines the texture to update
  11525. * @param data defines the data to store in the texture
  11526. * @param format defines the format of the data
  11527. * @param invertY defines if data must be stored with Y axis inverted
  11528. * @param compression defines the compression used (null by default)
  11529. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11530. */
  11531. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11532. /**
  11533. * Creates a raw texture
  11534. * @param data defines the data to store in the texture
  11535. * @param width defines the width of the texture
  11536. * @param height defines the height of the texture
  11537. * @param format defines the format of the data
  11538. * @param generateMipMaps defines if the engine should generate the mip levels
  11539. * @param invertY defines if data must be stored with Y axis inverted
  11540. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11541. * @param compression defines the compression used (null by default)
  11542. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11543. * @returns the raw texture inside an InternalTexture
  11544. */
  11545. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11546. private _unpackFlipYCached;
  11547. /**
  11548. * In case you are sharing the context with other applications, it might
  11549. * be interested to not cache the unpack flip y state to ensure a consistent
  11550. * value would be set.
  11551. */
  11552. enableUnpackFlipYCached: boolean;
  11553. /** @hidden */
  11554. _unpackFlipY(value: boolean): void;
  11555. /** @hidden */
  11556. _getUnpackAlignement(): number;
  11557. /**
  11558. * Creates a dynamic texture
  11559. * @param width defines the width of the texture
  11560. * @param height defines the height of the texture
  11561. * @param generateMipMaps defines if the engine should generate the mip levels
  11562. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11563. * @returns the dynamic texture inside an InternalTexture
  11564. */
  11565. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11566. /**
  11567. * Update the sampling mode of a given texture
  11568. * @param samplingMode defines the required sampling mode
  11569. * @param texture defines the texture to update
  11570. */
  11571. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11572. /**
  11573. * Update the content of a dynamic texture
  11574. * @param texture defines the texture to update
  11575. * @param canvas defines the canvas containing the source
  11576. * @param invertY defines if data must be stored with Y axis inverted
  11577. * @param premulAlpha defines if alpha is stored as premultiplied
  11578. * @param format defines the format of the data
  11579. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11580. */
  11581. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11582. /**
  11583. * Update a video texture
  11584. * @param texture defines the texture to update
  11585. * @param video defines the video element to use
  11586. * @param invertY defines if data must be stored with Y axis inverted
  11587. */
  11588. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11589. /**
  11590. * Updates a depth texture Comparison Mode and Function.
  11591. * If the comparison Function is equal to 0, the mode will be set to none.
  11592. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11593. * @param texture The texture to set the comparison function for
  11594. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11595. */
  11596. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11597. private _setupDepthStencilTexture;
  11598. /**
  11599. * Creates a depth stencil texture.
  11600. * This is only available in WebGL 2 or with the depth texture extension available.
  11601. * @param size The size of face edge in the texture.
  11602. * @param options The options defining the texture.
  11603. * @returns The texture
  11604. */
  11605. createDepthStencilTexture(size: number | {
  11606. width: number;
  11607. height: number;
  11608. }, options: DepthTextureCreationOptions): InternalTexture;
  11609. /**
  11610. * Creates a depth stencil texture.
  11611. * This is only available in WebGL 2 or with the depth texture extension available.
  11612. * @param size The size of face edge in the texture.
  11613. * @param options The options defining the texture.
  11614. * @returns The texture
  11615. */
  11616. private _createDepthStencilTexture;
  11617. /**
  11618. * Creates a depth stencil cube texture.
  11619. * This is only available in WebGL 2.
  11620. * @param size The size of face edge in the cube texture.
  11621. * @param options The options defining the cube texture.
  11622. * @returns The cube texture
  11623. */
  11624. private _createDepthStencilCubeTexture;
  11625. /**
  11626. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11627. * @param renderTarget The render target to set the frame buffer for
  11628. */
  11629. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11630. /**
  11631. * Creates a new render target texture
  11632. * @param size defines the size of the texture
  11633. * @param options defines the options used to create the texture
  11634. * @returns a new render target texture stored in an InternalTexture
  11635. */
  11636. createRenderTargetTexture(size: number | {
  11637. width: number;
  11638. height: number;
  11639. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11640. /**
  11641. * Create a multi render target texture
  11642. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11643. * @param size defines the size of the texture
  11644. * @param options defines the creation options
  11645. * @returns the cube texture as an InternalTexture
  11646. */
  11647. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11648. private _setupFramebufferDepthAttachments;
  11649. /**
  11650. * Updates the sample count of a render target texture
  11651. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11652. * @param texture defines the texture to update
  11653. * @param samples defines the sample count to set
  11654. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11655. */
  11656. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11657. /**
  11658. * Update the sample count for a given multiple render target texture
  11659. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11660. * @param textures defines the textures to update
  11661. * @param samples defines the sample count to set
  11662. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11663. */
  11664. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11665. /** @hidden */
  11666. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11667. /** @hidden */
  11668. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11669. /** @hidden */
  11670. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11671. /** @hidden */
  11672. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11673. /**
  11674. * Creates a new render target cube texture
  11675. * @param size defines the size of the texture
  11676. * @param options defines the options used to create the texture
  11677. * @returns a new render target cube texture stored in an InternalTexture
  11678. */
  11679. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11680. /**
  11681. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11682. * @param rootUrl defines the url where the file to load is located
  11683. * @param scene defines the current scene
  11684. * @param lodScale defines scale to apply to the mip map selection
  11685. * @param lodOffset defines offset to apply to the mip map selection
  11686. * @param onLoad defines an optional callback raised when the texture is loaded
  11687. * @param onError defines an optional callback raised if there is an issue to load the texture
  11688. * @param format defines the format of the data
  11689. * @param forcedExtension defines the extension to use to pick the right loader
  11690. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11691. * @returns the cube texture as an InternalTexture
  11692. */
  11693. 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;
  11694. /**
  11695. * Creates a cube texture
  11696. * @param rootUrl defines the url where the files to load is located
  11697. * @param scene defines the current scene
  11698. * @param files defines the list of files to load (1 per face)
  11699. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11700. * @param onLoad defines an optional callback raised when the texture is loaded
  11701. * @param onError defines an optional callback raised if there is an issue to load the texture
  11702. * @param format defines the format of the data
  11703. * @param forcedExtension defines the extension to use to pick the right loader
  11704. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11705. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11706. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11707. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11708. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  11709. * @returns the cube texture as an InternalTexture
  11710. */
  11711. 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;
  11712. /**
  11713. * @hidden
  11714. */
  11715. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11716. /**
  11717. * Update a raw cube texture
  11718. * @param texture defines the texture to udpdate
  11719. * @param data defines the data to store
  11720. * @param format defines the data format
  11721. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11722. * @param invertY defines if data must be stored with Y axis inverted
  11723. * @param compression defines the compression used (null by default)
  11724. * @param level defines which level of the texture to update
  11725. */
  11726. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11727. /**
  11728. * Creates a new raw cube texture
  11729. * @param data defines the array of data to use to create each face
  11730. * @param size defines the size of the textures
  11731. * @param format defines the format of the data
  11732. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11733. * @param generateMipMaps defines if the engine should generate the mip levels
  11734. * @param invertY defines if data must be stored with Y axis inverted
  11735. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11736. * @param compression defines the compression used (null by default)
  11737. * @returns the cube texture as an InternalTexture
  11738. */
  11739. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11740. /**
  11741. * Creates a new raw cube texture from a specified url
  11742. * @param url defines the url where the data is located
  11743. * @param scene defines the current scene
  11744. * @param size defines the size of the textures
  11745. * @param format defines the format of the data
  11746. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11747. * @param noMipmap defines if the engine should avoid generating the mip levels
  11748. * @param callback defines a callback used to extract texture data from loaded data
  11749. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11750. * @param onLoad defines a callback called when texture is loaded
  11751. * @param onError defines a callback called if there is an error
  11752. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11753. * @param invertY defines if data must be stored with Y axis inverted
  11754. * @returns the cube texture as an InternalTexture
  11755. */
  11756. 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;
  11757. /**
  11758. * Update a raw 3D texture
  11759. * @param texture defines the texture to update
  11760. * @param data defines the data to store
  11761. * @param format defines the data format
  11762. * @param invertY defines if data must be stored with Y axis inverted
  11763. * @param compression defines the used compression (can be null)
  11764. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11765. */
  11766. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11767. /**
  11768. * Creates a new raw 3D texture
  11769. * @param data defines the data used to create the texture
  11770. * @param width defines the width of the texture
  11771. * @param height defines the height of the texture
  11772. * @param depth defines the depth of the texture
  11773. * @param format defines the format of the texture
  11774. * @param generateMipMaps defines if the engine must generate mip levels
  11775. * @param invertY defines if data must be stored with Y axis inverted
  11776. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11777. * @param compression defines the compressed used (can be null)
  11778. * @param textureType defines the compressed used (can be null)
  11779. * @returns a new raw 3D texture (stored in an InternalTexture)
  11780. */
  11781. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11782. private _prepareWebGLTextureContinuation;
  11783. private _prepareWebGLTexture;
  11784. private _convertRGBtoRGBATextureData;
  11785. /** @hidden */
  11786. _releaseFramebufferObjects(texture: InternalTexture): void;
  11787. /** @hidden */
  11788. _releaseTexture(texture: InternalTexture): void;
  11789. private setProgram;
  11790. private _boundUniforms;
  11791. /**
  11792. * Binds an effect to the webGL context
  11793. * @param effect defines the effect to bind
  11794. */
  11795. bindSamplers(effect: Effect): void;
  11796. private _moveBoundTextureOnTop;
  11797. private _getCorrectTextureChannel;
  11798. private _linkTrackers;
  11799. private _removeDesignatedSlot;
  11800. private _activateCurrentTexture;
  11801. /** @hidden */
  11802. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11803. /** @hidden */
  11804. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11805. /**
  11806. * Sets a texture to the webGL context from a postprocess
  11807. * @param channel defines the channel to use
  11808. * @param postProcess defines the source postprocess
  11809. */
  11810. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11811. /**
  11812. * Binds the output of the passed in post process to the texture channel specified
  11813. * @param channel The channel the texture should be bound to
  11814. * @param postProcess The post process which's output should be bound
  11815. */
  11816. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11817. /**
  11818. * Unbind all textures from the webGL context
  11819. */
  11820. unbindAllTextures(): void;
  11821. /**
  11822. * Sets a texture to the according uniform.
  11823. * @param channel The texture channel
  11824. * @param uniform The uniform to set
  11825. * @param texture The texture to apply
  11826. */
  11827. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11828. /**
  11829. * Sets a depth stencil texture from a render target to the according uniform.
  11830. * @param channel The texture channel
  11831. * @param uniform The uniform to set
  11832. * @param texture The render target texture containing the depth stencil texture to apply
  11833. */
  11834. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11835. private _bindSamplerUniformToChannel;
  11836. private _getTextureWrapMode;
  11837. private _setTexture;
  11838. /**
  11839. * Sets an array of texture to the webGL context
  11840. * @param channel defines the channel where the texture array must be set
  11841. * @param uniform defines the associated uniform location
  11842. * @param textures defines the array of textures to bind
  11843. */
  11844. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11845. /** @hidden */
  11846. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11847. private _setTextureParameterFloat;
  11848. private _setTextureParameterInteger;
  11849. /**
  11850. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11851. * @param x defines the x coordinate of the rectangle where pixels must be read
  11852. * @param y defines the y coordinate of the rectangle where pixels must be read
  11853. * @param width defines the width of the rectangle where pixels must be read
  11854. * @param height defines the height of the rectangle where pixels must be read
  11855. * @returns a Uint8Array containing RGBA colors
  11856. */
  11857. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11858. /**
  11859. * Add an externaly attached data from its key.
  11860. * This method call will fail and return false, if such key already exists.
  11861. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11862. * @param key the unique key that identifies the data
  11863. * @param data the data object to associate to the key for this Engine instance
  11864. * @return true if no such key were already present and the data was added successfully, false otherwise
  11865. */
  11866. addExternalData<T>(key: string, data: T): boolean;
  11867. /**
  11868. * Get an externaly attached data from its key
  11869. * @param key the unique key that identifies the data
  11870. * @return the associated data, if present (can be null), or undefined if not present
  11871. */
  11872. getExternalData<T>(key: string): T;
  11873. /**
  11874. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11875. * @param key the unique key that identifies the data
  11876. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  11877. * @return the associated data, can be null if the factory returned null.
  11878. */
  11879. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  11880. /**
  11881. * Remove an externaly attached data from the Engine instance
  11882. * @param key the unique key that identifies the data
  11883. * @return true if the data was successfully removed, false if it doesn't exist
  11884. */
  11885. removeExternalData(key: string): boolean;
  11886. /**
  11887. * Unbind all vertex attributes from the webGL context
  11888. */
  11889. unbindAllAttributes(): void;
  11890. /**
  11891. * 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
  11892. */
  11893. releaseEffects(): void;
  11894. /**
  11895. * Dispose and release all associated resources
  11896. */
  11897. dispose(): void;
  11898. /**
  11899. * Display the loading screen
  11900. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11901. */
  11902. displayLoadingUI(): void;
  11903. /**
  11904. * Hide the loading screen
  11905. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11906. */
  11907. hideLoadingUI(): void;
  11908. /**
  11909. * Gets the current loading screen object
  11910. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11911. */
  11912. /**
  11913. * Sets the current loading screen object
  11914. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11915. */
  11916. loadingScreen: ILoadingScreen;
  11917. /**
  11918. * Sets the current loading screen text
  11919. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11920. */
  11921. loadingUIText: string;
  11922. /**
  11923. * Sets the current loading screen background color
  11924. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11925. */
  11926. loadingUIBackgroundColor: string;
  11927. /**
  11928. * Attach a new callback raised when context lost event is fired
  11929. * @param callback defines the callback to call
  11930. */
  11931. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11932. /**
  11933. * Attach a new callback raised when context restored event is fired
  11934. * @param callback defines the callback to call
  11935. */
  11936. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11937. /**
  11938. * Gets the source code of the vertex shader associated with a specific webGL program
  11939. * @param program defines the program to use
  11940. * @returns a string containing the source code of the vertex shader associated with the program
  11941. */
  11942. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  11943. /**
  11944. * Gets the source code of the fragment shader associated with a specific webGL program
  11945. * @param program defines the program to use
  11946. * @returns a string containing the source code of the fragment shader associated with the program
  11947. */
  11948. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  11949. /**
  11950. * Get the current error code of the webGL context
  11951. * @returns the error code
  11952. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11953. */
  11954. getError(): number;
  11955. /**
  11956. * Gets the current framerate
  11957. * @returns a number representing the framerate
  11958. */
  11959. getFps(): number;
  11960. /**
  11961. * Gets the time spent between current and previous frame
  11962. * @returns a number representing the delta time in ms
  11963. */
  11964. getDeltaTime(): number;
  11965. private _measureFps;
  11966. /** @hidden */
  11967. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  11968. private _canRenderToFloatFramebuffer;
  11969. private _canRenderToHalfFloatFramebuffer;
  11970. private _canRenderToFramebuffer;
  11971. /** @hidden */
  11972. _getWebGLTextureType(type: number): number;
  11973. private _getInternalFormat;
  11974. /** @hidden */
  11975. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  11976. /** @hidden */
  11977. _getRGBAMultiSampleBufferFormat(type: number): number;
  11978. /** @hidden */
  11979. _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;
  11980. /** @hidden */
  11981. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  11982. private _partialLoadFile;
  11983. private _cascadeLoadFiles;
  11984. /**
  11985. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  11986. * @returns true if the engine can be created
  11987. * @ignorenaming
  11988. */
  11989. static isSupported(): boolean;
  11990. }
  11991. }
  11992. declare module BABYLON {
  11993. /**
  11994. * Options to create the null engine
  11995. */
  11996. class NullEngineOptions {
  11997. /**
  11998. * Render width (Default: 512)
  11999. */
  12000. renderWidth: number;
  12001. /**
  12002. * Render height (Default: 256)
  12003. */
  12004. renderHeight: number;
  12005. /**
  12006. * Texture size (Default: 512)
  12007. */
  12008. textureSize: number;
  12009. /**
  12010. * If delta time between frames should be constant
  12011. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12012. */
  12013. deterministicLockstep: boolean;
  12014. /**
  12015. * Maximum about of steps between frames (Default: 4)
  12016. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12017. */
  12018. lockstepMaxSteps: number;
  12019. }
  12020. /**
  12021. * The null engine class provides support for headless version of babylon.js.
  12022. * This can be used in server side scenario or for testing purposes
  12023. */
  12024. class NullEngine extends Engine {
  12025. private _options;
  12026. /**
  12027. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12028. */
  12029. isDeterministicLockStep(): boolean;
  12030. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  12031. getLockstepMaxSteps(): number;
  12032. /**
  12033. * Sets hardware scaling, used to save performance if needed
  12034. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  12035. */
  12036. getHardwareScalingLevel(): number;
  12037. constructor(options?: NullEngineOptions);
  12038. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12039. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  12040. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  12041. getRenderWidth(useScreen?: boolean): number;
  12042. getRenderHeight(useScreen?: boolean): number;
  12043. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  12044. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  12045. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  12046. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  12047. bindSamplers(effect: Effect): void;
  12048. enableEffect(effect: Effect): void;
  12049. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  12050. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  12051. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  12052. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  12053. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  12054. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  12055. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  12056. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  12057. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  12058. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  12059. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  12060. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  12061. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  12062. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  12063. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  12064. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12065. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12066. setFloat(uniform: WebGLUniformLocation, value: number): void;
  12067. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  12068. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  12069. setBool(uniform: WebGLUniformLocation, bool: number): void;
  12070. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  12071. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  12072. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  12073. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12074. bindBuffers(vertexBuffers: {
  12075. [key: string]: VertexBuffer;
  12076. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  12077. wipeCaches(bruteForce?: boolean): void;
  12078. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  12079. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  12080. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  12081. /** @hidden */
  12082. _createTexture(): WebGLTexture;
  12083. /** @hidden */
  12084. _releaseTexture(texture: InternalTexture): void;
  12085. 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;
  12086. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12087. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  12088. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  12089. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  12090. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12091. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  12092. areAllEffectsReady(): boolean;
  12093. /**
  12094. * @hidden
  12095. * Get the current error code of the webGL context
  12096. * @returns the error code
  12097. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12098. */
  12099. getError(): number;
  12100. /** @hidden */
  12101. _getUnpackAlignement(): number;
  12102. /** @hidden */
  12103. _unpackFlipY(value: boolean): void;
  12104. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  12105. /**
  12106. * Updates a dynamic vertex buffer.
  12107. * @param vertexBuffer the vertex buffer to update
  12108. * @param data the data used to update the vertex buffer
  12109. * @param byteOffset the byte offset of the data (optional)
  12110. * @param byteLength the byte length of the data (optional)
  12111. */
  12112. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  12113. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  12114. /** @hidden */
  12115. _bindTexture(channel: number, texture: InternalTexture): void;
  12116. /** @hidden */
  12117. _releaseBuffer(buffer: WebGLBuffer): boolean;
  12118. releaseEffects(): void;
  12119. displayLoadingUI(): void;
  12120. hideLoadingUI(): void;
  12121. /** @hidden */
  12122. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12123. /** @hidden */
  12124. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12125. /** @hidden */
  12126. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12127. /** @hidden */
  12128. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  12129. }
  12130. }
  12131. interface WebGLRenderingContext {
  12132. readonly RASTERIZER_DISCARD: number;
  12133. readonly DEPTH_COMPONENT24: number;
  12134. readonly TEXTURE_3D: number;
  12135. readonly TEXTURE_2D_ARRAY: number;
  12136. readonly TEXTURE_COMPARE_FUNC: number;
  12137. readonly TEXTURE_COMPARE_MODE: number;
  12138. readonly COMPARE_REF_TO_TEXTURE: number;
  12139. readonly TEXTURE_WRAP_R: number;
  12140. readonly HALF_FLOAT: number;
  12141. readonly RGB8: number;
  12142. readonly RED_INTEGER: number;
  12143. readonly RG_INTEGER: number;
  12144. readonly RGB_INTEGER: number;
  12145. readonly RGBA_INTEGER: number;
  12146. readonly R8_SNORM: number;
  12147. readonly RG8_SNORM: number;
  12148. readonly RGB8_SNORM: number;
  12149. readonly RGBA8_SNORM: number;
  12150. readonly R8I: number;
  12151. readonly RG8I: number;
  12152. readonly RGB8I: number;
  12153. readonly RGBA8I: number;
  12154. readonly R8UI: number;
  12155. readonly RG8UI: number;
  12156. readonly RGB8UI: number;
  12157. readonly RGBA8UI: number;
  12158. readonly R16I: number;
  12159. readonly RG16I: number;
  12160. readonly RGB16I: number;
  12161. readonly RGBA16I: number;
  12162. readonly R16UI: number;
  12163. readonly RG16UI: number;
  12164. readonly RGB16UI: number;
  12165. readonly RGBA16UI: number;
  12166. readonly R32I: number;
  12167. readonly RG32I: number;
  12168. readonly RGB32I: number;
  12169. readonly RGBA32I: number;
  12170. readonly R32UI: number;
  12171. readonly RG32UI: number;
  12172. readonly RGB32UI: number;
  12173. readonly RGBA32UI: number;
  12174. readonly RGB10_A2UI: number;
  12175. readonly R11F_G11F_B10F: number;
  12176. readonly RGB9_E5: number;
  12177. readonly RGB10_A2: number;
  12178. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12179. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12180. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12181. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12182. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12183. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12184. 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;
  12185. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12186. readonly TRANSFORM_FEEDBACK: number;
  12187. readonly INTERLEAVED_ATTRIBS: number;
  12188. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12189. createTransformFeedback(): WebGLTransformFeedback;
  12190. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12191. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12192. beginTransformFeedback(primitiveMode: number): void;
  12193. endTransformFeedback(): void;
  12194. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12195. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12196. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12197. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12198. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12199. }
  12200. interface ImageBitmap {
  12201. readonly width: number;
  12202. readonly height: number;
  12203. close(): void;
  12204. }
  12205. interface WebGLQuery extends WebGLObject {
  12206. }
  12207. declare var WebGLQuery: {
  12208. prototype: WebGLQuery;
  12209. new (): WebGLQuery;
  12210. };
  12211. interface WebGLSampler extends WebGLObject {
  12212. }
  12213. declare var WebGLSampler: {
  12214. prototype: WebGLSampler;
  12215. new (): WebGLSampler;
  12216. };
  12217. interface WebGLSync extends WebGLObject {
  12218. }
  12219. declare var WebGLSync: {
  12220. prototype: WebGLSync;
  12221. new (): WebGLSync;
  12222. };
  12223. interface WebGLTransformFeedback extends WebGLObject {
  12224. }
  12225. declare var WebGLTransformFeedback: {
  12226. prototype: WebGLTransformFeedback;
  12227. new (): WebGLTransformFeedback;
  12228. };
  12229. interface WebGLVertexArrayObject extends WebGLObject {
  12230. }
  12231. declare var WebGLVertexArrayObject: {
  12232. prototype: WebGLVertexArrayObject;
  12233. new (): WebGLVertexArrayObject;
  12234. };
  12235. declare module BABYLON {
  12236. /**
  12237. * Gather the list of clipboard event types as constants.
  12238. */
  12239. class ClipboardEventTypes {
  12240. /**
  12241. * The clipboard event is fired when a copy command is active (pressed).
  12242. */
  12243. static readonly COPY: number;
  12244. /**
  12245. * The clipboard event is fired when a cut command is active (pressed).
  12246. */
  12247. static readonly CUT: number;
  12248. /**
  12249. * The clipboard event is fired when a paste command is active (pressed).
  12250. */
  12251. static readonly PASTE: number;
  12252. }
  12253. /**
  12254. * This class is used to store clipboard related info for the onClipboardObservable event.
  12255. */
  12256. class ClipboardInfo {
  12257. /**
  12258. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12259. */
  12260. type: number;
  12261. /**
  12262. * Defines the related dom event
  12263. */
  12264. event: ClipboardEvent;
  12265. /**
  12266. *Creates an instance of ClipboardInfo.
  12267. * @param {number} type
  12268. * @param {ClipboardEvent} event
  12269. */
  12270. constructor(
  12271. /**
  12272. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12273. */
  12274. type: number,
  12275. /**
  12276. * Defines the related dom event
  12277. */
  12278. event: ClipboardEvent);
  12279. /**
  12280. * Get the clipboard event's type from the keycode.
  12281. * @param keyCode Defines the keyCode for the current keyboard event.
  12282. * @return {number}
  12283. */
  12284. static GetTypeFromCharacter(keyCode: number): number;
  12285. }
  12286. }
  12287. declare module BABYLON {
  12288. /**
  12289. * Gather the list of keyboard event types as constants.
  12290. */
  12291. class KeyboardEventTypes {
  12292. /**
  12293. * The keydown event is fired when a key becomes active (pressed).
  12294. */
  12295. static readonly KEYDOWN: number;
  12296. /**
  12297. * The keyup event is fired when a key has been released.
  12298. */
  12299. static readonly KEYUP: number;
  12300. }
  12301. /**
  12302. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12303. */
  12304. class KeyboardInfo {
  12305. /**
  12306. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12307. */
  12308. type: number;
  12309. /**
  12310. * Defines the related dom event
  12311. */
  12312. event: KeyboardEvent;
  12313. /**
  12314. * Instantiates a new keyboard info.
  12315. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12316. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12317. * @param event Defines the related dom event
  12318. */
  12319. constructor(
  12320. /**
  12321. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12322. */
  12323. type: number,
  12324. /**
  12325. * Defines the related dom event
  12326. */
  12327. event: KeyboardEvent);
  12328. }
  12329. /**
  12330. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12331. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12332. */
  12333. class KeyboardInfoPre extends KeyboardInfo {
  12334. /**
  12335. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12336. */
  12337. type: number;
  12338. /**
  12339. * Defines the related dom event
  12340. */
  12341. event: KeyboardEvent;
  12342. /**
  12343. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12344. */
  12345. skipOnPointerObservable: boolean;
  12346. /**
  12347. * Instantiates a new keyboard pre info.
  12348. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12349. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12350. * @param event Defines the related dom event
  12351. */
  12352. constructor(
  12353. /**
  12354. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12355. */
  12356. type: number,
  12357. /**
  12358. * Defines the related dom event
  12359. */
  12360. event: KeyboardEvent);
  12361. }
  12362. }
  12363. declare module BABYLON {
  12364. /**
  12365. * Gather the list of pointer event types as constants.
  12366. */
  12367. class PointerEventTypes {
  12368. /**
  12369. * 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.
  12370. */
  12371. static readonly POINTERDOWN: number;
  12372. /**
  12373. * The pointerup event is fired when a pointer is no longer active.
  12374. */
  12375. static readonly POINTERUP: number;
  12376. /**
  12377. * The pointermove event is fired when a pointer changes coordinates.
  12378. */
  12379. static readonly POINTERMOVE: number;
  12380. /**
  12381. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12382. */
  12383. static readonly POINTERWHEEL: number;
  12384. /**
  12385. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12386. */
  12387. static readonly POINTERPICK: number;
  12388. /**
  12389. * The pointertap event is fired when a the object has been touched and released without drag.
  12390. */
  12391. static readonly POINTERTAP: number;
  12392. /**
  12393. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12394. */
  12395. static readonly POINTERDOUBLETAP: number;
  12396. }
  12397. /**
  12398. * Base class of pointer info types.
  12399. */
  12400. class PointerInfoBase {
  12401. /**
  12402. * Defines the type of event (BABYLON.PointerEventTypes)
  12403. */
  12404. type: number;
  12405. /**
  12406. * Defines the related dom event
  12407. */
  12408. event: PointerEvent | MouseWheelEvent;
  12409. /**
  12410. * Instantiates the base class of pointers info.
  12411. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12412. * @param event Defines the related dom event
  12413. */
  12414. constructor(
  12415. /**
  12416. * Defines the type of event (BABYLON.PointerEventTypes)
  12417. */
  12418. type: number,
  12419. /**
  12420. * Defines the related dom event
  12421. */
  12422. event: PointerEvent | MouseWheelEvent);
  12423. }
  12424. /**
  12425. * This class is used to store pointer related info for the onPrePointerObservable event.
  12426. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12427. */
  12428. class PointerInfoPre extends PointerInfoBase {
  12429. /**
  12430. * Ray from a pointer if availible (eg. 6dof controller)
  12431. */
  12432. ray: Nullable<Ray>;
  12433. /**
  12434. * Defines the local position of the pointer on the canvas.
  12435. */
  12436. localPosition: Vector2;
  12437. /**
  12438. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12439. */
  12440. skipOnPointerObservable: boolean;
  12441. /**
  12442. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12443. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12444. * @param event Defines the related dom event
  12445. * @param localX Defines the local x coordinates of the pointer when the event occured
  12446. * @param localY Defines the local y coordinates of the pointer when the event occured
  12447. */
  12448. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12449. }
  12450. /**
  12451. * This type contains all the data related to a pointer event in Babylon.js.
  12452. * 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.
  12453. */
  12454. class PointerInfo extends PointerInfoBase {
  12455. /**
  12456. * Defines the picking info associated to the info (if any)\
  12457. */
  12458. pickInfo: Nullable<PickingInfo>;
  12459. /**
  12460. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12461. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12462. * @param event Defines the related dom event
  12463. * @param pickInfo Defines the picking info associated to the info (if any)\
  12464. */
  12465. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12466. /**
  12467. * Defines the picking info associated to the info (if any)\
  12468. */
  12469. pickInfo: Nullable<PickingInfo>);
  12470. }
  12471. }
  12472. declare module BABYLON {
  12473. /**
  12474. * Represents a gamepad control stick position
  12475. */
  12476. class StickValues {
  12477. /**
  12478. * The x component of the control stick
  12479. */
  12480. x: number;
  12481. /**
  12482. * The y component of the control stick
  12483. */
  12484. y: number;
  12485. /**
  12486. * Initializes the gamepad x and y control stick values
  12487. * @param x The x component of the gamepad control stick value
  12488. * @param y The y component of the gamepad control stick value
  12489. */
  12490. constructor(
  12491. /**
  12492. * The x component of the control stick
  12493. */
  12494. x: number,
  12495. /**
  12496. * The y component of the control stick
  12497. */
  12498. y: number);
  12499. }
  12500. /**
  12501. * An interface which manages callbacks for gamepad button changes
  12502. */
  12503. interface GamepadButtonChanges {
  12504. /**
  12505. * Called when a gamepad has been changed
  12506. */
  12507. changed: boolean;
  12508. /**
  12509. * Called when a gamepad press event has been triggered
  12510. */
  12511. pressChanged: boolean;
  12512. /**
  12513. * Called when a touch event has been triggered
  12514. */
  12515. touchChanged: boolean;
  12516. /**
  12517. * Called when a value has changed
  12518. */
  12519. valueChanged: boolean;
  12520. }
  12521. /**
  12522. * Represents a gamepad
  12523. */
  12524. class Gamepad {
  12525. /**
  12526. * The id of the gamepad
  12527. */
  12528. id: string;
  12529. /**
  12530. * The index of the gamepad
  12531. */
  12532. index: number;
  12533. /**
  12534. * The browser gamepad
  12535. */
  12536. browserGamepad: any;
  12537. /**
  12538. * Specifies what type of gamepad this represents
  12539. */
  12540. type: number;
  12541. private _leftStick;
  12542. private _rightStick;
  12543. /** @hidden */
  12544. _isConnected: boolean;
  12545. private _leftStickAxisX;
  12546. private _leftStickAxisY;
  12547. private _rightStickAxisX;
  12548. private _rightStickAxisY;
  12549. /**
  12550. * Triggered when the left control stick has been changed
  12551. */
  12552. private _onleftstickchanged;
  12553. /**
  12554. * Triggered when the right control stick has been changed
  12555. */
  12556. private _onrightstickchanged;
  12557. /**
  12558. * Represents a gamepad controller
  12559. */
  12560. static GAMEPAD: number;
  12561. /**
  12562. * Represents a generic controller
  12563. */
  12564. static GENERIC: number;
  12565. /**
  12566. * Represents an XBox controller
  12567. */
  12568. static XBOX: number;
  12569. /**
  12570. * Represents a pose-enabled controller
  12571. */
  12572. static POSE_ENABLED: number;
  12573. /**
  12574. * Specifies whether the left control stick should be Y-inverted
  12575. */
  12576. protected _invertLeftStickY: boolean;
  12577. /**
  12578. * Specifies if the gamepad has been connected
  12579. */
  12580. readonly isConnected: boolean;
  12581. /**
  12582. * Initializes the gamepad
  12583. * @param id The id of the gamepad
  12584. * @param index The index of the gamepad
  12585. * @param browserGamepad The browser gamepad
  12586. * @param leftStickX The x component of the left joystick
  12587. * @param leftStickY The y component of the left joystick
  12588. * @param rightStickX The x component of the right joystick
  12589. * @param rightStickY The y component of the right joystick
  12590. */
  12591. constructor(
  12592. /**
  12593. * The id of the gamepad
  12594. */
  12595. id: string,
  12596. /**
  12597. * The index of the gamepad
  12598. */
  12599. index: number,
  12600. /**
  12601. * The browser gamepad
  12602. */
  12603. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12604. /**
  12605. * Callback triggered when the left joystick has changed
  12606. * @param callback
  12607. */
  12608. onleftstickchanged(callback: (values: StickValues) => void): void;
  12609. /**
  12610. * Callback triggered when the right joystick has changed
  12611. * @param callback
  12612. */
  12613. onrightstickchanged(callback: (values: StickValues) => void): void;
  12614. /**
  12615. * Gets the left joystick
  12616. */
  12617. /**
  12618. * Sets the left joystick values
  12619. */
  12620. leftStick: StickValues;
  12621. /**
  12622. * Gets the right joystick
  12623. */
  12624. /**
  12625. * Sets the right joystick value
  12626. */
  12627. rightStick: StickValues;
  12628. /**
  12629. * Updates the gamepad joystick positions
  12630. */
  12631. update(): void;
  12632. /**
  12633. * Disposes the gamepad
  12634. */
  12635. dispose(): void;
  12636. }
  12637. /**
  12638. * Represents a generic gamepad
  12639. */
  12640. class GenericPad extends Gamepad {
  12641. private _buttons;
  12642. private _onbuttondown;
  12643. private _onbuttonup;
  12644. /**
  12645. * Observable triggered when a button has been pressed
  12646. */
  12647. onButtonDownObservable: Observable<number>;
  12648. /**
  12649. * Observable triggered when a button has been released
  12650. */
  12651. onButtonUpObservable: Observable<number>;
  12652. /**
  12653. * Callback triggered when a button has been pressed
  12654. * @param callback Called when a button has been pressed
  12655. */
  12656. onbuttondown(callback: (buttonPressed: number) => void): void;
  12657. /**
  12658. * Callback triggered when a button has been released
  12659. * @param callback Called when a button has been released
  12660. */
  12661. onbuttonup(callback: (buttonReleased: number) => void): void;
  12662. /**
  12663. * Initializes the generic gamepad
  12664. * @param id The id of the generic gamepad
  12665. * @param index The index of the generic gamepad
  12666. * @param browserGamepad The browser gamepad
  12667. */
  12668. constructor(id: string, index: number, browserGamepad: any);
  12669. private _setButtonValue;
  12670. /**
  12671. * Updates the generic gamepad
  12672. */
  12673. update(): void;
  12674. /**
  12675. * Disposes the generic gamepad
  12676. */
  12677. dispose(): void;
  12678. }
  12679. }
  12680. declare module BABYLON {
  12681. /**
  12682. * Manager for handling gamepads
  12683. */
  12684. class GamepadManager {
  12685. private _scene?;
  12686. private _babylonGamepads;
  12687. private _oneGamepadConnected;
  12688. /** @hidden */
  12689. _isMonitoring: boolean;
  12690. private _gamepadEventSupported;
  12691. private _gamepadSupport;
  12692. /**
  12693. * observable to be triggered when the gamepad controller has been connected
  12694. */
  12695. onGamepadConnectedObservable: Observable<Gamepad>;
  12696. /**
  12697. * observable to be triggered when the gamepad controller has been disconnected
  12698. */
  12699. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12700. private _onGamepadConnectedEvent;
  12701. private _onGamepadDisconnectedEvent;
  12702. /**
  12703. * Initializes the gamepad manager
  12704. * @param _scene BabylonJS scene
  12705. */
  12706. constructor(_scene?: Scene | undefined);
  12707. /**
  12708. * The gamepads in the game pad manager
  12709. */
  12710. readonly gamepads: Gamepad[];
  12711. /**
  12712. * Get the gamepad controllers based on type
  12713. * @param type The type of gamepad controller
  12714. * @returns Nullable gamepad
  12715. */
  12716. getGamepadByType(type?: number): Nullable<Gamepad>;
  12717. /**
  12718. * Disposes the gamepad manager
  12719. */
  12720. dispose(): void;
  12721. private _addNewGamepad;
  12722. private _startMonitoringGamepads;
  12723. private _stopMonitoringGamepads;
  12724. /** @hidden */
  12725. _checkGamepadsStatus(): void;
  12726. private _updateGamepadObjects;
  12727. }
  12728. }
  12729. declare module BABYLON {
  12730. interface Scene {
  12731. /** @hidden */
  12732. _gamepadManager: Nullable<GamepadManager>;
  12733. /**
  12734. * Gets the gamepad manager associated with the scene
  12735. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12736. */
  12737. gamepadManager: GamepadManager;
  12738. }
  12739. /**
  12740. * Interface representing a free camera inputs manager
  12741. */
  12742. interface FreeCameraInputsManager {
  12743. /**
  12744. * Adds gamepad input support to the FreeCameraInputsManager.
  12745. * @returns the FreeCameraInputsManager
  12746. */
  12747. addGamepad(): FreeCameraInputsManager;
  12748. }
  12749. /**
  12750. * Interface representing an arc rotate camera inputs manager
  12751. */
  12752. interface ArcRotateCameraInputsManager {
  12753. /**
  12754. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12755. * @returns the camera inputs manager
  12756. */
  12757. addGamepad(): ArcRotateCameraInputsManager;
  12758. }
  12759. /**
  12760. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12761. */
  12762. class GamepadSystemSceneComponent implements ISceneComponent {
  12763. /**
  12764. * The component name helpfull to identify the component in the list of scene components.
  12765. */
  12766. readonly name: string;
  12767. /**
  12768. * The scene the component belongs to.
  12769. */
  12770. scene: Scene;
  12771. /**
  12772. * Creates a new instance of the component for the given scene
  12773. * @param scene Defines the scene to register the component in
  12774. */
  12775. constructor(scene: Scene);
  12776. /**
  12777. * Registers the component in a given scene
  12778. */
  12779. register(): void;
  12780. /**
  12781. * Rebuilds the elements related to this component in case of
  12782. * context lost for instance.
  12783. */
  12784. rebuild(): void;
  12785. /**
  12786. * Disposes the component and the associated ressources
  12787. */
  12788. dispose(): void;
  12789. private _beforeCameraUpdate;
  12790. }
  12791. }
  12792. declare module BABYLON {
  12793. /**
  12794. * Defines supported buttons for XBox360 compatible gamepads
  12795. */
  12796. enum Xbox360Button {
  12797. /** A */
  12798. A = 0,
  12799. /** B */
  12800. B = 1,
  12801. /** X */
  12802. X = 2,
  12803. /** Y */
  12804. Y = 3,
  12805. /** Start */
  12806. Start = 4,
  12807. /** Back */
  12808. Back = 5,
  12809. /** Left button */
  12810. LB = 6,
  12811. /** Right button */
  12812. RB = 7,
  12813. /** Left stick */
  12814. LeftStick = 8,
  12815. /** Right stick */
  12816. RightStick = 9
  12817. }
  12818. /** Defines values for XBox360 DPad */
  12819. enum Xbox360Dpad {
  12820. /** Up */
  12821. Up = 0,
  12822. /** Down */
  12823. Down = 1,
  12824. /** Left */
  12825. Left = 2,
  12826. /** Right */
  12827. Right = 3
  12828. }
  12829. /**
  12830. * Defines a XBox360 gamepad
  12831. */
  12832. class Xbox360Pad extends Gamepad {
  12833. private _leftTrigger;
  12834. private _rightTrigger;
  12835. private _onlefttriggerchanged;
  12836. private _onrighttriggerchanged;
  12837. private _onbuttondown;
  12838. private _onbuttonup;
  12839. private _ondpaddown;
  12840. private _ondpadup;
  12841. /** Observable raised when a button is pressed */
  12842. onButtonDownObservable: Observable<Xbox360Button>;
  12843. /** Observable raised when a button is released */
  12844. onButtonUpObservable: Observable<Xbox360Button>;
  12845. /** Observable raised when a pad is pressed */
  12846. onPadDownObservable: Observable<Xbox360Dpad>;
  12847. /** Observable raised when a pad is released */
  12848. onPadUpObservable: Observable<Xbox360Dpad>;
  12849. private _buttonA;
  12850. private _buttonB;
  12851. private _buttonX;
  12852. private _buttonY;
  12853. private _buttonBack;
  12854. private _buttonStart;
  12855. private _buttonLB;
  12856. private _buttonRB;
  12857. private _buttonLeftStick;
  12858. private _buttonRightStick;
  12859. private _dPadUp;
  12860. private _dPadDown;
  12861. private _dPadLeft;
  12862. private _dPadRight;
  12863. private _isXboxOnePad;
  12864. /**
  12865. * Creates a new XBox360 gamepad object
  12866. * @param id defines the id of this gamepad
  12867. * @param index defines its index
  12868. * @param gamepad defines the internal HTML gamepad object
  12869. * @param xboxOne defines if it is a XBox One gamepad
  12870. */
  12871. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12872. /**
  12873. * Defines the callback to call when left trigger is pressed
  12874. * @param callback defines the callback to use
  12875. */
  12876. onlefttriggerchanged(callback: (value: number) => void): void;
  12877. /**
  12878. * Defines the callback to call when right trigger is pressed
  12879. * @param callback defines the callback to use
  12880. */
  12881. onrighttriggerchanged(callback: (value: number) => void): void;
  12882. /**
  12883. * Gets the left trigger value
  12884. */
  12885. /**
  12886. * Sets the left trigger value
  12887. */
  12888. leftTrigger: number;
  12889. /**
  12890. * Gets the right trigger value
  12891. */
  12892. /**
  12893. * Sets the right trigger value
  12894. */
  12895. rightTrigger: number;
  12896. /**
  12897. * Defines the callback to call when a button is pressed
  12898. * @param callback defines the callback to use
  12899. */
  12900. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12901. /**
  12902. * Defines the callback to call when a button is released
  12903. * @param callback defines the callback to use
  12904. */
  12905. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  12906. /**
  12907. * Defines the callback to call when a pad is pressed
  12908. * @param callback defines the callback to use
  12909. */
  12910. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  12911. /**
  12912. * Defines the callback to call when a pad is released
  12913. * @param callback defines the callback to use
  12914. */
  12915. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  12916. private _setButtonValue;
  12917. private _setDPadValue;
  12918. /**
  12919. * Gets the value of the `A` button
  12920. */
  12921. /**
  12922. * Sets the value of the `A` button
  12923. */
  12924. buttonA: number;
  12925. /**
  12926. * Gets the value of the `B` button
  12927. */
  12928. /**
  12929. * Sets the value of the `B` button
  12930. */
  12931. buttonB: number;
  12932. /**
  12933. * Gets the value of the `X` button
  12934. */
  12935. /**
  12936. * Sets the value of the `X` button
  12937. */
  12938. buttonX: number;
  12939. /**
  12940. * Gets the value of the `Y` button
  12941. */
  12942. /**
  12943. * Sets the value of the `Y` button
  12944. */
  12945. buttonY: number;
  12946. /**
  12947. * Gets the value of the `Start` button
  12948. */
  12949. /**
  12950. * Sets the value of the `Start` button
  12951. */
  12952. buttonStart: number;
  12953. /**
  12954. * Gets the value of the `Back` button
  12955. */
  12956. /**
  12957. * Sets the value of the `Back` button
  12958. */
  12959. buttonBack: number;
  12960. /**
  12961. * Gets the value of the `Left` button
  12962. */
  12963. /**
  12964. * Sets the value of the `Left` button
  12965. */
  12966. buttonLB: number;
  12967. /**
  12968. * Gets the value of the `Right` button
  12969. */
  12970. /**
  12971. * Sets the value of the `Right` button
  12972. */
  12973. buttonRB: number;
  12974. /**
  12975. * Gets the value of the Left joystick
  12976. */
  12977. /**
  12978. * Sets the value of the Left joystick
  12979. */
  12980. buttonLeftStick: number;
  12981. /**
  12982. * Gets the value of the Right joystick
  12983. */
  12984. /**
  12985. * Sets the value of the Right joystick
  12986. */
  12987. buttonRightStick: number;
  12988. /**
  12989. * Gets the value of D-pad up
  12990. */
  12991. /**
  12992. * Sets the value of D-pad up
  12993. */
  12994. dPadUp: number;
  12995. /**
  12996. * Gets the value of D-pad down
  12997. */
  12998. /**
  12999. * Sets the value of D-pad down
  13000. */
  13001. dPadDown: number;
  13002. /**
  13003. * Gets the value of D-pad left
  13004. */
  13005. /**
  13006. * Sets the value of D-pad left
  13007. */
  13008. dPadLeft: number;
  13009. /**
  13010. * Gets the value of D-pad right
  13011. */
  13012. /**
  13013. * Sets the value of D-pad right
  13014. */
  13015. dPadRight: number;
  13016. /**
  13017. * Force the gamepad to synchronize with device values
  13018. */
  13019. update(): void;
  13020. /**
  13021. * Disposes the gamepad
  13022. */
  13023. dispose(): void;
  13024. }
  13025. }
  13026. declare module BABYLON {
  13027. /**
  13028. * Single axis drag gizmo
  13029. */
  13030. class AxisDragGizmo extends Gizmo {
  13031. /**
  13032. * Drag behavior responsible for the gizmos dragging interactions
  13033. */
  13034. dragBehavior: PointerDragBehavior;
  13035. private _pointerObserver;
  13036. /**
  13037. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13038. */
  13039. snapDistance: number;
  13040. /**
  13041. * Event that fires each time the gizmo snaps to a new location.
  13042. * * snapDistance is the the change in distance
  13043. */
  13044. onSnapObservable: Observable<{
  13045. snapDistance: number;
  13046. }>;
  13047. /**
  13048. * Creates an AxisDragGizmo
  13049. * @param gizmoLayer The utility layer the gizmo will be added to
  13050. * @param dragAxis The axis which the gizmo will be able to drag on
  13051. * @param color The color of the gizmo
  13052. */
  13053. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13054. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13055. /**
  13056. * Disposes of the gizmo
  13057. */
  13058. dispose(): void;
  13059. }
  13060. }
  13061. declare module BABYLON {
  13062. /**
  13063. * Single axis scale gizmo
  13064. */
  13065. class AxisScaleGizmo extends Gizmo {
  13066. private _coloredMaterial;
  13067. /**
  13068. * Drag behavior responsible for the gizmos dragging interactions
  13069. */
  13070. dragBehavior: PointerDragBehavior;
  13071. private _pointerObserver;
  13072. /**
  13073. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13074. */
  13075. snapDistance: number;
  13076. /**
  13077. * Event that fires each time the gizmo snaps to a new location.
  13078. * * snapDistance is the the change in distance
  13079. */
  13080. onSnapObservable: Observable<{
  13081. snapDistance: number;
  13082. }>;
  13083. /**
  13084. * If the scaling operation should be done on all axis (default: false)
  13085. */
  13086. uniformScaling: boolean;
  13087. /**
  13088. * Creates an AxisScaleGizmo
  13089. * @param gizmoLayer The utility layer the gizmo will be added to
  13090. * @param dragAxis The axis which the gizmo will be able to scale on
  13091. * @param color The color of the gizmo
  13092. */
  13093. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13094. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13095. /**
  13096. * Disposes of the gizmo
  13097. */
  13098. dispose(): void;
  13099. /**
  13100. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13101. * @param mesh The mesh to replace the default mesh of the gizmo
  13102. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  13103. */
  13104. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  13105. }
  13106. }
  13107. declare module BABYLON {
  13108. /**
  13109. * Bounding box gizmo
  13110. */
  13111. class BoundingBoxGizmo extends Gizmo {
  13112. private _lineBoundingBox;
  13113. private _rotateSpheresParent;
  13114. private _scaleBoxesParent;
  13115. private _boundingDimensions;
  13116. private _renderObserver;
  13117. private _pointerObserver;
  13118. private _scaleDragSpeed;
  13119. private _tmpQuaternion;
  13120. private _tmpVector;
  13121. private _tmpRotationMatrix;
  13122. /**
  13123. * 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)
  13124. */
  13125. ignoreChildren: boolean;
  13126. /**
  13127. * 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)
  13128. */
  13129. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  13130. /**
  13131. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  13132. */
  13133. rotationSphereSize: number;
  13134. /**
  13135. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  13136. */
  13137. scaleBoxSize: number;
  13138. /**
  13139. * 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)
  13140. */
  13141. fixedDragMeshScreenSize: boolean;
  13142. /**
  13143. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  13144. */
  13145. fixedDragMeshScreenSizeDistanceFactor: number;
  13146. /**
  13147. * Fired when a rotation sphere or scale box is dragged
  13148. */
  13149. onDragStartObservable: Observable<{}>;
  13150. /**
  13151. * Fired when a scale box is dragged
  13152. */
  13153. onScaleBoxDragObservable: Observable<{}>;
  13154. /**
  13155. * Fired when a scale box drag is ended
  13156. */
  13157. onScaleBoxDragEndObservable: Observable<{}>;
  13158. /**
  13159. * Fired when a rotation sphere is dragged
  13160. */
  13161. onRotationSphereDragObservable: Observable<{}>;
  13162. /**
  13163. * Fired when a rotation sphere drag is ended
  13164. */
  13165. onRotationSphereDragEndObservable: Observable<{}>;
  13166. /**
  13167. * 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)
  13168. */
  13169. scalePivot: Nullable<Vector3>;
  13170. private _anchorMesh;
  13171. private _existingMeshScale;
  13172. private static _PivotCached;
  13173. private static _OldPivotPoint;
  13174. private static _PivotTranslation;
  13175. private static _PivotTmpVector;
  13176. /** @hidden */
  13177. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  13178. /** @hidden */
  13179. static _RestorePivotPoint(mesh: AbstractMesh): void;
  13180. /**
  13181. * Creates an BoundingBoxGizmo
  13182. * @param gizmoLayer The utility layer the gizmo will be added to
  13183. * @param color The color of the gizmo
  13184. */
  13185. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13186. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13187. private _selectNode;
  13188. /**
  13189. * Updates the bounding box information for the Gizmo
  13190. */
  13191. updateBoundingBox(): void;
  13192. private _updateRotationSpheres;
  13193. private _updateScaleBoxes;
  13194. /**
  13195. * Enables rotation on the specified axis and disables rotation on the others
  13196. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  13197. */
  13198. setEnabledRotationAxis(axis: string): void;
  13199. /**
  13200. * Disposes of the gizmo
  13201. */
  13202. dispose(): void;
  13203. /**
  13204. * 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)
  13205. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  13206. * @returns the bounding box mesh with the passed in mesh as a child
  13207. */
  13208. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  13209. /**
  13210. * CustomMeshes are not supported by this gizmo
  13211. * @param mesh The mesh to replace the default mesh of the gizmo
  13212. */
  13213. setCustomMesh(mesh: Mesh): void;
  13214. }
  13215. }
  13216. declare module BABYLON {
  13217. /**
  13218. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  13219. */
  13220. class Gizmo implements IDisposable {
  13221. /** The utility layer the gizmo will be added to */
  13222. gizmoLayer: UtilityLayerRenderer;
  13223. /**
  13224. * The root mesh of the gizmo
  13225. */
  13226. protected _rootMesh: Mesh;
  13227. private _attachedMesh;
  13228. /**
  13229. * Ratio for the scale of the gizmo (Default: 1)
  13230. */
  13231. scaleRatio: number;
  13232. private _tmpMatrix;
  13233. /**
  13234. * If a custom mesh has been set (Default: false)
  13235. */
  13236. protected _customMeshSet: boolean;
  13237. /**
  13238. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  13239. * * When set, interactions will be enabled
  13240. */
  13241. attachedMesh: Nullable<AbstractMesh>;
  13242. /**
  13243. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13244. * @param mesh The mesh to replace the default mesh of the gizmo
  13245. */
  13246. setCustomMesh(mesh: Mesh): void;
  13247. /**
  13248. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  13249. */
  13250. updateGizmoRotationToMatchAttachedMesh: boolean;
  13251. /**
  13252. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  13253. */
  13254. updateGizmoPositionToMatchAttachedMesh: boolean;
  13255. /**
  13256. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  13257. */
  13258. protected _updateScale: boolean;
  13259. protected _interactionsEnabled: boolean;
  13260. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13261. private _beforeRenderObserver;
  13262. /**
  13263. * Creates a gizmo
  13264. * @param gizmoLayer The utility layer the gizmo will be added to
  13265. */
  13266. constructor(
  13267. /** The utility layer the gizmo will be added to */
  13268. gizmoLayer?: UtilityLayerRenderer);
  13269. private _tempVector;
  13270. /**
  13271. * @hidden
  13272. * Updates the gizmo to match the attached mesh's position/rotation
  13273. */
  13274. protected _update(): void;
  13275. /**
  13276. * Disposes of the gizmo
  13277. */
  13278. dispose(): void;
  13279. }
  13280. }
  13281. declare module BABYLON {
  13282. /**
  13283. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  13284. */
  13285. class GizmoManager implements IDisposable {
  13286. private scene;
  13287. /**
  13288. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  13289. */
  13290. gizmos: {
  13291. positionGizmo: Nullable<PositionGizmo>;
  13292. rotationGizmo: Nullable<RotationGizmo>;
  13293. scaleGizmo: Nullable<ScaleGizmo>;
  13294. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  13295. };
  13296. private _gizmosEnabled;
  13297. private _pointerObserver;
  13298. private _attachedMesh;
  13299. private _boundingBoxColor;
  13300. private _defaultUtilityLayer;
  13301. private _defaultKeepDepthUtilityLayer;
  13302. /**
  13303. * When bounding box gizmo is enabled, this can be used to track drag/end events
  13304. */
  13305. boundingBoxDragBehavior: SixDofDragBehavior;
  13306. /**
  13307. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  13308. */
  13309. attachableMeshes: Nullable<Array<AbstractMesh>>;
  13310. /**
  13311. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  13312. */
  13313. usePointerToAttachGizmos: boolean;
  13314. /**
  13315. * Instatiates a gizmo manager
  13316. * @param scene the scene to overlay the gizmos on top of
  13317. */
  13318. constructor(scene: Scene);
  13319. /**
  13320. * Attaches a set of gizmos to the specified mesh
  13321. * @param mesh The mesh the gizmo's should be attached to
  13322. */
  13323. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  13324. /**
  13325. * If the position gizmo is enabled
  13326. */
  13327. positionGizmoEnabled: boolean;
  13328. /**
  13329. * If the rotation gizmo is enabled
  13330. */
  13331. rotationGizmoEnabled: boolean;
  13332. /**
  13333. * If the scale gizmo is enabled
  13334. */
  13335. scaleGizmoEnabled: boolean;
  13336. /**
  13337. * If the boundingBox gizmo is enabled
  13338. */
  13339. boundingBoxGizmoEnabled: boolean;
  13340. /**
  13341. * Disposes of the gizmo manager
  13342. */
  13343. dispose(): void;
  13344. }
  13345. }
  13346. declare module BABYLON {
  13347. /**
  13348. * Single plane rotation gizmo
  13349. */
  13350. class PlaneRotationGizmo extends Gizmo {
  13351. /**
  13352. * Drag behavior responsible for the gizmos dragging interactions
  13353. */
  13354. dragBehavior: PointerDragBehavior;
  13355. private _pointerObserver;
  13356. /**
  13357. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  13358. */
  13359. snapDistance: number;
  13360. /**
  13361. * Event that fires each time the gizmo snaps to a new location.
  13362. * * snapDistance is the the change in distance
  13363. */
  13364. onSnapObservable: Observable<{
  13365. snapDistance: number;
  13366. }>;
  13367. /**
  13368. * Creates a PlaneRotationGizmo
  13369. * @param gizmoLayer The utility layer the gizmo will be added to
  13370. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  13371. * @param color The color of the gizmo
  13372. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13373. */
  13374. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13375. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13376. /**
  13377. * Disposes of the gizmo
  13378. */
  13379. dispose(): void;
  13380. }
  13381. }
  13382. declare module BABYLON {
  13383. /**
  13384. * Gizmo that enables dragging a mesh along 3 axis
  13385. */
  13386. class PositionGizmo extends Gizmo {
  13387. /**
  13388. * Internal gizmo used for interactions on the x axis
  13389. */
  13390. xGizmo: AxisDragGizmo;
  13391. /**
  13392. * Internal gizmo used for interactions on the y axis
  13393. */
  13394. yGizmo: AxisDragGizmo;
  13395. /**
  13396. * Internal gizmo used for interactions on the z axis
  13397. */
  13398. zGizmo: AxisDragGizmo;
  13399. /** Fires an event when any of it's sub gizmos are dragged */
  13400. onDragStartObservable: Observable<{}>;
  13401. /** Fires an event when any of it's sub gizmos are released from dragging */
  13402. onDragEndObservable: Observable<{}>;
  13403. attachedMesh: Nullable<AbstractMesh>;
  13404. /**
  13405. * Creates a PositionGizmo
  13406. * @param gizmoLayer The utility layer the gizmo will be added to
  13407. */
  13408. constructor(gizmoLayer?: UtilityLayerRenderer);
  13409. updateGizmoRotationToMatchAttachedMesh: boolean;
  13410. /**
  13411. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13412. */
  13413. snapDistance: number;
  13414. /**
  13415. * Ratio for the scale of the gizmo (Default: 1)
  13416. */
  13417. scaleRatio: number;
  13418. /**
  13419. * Disposes of the gizmo
  13420. */
  13421. dispose(): void;
  13422. /**
  13423. * CustomMeshes are not supported by this gizmo
  13424. * @param mesh The mesh to replace the default mesh of the gizmo
  13425. */
  13426. setCustomMesh(mesh: Mesh): void;
  13427. }
  13428. }
  13429. declare module BABYLON {
  13430. /**
  13431. * Gizmo that enables rotating a mesh along 3 axis
  13432. */
  13433. class RotationGizmo extends Gizmo {
  13434. /**
  13435. * Internal gizmo used for interactions on the x axis
  13436. */
  13437. xGizmo: PlaneRotationGizmo;
  13438. /**
  13439. * Internal gizmo used for interactions on the y axis
  13440. */
  13441. yGizmo: PlaneRotationGizmo;
  13442. /**
  13443. * Internal gizmo used for interactions on the z axis
  13444. */
  13445. zGizmo: PlaneRotationGizmo;
  13446. /** Fires an event when any of it's sub gizmos are dragged */
  13447. onDragStartObservable: Observable<{}>;
  13448. /** Fires an event when any of it's sub gizmos are released from dragging */
  13449. onDragEndObservable: Observable<{}>;
  13450. attachedMesh: Nullable<AbstractMesh>;
  13451. /**
  13452. * Creates a RotationGizmo
  13453. * @param gizmoLayer The utility layer the gizmo will be added to
  13454. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13455. */
  13456. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13457. updateGizmoRotationToMatchAttachedMesh: boolean;
  13458. /**
  13459. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13460. */
  13461. snapDistance: number;
  13462. /**
  13463. * Ratio for the scale of the gizmo (Default: 1)
  13464. */
  13465. scaleRatio: number;
  13466. /**
  13467. * Disposes of the gizmo
  13468. */
  13469. dispose(): void;
  13470. /**
  13471. * CustomMeshes are not supported by this gizmo
  13472. * @param mesh The mesh to replace the default mesh of the gizmo
  13473. */
  13474. setCustomMesh(mesh: Mesh): void;
  13475. }
  13476. }
  13477. declare module BABYLON {
  13478. /**
  13479. * Gizmo that enables scaling a mesh along 3 axis
  13480. */
  13481. class ScaleGizmo extends Gizmo {
  13482. /**
  13483. * Internal gizmo used for interactions on the x axis
  13484. */
  13485. xGizmo: AxisScaleGizmo;
  13486. /**
  13487. * Internal gizmo used for interactions on the y axis
  13488. */
  13489. yGizmo: AxisScaleGizmo;
  13490. /**
  13491. * Internal gizmo used for interactions on the z axis
  13492. */
  13493. zGizmo: AxisScaleGizmo;
  13494. /**
  13495. * Internal gizmo used to scale all axis equally
  13496. */
  13497. uniformScaleGizmo: AxisScaleGizmo;
  13498. /** Fires an event when any of it's sub gizmos are dragged */
  13499. onDragStartObservable: Observable<{}>;
  13500. /** Fires an event when any of it's sub gizmos are released from dragging */
  13501. onDragEndObservable: Observable<{}>;
  13502. attachedMesh: Nullable<AbstractMesh>;
  13503. /**
  13504. * Creates a ScaleGizmo
  13505. * @param gizmoLayer The utility layer the gizmo will be added to
  13506. */
  13507. constructor(gizmoLayer?: UtilityLayerRenderer);
  13508. updateGizmoRotationToMatchAttachedMesh: boolean;
  13509. /**
  13510. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13511. */
  13512. snapDistance: number;
  13513. /**
  13514. * Ratio for the scale of the gizmo (Default: 1)
  13515. */
  13516. scaleRatio: number;
  13517. /**
  13518. * Disposes of the gizmo
  13519. */
  13520. dispose(): void;
  13521. }
  13522. }
  13523. declare module BABYLON {
  13524. /**
  13525. * This class can be used to get instrumentation data from a Babylon engine
  13526. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13527. */
  13528. class EngineInstrumentation implements IDisposable {
  13529. /**
  13530. * Define the instrumented engine.
  13531. */
  13532. engine: Engine;
  13533. private _captureGPUFrameTime;
  13534. private _gpuFrameTimeToken;
  13535. private _gpuFrameTime;
  13536. private _captureShaderCompilationTime;
  13537. private _shaderCompilationTime;
  13538. private _onBeginFrameObserver;
  13539. private _onEndFrameObserver;
  13540. private _onBeforeShaderCompilationObserver;
  13541. private _onAfterShaderCompilationObserver;
  13542. /**
  13543. * Gets the perf counter used for GPU frame time
  13544. */
  13545. readonly gpuFrameTimeCounter: PerfCounter;
  13546. /**
  13547. * Gets the GPU frame time capture status
  13548. */
  13549. /**
  13550. * Enable or disable the GPU frame time capture
  13551. */
  13552. captureGPUFrameTime: boolean;
  13553. /**
  13554. * Gets the perf counter used for shader compilation time
  13555. */
  13556. readonly shaderCompilationTimeCounter: PerfCounter;
  13557. /**
  13558. * Gets the shader compilation time capture status
  13559. */
  13560. /**
  13561. * Enable or disable the shader compilation time capture
  13562. */
  13563. captureShaderCompilationTime: boolean;
  13564. /**
  13565. * Instantiates a new engine instrumentation.
  13566. * This class can be used to get instrumentation data from a Babylon engine
  13567. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13568. * @param engine Defines the engine to instrument
  13569. */
  13570. constructor(
  13571. /**
  13572. * Define the instrumented engine.
  13573. */
  13574. engine: Engine);
  13575. /**
  13576. * Dispose and release associated resources.
  13577. */
  13578. dispose(): void;
  13579. }
  13580. }
  13581. declare module BABYLON {
  13582. /**
  13583. * This class can be used to get instrumentation data from a Babylon engine
  13584. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  13585. */
  13586. class SceneInstrumentation implements IDisposable {
  13587. /**
  13588. * Defines the scene to instrument
  13589. */
  13590. scene: Scene;
  13591. private _captureActiveMeshesEvaluationTime;
  13592. private _activeMeshesEvaluationTime;
  13593. private _captureRenderTargetsRenderTime;
  13594. private _renderTargetsRenderTime;
  13595. private _captureFrameTime;
  13596. private _frameTime;
  13597. private _captureRenderTime;
  13598. private _renderTime;
  13599. private _captureInterFrameTime;
  13600. private _interFrameTime;
  13601. private _captureParticlesRenderTime;
  13602. private _particlesRenderTime;
  13603. private _captureSpritesRenderTime;
  13604. private _spritesRenderTime;
  13605. private _capturePhysicsTime;
  13606. private _physicsTime;
  13607. private _captureAnimationsTime;
  13608. private _animationsTime;
  13609. private _captureCameraRenderTime;
  13610. private _cameraRenderTime;
  13611. private _onBeforeActiveMeshesEvaluationObserver;
  13612. private _onAfterActiveMeshesEvaluationObserver;
  13613. private _onBeforeRenderTargetsRenderObserver;
  13614. private _onAfterRenderTargetsRenderObserver;
  13615. private _onAfterRenderObserver;
  13616. private _onBeforeDrawPhaseObserver;
  13617. private _onAfterDrawPhaseObserver;
  13618. private _onBeforeAnimationsObserver;
  13619. private _onBeforeParticlesRenderingObserver;
  13620. private _onAfterParticlesRenderingObserver;
  13621. private _onBeforeSpritesRenderingObserver;
  13622. private _onAfterSpritesRenderingObserver;
  13623. private _onBeforePhysicsObserver;
  13624. private _onAfterPhysicsObserver;
  13625. private _onAfterAnimationsObserver;
  13626. private _onBeforeCameraRenderObserver;
  13627. private _onAfterCameraRenderObserver;
  13628. /**
  13629. * Gets the perf counter used for active meshes evaluation time
  13630. */
  13631. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  13632. /**
  13633. * Gets the active meshes evaluation time capture status
  13634. */
  13635. /**
  13636. * Enable or disable the active meshes evaluation time capture
  13637. */
  13638. captureActiveMeshesEvaluationTime: boolean;
  13639. /**
  13640. * Gets the perf counter used for render targets render time
  13641. */
  13642. readonly renderTargetsRenderTimeCounter: PerfCounter;
  13643. /**
  13644. * Gets the render targets render time capture status
  13645. */
  13646. /**
  13647. * Enable or disable the render targets render time capture
  13648. */
  13649. captureRenderTargetsRenderTime: boolean;
  13650. /**
  13651. * Gets the perf counter used for particles render time
  13652. */
  13653. readonly particlesRenderTimeCounter: PerfCounter;
  13654. /**
  13655. * Gets the particles render time capture status
  13656. */
  13657. /**
  13658. * Enable or disable the particles render time capture
  13659. */
  13660. captureParticlesRenderTime: boolean;
  13661. /**
  13662. * Gets the perf counter used for sprites render time
  13663. */
  13664. readonly spritesRenderTimeCounter: PerfCounter;
  13665. /**
  13666. * Gets the sprites render time capture status
  13667. */
  13668. /**
  13669. * Enable or disable the sprites render time capture
  13670. */
  13671. captureSpritesRenderTime: boolean;
  13672. /**
  13673. * Gets the perf counter used for physics time
  13674. */
  13675. readonly physicsTimeCounter: PerfCounter;
  13676. /**
  13677. * Gets the physics time capture status
  13678. */
  13679. /**
  13680. * Enable or disable the physics time capture
  13681. */
  13682. capturePhysicsTime: boolean;
  13683. /**
  13684. * Gets the perf counter used for animations time
  13685. */
  13686. readonly animationsTimeCounter: PerfCounter;
  13687. /**
  13688. * Gets the animations time capture status
  13689. */
  13690. /**
  13691. * Enable or disable the animations time capture
  13692. */
  13693. captureAnimationsTime: boolean;
  13694. /**
  13695. * Gets the perf counter used for frame time capture
  13696. */
  13697. readonly frameTimeCounter: PerfCounter;
  13698. /**
  13699. * Gets the frame time capture status
  13700. */
  13701. /**
  13702. * Enable or disable the frame time capture
  13703. */
  13704. captureFrameTime: boolean;
  13705. /**
  13706. * Gets the perf counter used for inter-frames time capture
  13707. */
  13708. readonly interFrameTimeCounter: PerfCounter;
  13709. /**
  13710. * Gets the inter-frames time capture status
  13711. */
  13712. /**
  13713. * Enable or disable the inter-frames time capture
  13714. */
  13715. captureInterFrameTime: boolean;
  13716. /**
  13717. * Gets the perf counter used for render time capture
  13718. */
  13719. readonly renderTimeCounter: PerfCounter;
  13720. /**
  13721. * Gets the render time capture status
  13722. */
  13723. /**
  13724. * Enable or disable the render time capture
  13725. */
  13726. captureRenderTime: boolean;
  13727. /**
  13728. * Gets the perf counter used for camera render time capture
  13729. */
  13730. readonly cameraRenderTimeCounter: PerfCounter;
  13731. /**
  13732. * Gets the camera render time capture status
  13733. */
  13734. /**
  13735. * Enable or disable the camera render time capture
  13736. */
  13737. captureCameraRenderTime: boolean;
  13738. /**
  13739. * Gets the perf counter used for draw calls
  13740. */
  13741. readonly drawCallsCounter: PerfCounter;
  13742. /**
  13743. * Gets the perf counter used for texture collisions
  13744. */
  13745. readonly textureCollisionsCounter: PerfCounter;
  13746. /**
  13747. * Instantiates a new scene instrumentation.
  13748. * This class can be used to get instrumentation data from a Babylon engine
  13749. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  13750. * @param scene Defines the scene to instrument
  13751. */
  13752. constructor(
  13753. /**
  13754. * Defines the scene to instrument
  13755. */
  13756. scene: Scene);
  13757. /**
  13758. * Dispose and release associated resources.
  13759. */
  13760. dispose(): void;
  13761. }
  13762. }
  13763. declare module BABYLON {
  13764. /**
  13765. * @hidden
  13766. **/
  13767. class _TimeToken {
  13768. _startTimeQuery: Nullable<WebGLQuery>;
  13769. _endTimeQuery: Nullable<WebGLQuery>;
  13770. _timeElapsedQuery: Nullable<WebGLQuery>;
  13771. _timeElapsedQueryEnded: boolean;
  13772. }
  13773. }
  13774. declare module BABYLON {
  13775. /**
  13776. * Represents the different options available during the creation of
  13777. * a Environment helper.
  13778. *
  13779. * This can control the default ground, skybox and image processing setup of your scene.
  13780. */
  13781. interface IEnvironmentHelperOptions {
  13782. /**
  13783. * Specifies wether or not to create a ground.
  13784. * True by default.
  13785. */
  13786. createGround: boolean;
  13787. /**
  13788. * Specifies the ground size.
  13789. * 15 by default.
  13790. */
  13791. groundSize: number;
  13792. /**
  13793. * The texture used on the ground for the main color.
  13794. * Comes from the BabylonJS CDN by default.
  13795. *
  13796. * Remarks: Can be either a texture or a url.
  13797. */
  13798. groundTexture: string | BaseTexture;
  13799. /**
  13800. * The color mixed in the ground texture by default.
  13801. * BabylonJS clearColor by default.
  13802. */
  13803. groundColor: Color3;
  13804. /**
  13805. * Specifies the ground opacity.
  13806. * 1 by default.
  13807. */
  13808. groundOpacity: number;
  13809. /**
  13810. * Enables the ground to receive shadows.
  13811. * True by default.
  13812. */
  13813. enableGroundShadow: boolean;
  13814. /**
  13815. * Helps preventing the shadow to be fully black on the ground.
  13816. * 0.5 by default.
  13817. */
  13818. groundShadowLevel: number;
  13819. /**
  13820. * Creates a mirror texture attach to the ground.
  13821. * false by default.
  13822. */
  13823. enableGroundMirror: boolean;
  13824. /**
  13825. * Specifies the ground mirror size ratio.
  13826. * 0.3 by default as the default kernel is 64.
  13827. */
  13828. groundMirrorSizeRatio: number;
  13829. /**
  13830. * Specifies the ground mirror blur kernel size.
  13831. * 64 by default.
  13832. */
  13833. groundMirrorBlurKernel: number;
  13834. /**
  13835. * Specifies the ground mirror visibility amount.
  13836. * 1 by default
  13837. */
  13838. groundMirrorAmount: number;
  13839. /**
  13840. * Specifies the ground mirror reflectance weight.
  13841. * This uses the standard weight of the background material to setup the fresnel effect
  13842. * of the mirror.
  13843. * 1 by default.
  13844. */
  13845. groundMirrorFresnelWeight: number;
  13846. /**
  13847. * Specifies the ground mirror Falloff distance.
  13848. * This can helps reducing the size of the reflection.
  13849. * 0 by Default.
  13850. */
  13851. groundMirrorFallOffDistance: number;
  13852. /**
  13853. * Specifies the ground mirror texture type.
  13854. * Unsigned Int by Default.
  13855. */
  13856. groundMirrorTextureType: number;
  13857. /**
  13858. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13859. * the shown objects.
  13860. */
  13861. groundYBias: number;
  13862. /**
  13863. * Specifies wether or not to create a skybox.
  13864. * True by default.
  13865. */
  13866. createSkybox: boolean;
  13867. /**
  13868. * Specifies the skybox size.
  13869. * 20 by default.
  13870. */
  13871. skyboxSize: number;
  13872. /**
  13873. * The texture used on the skybox for the main color.
  13874. * Comes from the BabylonJS CDN by default.
  13875. *
  13876. * Remarks: Can be either a texture or a url.
  13877. */
  13878. skyboxTexture: string | BaseTexture;
  13879. /**
  13880. * The color mixed in the skybox texture by default.
  13881. * BabylonJS clearColor by default.
  13882. */
  13883. skyboxColor: Color3;
  13884. /**
  13885. * The background rotation around the Y axis of the scene.
  13886. * This helps aligning the key lights of your scene with the background.
  13887. * 0 by default.
  13888. */
  13889. backgroundYRotation: number;
  13890. /**
  13891. * Compute automatically the size of the elements to best fit with the scene.
  13892. */
  13893. sizeAuto: boolean;
  13894. /**
  13895. * Default position of the rootMesh if autoSize is not true.
  13896. */
  13897. rootPosition: Vector3;
  13898. /**
  13899. * Sets up the image processing in the scene.
  13900. * true by default.
  13901. */
  13902. setupImageProcessing: boolean;
  13903. /**
  13904. * The texture used as your environment texture in the scene.
  13905. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13906. *
  13907. * Remarks: Can be either a texture or a url.
  13908. */
  13909. environmentTexture: string | BaseTexture;
  13910. /**
  13911. * The value of the exposure to apply to the scene.
  13912. * 0.6 by default if setupImageProcessing is true.
  13913. */
  13914. cameraExposure: number;
  13915. /**
  13916. * The value of the contrast to apply to the scene.
  13917. * 1.6 by default if setupImageProcessing is true.
  13918. */
  13919. cameraContrast: number;
  13920. /**
  13921. * Specifies wether or not tonemapping should be enabled in the scene.
  13922. * true by default if setupImageProcessing is true.
  13923. */
  13924. toneMappingEnabled: boolean;
  13925. }
  13926. /**
  13927. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13928. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13929. * It also helps with the default setup of your imageProcessing configuration.
  13930. */
  13931. class EnvironmentHelper {
  13932. /**
  13933. * Default ground texture URL.
  13934. */
  13935. private static _groundTextureCDNUrl;
  13936. /**
  13937. * Default skybox texture URL.
  13938. */
  13939. private static _skyboxTextureCDNUrl;
  13940. /**
  13941. * Default environment texture URL.
  13942. */
  13943. private static _environmentTextureCDNUrl;
  13944. /**
  13945. * Creates the default options for the helper.
  13946. */
  13947. private static _getDefaultOptions;
  13948. private _rootMesh;
  13949. /**
  13950. * Gets the root mesh created by the helper.
  13951. */
  13952. readonly rootMesh: Mesh;
  13953. private _skybox;
  13954. /**
  13955. * Gets the skybox created by the helper.
  13956. */
  13957. readonly skybox: Nullable<Mesh>;
  13958. private _skyboxTexture;
  13959. /**
  13960. * Gets the skybox texture created by the helper.
  13961. */
  13962. readonly skyboxTexture: Nullable<BaseTexture>;
  13963. private _skyboxMaterial;
  13964. /**
  13965. * Gets the skybox material created by the helper.
  13966. */
  13967. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13968. private _ground;
  13969. /**
  13970. * Gets the ground mesh created by the helper.
  13971. */
  13972. readonly ground: Nullable<Mesh>;
  13973. private _groundTexture;
  13974. /**
  13975. * Gets the ground texture created by the helper.
  13976. */
  13977. readonly groundTexture: Nullable<BaseTexture>;
  13978. private _groundMirror;
  13979. /**
  13980. * Gets the ground mirror created by the helper.
  13981. */
  13982. readonly groundMirror: Nullable<MirrorTexture>;
  13983. /**
  13984. * Gets the ground mirror render list to helps pushing the meshes
  13985. * you wish in the ground reflection.
  13986. */
  13987. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13988. private _groundMaterial;
  13989. /**
  13990. * Gets the ground material created by the helper.
  13991. */
  13992. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13993. /**
  13994. * Stores the creation options.
  13995. */
  13996. private readonly _scene;
  13997. private _options;
  13998. /**
  13999. * This observable will be notified with any error during the creation of the environment,
  14000. * mainly texture creation errors.
  14001. */
  14002. onErrorObservable: Observable<{
  14003. message?: string;
  14004. exception?: any;
  14005. }>;
  14006. /**
  14007. * constructor
  14008. * @param options
  14009. * @param scene The scene to add the material to
  14010. */
  14011. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  14012. /**
  14013. * Updates the background according to the new options
  14014. * @param options
  14015. */
  14016. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  14017. /**
  14018. * Sets the primary color of all the available elements.
  14019. * @param color the main color to affect to the ground and the background
  14020. */
  14021. setMainColor(color: Color3): void;
  14022. /**
  14023. * Setup the image processing according to the specified options.
  14024. */
  14025. private _setupImageProcessing;
  14026. /**
  14027. * Setup the environment texture according to the specified options.
  14028. */
  14029. private _setupEnvironmentTexture;
  14030. /**
  14031. * Setup the background according to the specified options.
  14032. */
  14033. private _setupBackground;
  14034. /**
  14035. * Get the scene sizes according to the setup.
  14036. */
  14037. private _getSceneSize;
  14038. /**
  14039. * Setup the ground according to the specified options.
  14040. */
  14041. private _setupGround;
  14042. /**
  14043. * Setup the ground material according to the specified options.
  14044. */
  14045. private _setupGroundMaterial;
  14046. /**
  14047. * Setup the ground diffuse texture according to the specified options.
  14048. */
  14049. private _setupGroundDiffuseTexture;
  14050. /**
  14051. * Setup the ground mirror texture according to the specified options.
  14052. */
  14053. private _setupGroundMirrorTexture;
  14054. /**
  14055. * Setup the ground to receive the mirror texture.
  14056. */
  14057. private _setupMirrorInGroundMaterial;
  14058. /**
  14059. * Setup the skybox according to the specified options.
  14060. */
  14061. private _setupSkybox;
  14062. /**
  14063. * Setup the skybox material according to the specified options.
  14064. */
  14065. private _setupSkyboxMaterial;
  14066. /**
  14067. * Setup the skybox reflection texture according to the specified options.
  14068. */
  14069. private _setupSkyboxReflectionTexture;
  14070. private _errorHandler;
  14071. /**
  14072. * Dispose all the elements created by the Helper.
  14073. */
  14074. dispose(): void;
  14075. }
  14076. }
  14077. declare module BABYLON {
  14078. /**
  14079. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  14080. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  14081. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  14082. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  14083. */
  14084. class PhotoDome extends TransformNode {
  14085. private _useDirectMapping;
  14086. /**
  14087. * The texture being displayed on the sphere
  14088. */
  14089. protected _photoTexture: Texture;
  14090. /**
  14091. * Gets or sets the texture being displayed on the sphere
  14092. */
  14093. photoTexture: Texture;
  14094. /**
  14095. * Observable raised when an error occured while loading the 360 image
  14096. */
  14097. onLoadErrorObservable: Observable<string>;
  14098. /**
  14099. * The skybox material
  14100. */
  14101. protected _material: BackgroundMaterial;
  14102. /**
  14103. * The surface used for the skybox
  14104. */
  14105. protected _mesh: Mesh;
  14106. /**
  14107. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  14108. * Also see the options.resolution property.
  14109. */
  14110. fovMultiplier: number;
  14111. /**
  14112. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  14113. * @param name Element's name, child elements will append suffixes for their own names.
  14114. * @param urlsOfPhoto defines the url of the photo to display
  14115. * @param options defines an object containing optional or exposed sub element properties
  14116. * @param onError defines a callback called when an error occured while loading the texture
  14117. */
  14118. constructor(name: string, urlOfPhoto: string, options: {
  14119. resolution?: number;
  14120. size?: number;
  14121. useDirectMapping?: boolean;
  14122. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  14123. /**
  14124. * Releases resources associated with this node.
  14125. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14126. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14127. */
  14128. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14129. }
  14130. }
  14131. declare module BABYLON {
  14132. interface Scene {
  14133. /**
  14134. * Creates a default light for the scene.
  14135. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  14136. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  14137. */
  14138. createDefaultLight(replace?: boolean): void;
  14139. /**
  14140. * Creates a default camera for the scene.
  14141. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  14142. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  14143. * @param replace has default false, when true replaces the active camera in the scene
  14144. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  14145. */
  14146. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  14147. /**
  14148. * Creates a default camera and a default light.
  14149. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  14150. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  14151. * @param replace has the default false, when true replaces the active camera/light in the scene
  14152. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  14153. */
  14154. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  14155. /**
  14156. * Creates a new sky box
  14157. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  14158. * @param environmentTexture defines the texture to use as environment texture
  14159. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  14160. * @param scale defines the overall scale of the skybox
  14161. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  14162. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  14163. * @returns a new mesh holding the sky box
  14164. */
  14165. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  14166. /**
  14167. * Creates a new environment
  14168. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  14169. * @param options defines the options you can use to configure the environment
  14170. * @returns the new EnvironmentHelper
  14171. */
  14172. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  14173. /**
  14174. * Creates a new VREXperienceHelper
  14175. * @see http://doc.babylonjs.com/how_to/webvr_helper
  14176. * @param webVROptions defines the options used to create the new VREXperienceHelper
  14177. * @returns a new VREXperienceHelper
  14178. */
  14179. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  14180. /**
  14181. * Creates a new XREXperienceHelper
  14182. * @see http://doc.babylonjs.com/how_to/webxr
  14183. * @returns a promise for a new XREXperienceHelper
  14184. */
  14185. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  14186. }
  14187. }
  14188. declare module BABYLON {
  14189. /**
  14190. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  14191. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  14192. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  14193. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  14194. */
  14195. class VideoDome extends TransformNode {
  14196. private _useDirectMapping;
  14197. /**
  14198. * The video texture being displayed on the sphere
  14199. */
  14200. protected _videoTexture: VideoTexture;
  14201. /**
  14202. * Gets the video texture being displayed on the sphere
  14203. */
  14204. readonly videoTexture: VideoTexture;
  14205. /**
  14206. * The skybox material
  14207. */
  14208. protected _material: BackgroundMaterial;
  14209. /**
  14210. * The surface used for the skybox
  14211. */
  14212. protected _mesh: Mesh;
  14213. /**
  14214. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  14215. * Also see the options.resolution property.
  14216. */
  14217. fovMultiplier: number;
  14218. /**
  14219. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  14220. * @param name Element's name, child elements will append suffixes for their own names.
  14221. * @param urlsOrVideo defines the url(s) or the video element to use
  14222. * @param options An object containing optional or exposed sub element properties
  14223. */
  14224. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  14225. resolution?: number;
  14226. clickToPlay?: boolean;
  14227. autoPlay?: boolean;
  14228. loop?: boolean;
  14229. size?: number;
  14230. poster?: string;
  14231. useDirectMapping?: boolean;
  14232. }, scene: Scene);
  14233. /**
  14234. * Releases resources associated with this node.
  14235. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14236. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14237. */
  14238. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14239. }
  14240. }
  14241. declare module BABYLON {
  14242. /**
  14243. * Effect layer options. This helps customizing the behaviour
  14244. * of the effect layer.
  14245. */
  14246. interface IEffectLayerOptions {
  14247. /**
  14248. * Multiplication factor apply to the canvas size to compute the render target size
  14249. * used to generated the objects (the smaller the faster).
  14250. */
  14251. mainTextureRatio: number;
  14252. /**
  14253. * Enforces a fixed size texture to ensure effect stability across devices.
  14254. */
  14255. mainTextureFixedSize?: number;
  14256. /**
  14257. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14258. */
  14259. alphaBlendingMode: number;
  14260. /**
  14261. * The camera attached to the layer.
  14262. */
  14263. camera: Nullable<Camera>;
  14264. /**
  14265. * The rendering group to draw the layer in.
  14266. */
  14267. renderingGroupId: number;
  14268. }
  14269. /**
  14270. * The effect layer Helps adding post process effect blended with the main pass.
  14271. *
  14272. * This can be for instance use to generate glow or higlight effects on the scene.
  14273. *
  14274. * The effect layer class can not be used directly and is intented to inherited from to be
  14275. * customized per effects.
  14276. */
  14277. abstract class EffectLayer {
  14278. private _vertexBuffers;
  14279. private _indexBuffer;
  14280. private _cachedDefines;
  14281. private _effectLayerMapGenerationEffect;
  14282. private _effectLayerOptions;
  14283. private _mergeEffect;
  14284. protected _scene: Scene;
  14285. protected _engine: Engine;
  14286. protected _maxSize: number;
  14287. protected _mainTextureDesiredSize: ISize;
  14288. protected _mainTexture: RenderTargetTexture;
  14289. protected _shouldRender: boolean;
  14290. protected _postProcesses: PostProcess[];
  14291. protected _textures: BaseTexture[];
  14292. protected _emissiveTextureAndColor: {
  14293. texture: Nullable<BaseTexture>;
  14294. color: Color4;
  14295. };
  14296. /**
  14297. * The name of the layer
  14298. */
  14299. name: string;
  14300. /**
  14301. * The clear color of the texture used to generate the glow map.
  14302. */
  14303. neutralColor: Color4;
  14304. /**
  14305. * Specifies wether the highlight layer is enabled or not.
  14306. */
  14307. isEnabled: boolean;
  14308. /**
  14309. * Gets the camera attached to the layer.
  14310. */
  14311. readonly camera: Nullable<Camera>;
  14312. /**
  14313. * Gets the rendering group id the layer should render in.
  14314. */
  14315. readonly renderingGroupId: number;
  14316. /**
  14317. * An event triggered when the effect layer has been disposed.
  14318. */
  14319. onDisposeObservable: Observable<EffectLayer>;
  14320. /**
  14321. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14322. */
  14323. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14324. /**
  14325. * An event triggered when the generated texture is being merged in the scene.
  14326. */
  14327. onBeforeComposeObservable: Observable<EffectLayer>;
  14328. /**
  14329. * An event triggered when the generated texture has been merged in the scene.
  14330. */
  14331. onAfterComposeObservable: Observable<EffectLayer>;
  14332. /**
  14333. * An event triggered when the efffect layer changes its size.
  14334. */
  14335. onSizeChangedObservable: Observable<EffectLayer>;
  14336. /**
  14337. * Instantiates a new effect Layer and references it in the scene.
  14338. * @param name The name of the layer
  14339. * @param scene The scene to use the layer in
  14340. */
  14341. constructor(
  14342. /** The Friendly of the effect in the scene */
  14343. name: string, scene: Scene);
  14344. /**
  14345. * Get the effect name of the layer.
  14346. * @return The effect name
  14347. */
  14348. abstract getEffectName(): string;
  14349. /**
  14350. * Checks for the readiness of the element composing the layer.
  14351. * @param subMesh the mesh to check for
  14352. * @param useInstances specify wether or not to use instances to render the mesh
  14353. * @return true if ready otherwise, false
  14354. */
  14355. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14356. /**
  14357. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14358. * @returns true if the effect requires stencil during the main canvas render pass.
  14359. */
  14360. abstract needStencil(): boolean;
  14361. /**
  14362. * Create the merge effect. This is the shader use to blit the information back
  14363. * to the main canvas at the end of the scene rendering.
  14364. * @returns The effect containing the shader used to merge the effect on the main canvas
  14365. */
  14366. protected abstract _createMergeEffect(): Effect;
  14367. /**
  14368. * Creates the render target textures and post processes used in the effect layer.
  14369. */
  14370. protected abstract _createTextureAndPostProcesses(): void;
  14371. /**
  14372. * Implementation specific of rendering the generating effect on the main canvas.
  14373. * @param effect The effect used to render through
  14374. */
  14375. protected abstract _internalRender(effect: Effect): void;
  14376. /**
  14377. * Sets the required values for both the emissive texture and and the main color.
  14378. */
  14379. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14380. /**
  14381. * Free any resources and references associated to a mesh.
  14382. * Internal use
  14383. * @param mesh The mesh to free.
  14384. */
  14385. abstract _disposeMesh(mesh: Mesh): void;
  14386. /**
  14387. * Serializes this layer (Glow or Highlight for example)
  14388. * @returns a serialized layer object
  14389. */
  14390. abstract serialize?(): any;
  14391. /**
  14392. * Initializes the effect layer with the required options.
  14393. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14394. */
  14395. protected _init(options: Partial<IEffectLayerOptions>): void;
  14396. /**
  14397. * Generates the index buffer of the full screen quad blending to the main canvas.
  14398. */
  14399. private _generateIndexBuffer;
  14400. /**
  14401. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14402. */
  14403. private _genrateVertexBuffer;
  14404. /**
  14405. * Sets the main texture desired size which is the closest power of two
  14406. * of the engine canvas size.
  14407. */
  14408. private _setMainTextureSize;
  14409. /**
  14410. * Creates the main texture for the effect layer.
  14411. */
  14412. protected _createMainTexture(): void;
  14413. /**
  14414. * Checks for the readiness of the element composing the layer.
  14415. * @param subMesh the mesh to check for
  14416. * @param useInstances specify wether or not to use instances to render the mesh
  14417. * @param emissiveTexture the associated emissive texture used to generate the glow
  14418. * @return true if ready otherwise, false
  14419. */
  14420. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14421. /**
  14422. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14423. */
  14424. render(): void;
  14425. /**
  14426. * Determine if a given mesh will be used in the current effect.
  14427. * @param mesh mesh to test
  14428. * @returns true if the mesh will be used
  14429. */
  14430. hasMesh(mesh: AbstractMesh): boolean;
  14431. /**
  14432. * Returns true if the layer contains information to display, otherwise false.
  14433. * @returns true if the glow layer should be rendered
  14434. */
  14435. shouldRender(): boolean;
  14436. /**
  14437. * Returns true if the mesh should render, otherwise false.
  14438. * @param mesh The mesh to render
  14439. * @returns true if it should render otherwise false
  14440. */
  14441. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14442. /**
  14443. * Returns true if the mesh should render, otherwise false.
  14444. * @param mesh The mesh to render
  14445. * @returns true if it should render otherwise false
  14446. */
  14447. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14448. /**
  14449. * Renders the submesh passed in parameter to the generation map.
  14450. */
  14451. protected _renderSubMesh(subMesh: SubMesh): void;
  14452. /**
  14453. * Rebuild the required buffers.
  14454. * @hidden Internal use only.
  14455. */
  14456. _rebuild(): void;
  14457. /**
  14458. * Dispose only the render target textures and post process.
  14459. */
  14460. private _disposeTextureAndPostProcesses;
  14461. /**
  14462. * Dispose the highlight layer and free resources.
  14463. */
  14464. dispose(): void;
  14465. /**
  14466. * Gets the class name of the effect layer
  14467. * @returns the string with the class name of the effect layer
  14468. */
  14469. getClassName(): string;
  14470. /**
  14471. * Creates an effect layer from parsed effect layer data
  14472. * @param parsedEffectLayer defines effect layer data
  14473. * @param scene defines the current scene
  14474. * @param rootUrl defines the root URL containing the effect layer information
  14475. * @returns a parsed effect Layer
  14476. */
  14477. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14478. }
  14479. }
  14480. declare module BABYLON {
  14481. interface AbstractScene {
  14482. /**
  14483. * The list of effect layers (highlights/glow) added to the scene
  14484. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14485. * @see http://doc.babylonjs.com/how_to/glow_layer
  14486. */
  14487. effectLayers: Array<EffectLayer>;
  14488. /**
  14489. * Removes the given effect layer from this scene.
  14490. * @param toRemove defines the effect layer to remove
  14491. * @returns the index of the removed effect layer
  14492. */
  14493. removeEffectLayer(toRemove: EffectLayer): number;
  14494. /**
  14495. * Adds the given effect layer to this scene
  14496. * @param newEffectLayer defines the effect layer to add
  14497. */
  14498. addEffectLayer(newEffectLayer: EffectLayer): void;
  14499. }
  14500. /**
  14501. * Defines the layer scene component responsible to manage any effect layers
  14502. * in a given scene.
  14503. */
  14504. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14505. /**
  14506. * The component name helpfull to identify the component in the list of scene components.
  14507. */
  14508. readonly name: string;
  14509. /**
  14510. * The scene the component belongs to.
  14511. */
  14512. scene: Scene;
  14513. private _engine;
  14514. private _renderEffects;
  14515. private _needStencil;
  14516. private _previousStencilState;
  14517. /**
  14518. * Creates a new instance of the component for the given scene
  14519. * @param scene Defines the scene to register the component in
  14520. */
  14521. constructor(scene: Scene);
  14522. /**
  14523. * Registers the component in a given scene
  14524. */
  14525. register(): void;
  14526. /**
  14527. * Rebuilds the elements related to this component in case of
  14528. * context lost for instance.
  14529. */
  14530. rebuild(): void;
  14531. /**
  14532. * Serializes the component data to the specified json object
  14533. * @param serializationObject The object to serialize to
  14534. */
  14535. serialize(serializationObject: any): void;
  14536. /**
  14537. * Adds all the element from the container to the scene
  14538. * @param container the container holding the elements
  14539. */
  14540. addFromContainer(container: AbstractScene): void;
  14541. /**
  14542. * Removes all the elements in the container from the scene
  14543. * @param container contains the elements to remove
  14544. */
  14545. removeFromContainer(container: AbstractScene): void;
  14546. /**
  14547. * Disposes the component and the associated ressources.
  14548. */
  14549. dispose(): void;
  14550. private _isReadyForMesh;
  14551. private _renderMainTexture;
  14552. private _setStencil;
  14553. private _setStencilBack;
  14554. private _draw;
  14555. private _drawCamera;
  14556. private _drawRenderingGroup;
  14557. }
  14558. }
  14559. declare module BABYLON {
  14560. interface AbstractScene {
  14561. /**
  14562. * Return a the first highlight layer of the scene with a given name.
  14563. * @param name The name of the highlight layer to look for.
  14564. * @return The highlight layer if found otherwise null.
  14565. */
  14566. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14567. }
  14568. /**
  14569. * Glow layer options. This helps customizing the behaviour
  14570. * of the glow layer.
  14571. */
  14572. interface IGlowLayerOptions {
  14573. /**
  14574. * Multiplication factor apply to the canvas size to compute the render target size
  14575. * used to generated the glowing objects (the smaller the faster).
  14576. */
  14577. mainTextureRatio: number;
  14578. /**
  14579. * Enforces a fixed size texture to ensure resize independant blur.
  14580. */
  14581. mainTextureFixedSize?: number;
  14582. /**
  14583. * How big is the kernel of the blur texture.
  14584. */
  14585. blurKernelSize: number;
  14586. /**
  14587. * The camera attached to the layer.
  14588. */
  14589. camera: Nullable<Camera>;
  14590. /**
  14591. * Enable MSAA by chosing the number of samples.
  14592. */
  14593. mainTextureSamples?: number;
  14594. /**
  14595. * The rendering group to draw the layer in.
  14596. */
  14597. renderingGroupId: number;
  14598. }
  14599. /**
  14600. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14601. *
  14602. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14603. * glowy meshes to your scene.
  14604. *
  14605. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14606. */
  14607. class GlowLayer extends EffectLayer {
  14608. /**
  14609. * Effect Name of the layer.
  14610. */
  14611. static readonly EffectName: string;
  14612. /**
  14613. * The default blur kernel size used for the glow.
  14614. */
  14615. static DefaultBlurKernelSize: number;
  14616. /**
  14617. * The default texture size ratio used for the glow.
  14618. */
  14619. static DefaultTextureRatio: number;
  14620. /**
  14621. * Sets the kernel size of the blur.
  14622. */
  14623. /**
  14624. * Gets the kernel size of the blur.
  14625. */
  14626. blurKernelSize: number;
  14627. /**
  14628. * Sets the glow intensity.
  14629. */
  14630. /**
  14631. * Gets the glow intensity.
  14632. */
  14633. intensity: number;
  14634. private _options;
  14635. private _intensity;
  14636. private _horizontalBlurPostprocess1;
  14637. private _verticalBlurPostprocess1;
  14638. private _horizontalBlurPostprocess2;
  14639. private _verticalBlurPostprocess2;
  14640. private _blurTexture1;
  14641. private _blurTexture2;
  14642. private _postProcesses1;
  14643. private _postProcesses2;
  14644. private _includedOnlyMeshes;
  14645. private _excludedMeshes;
  14646. /**
  14647. * Callback used to let the user override the color selection on a per mesh basis
  14648. */
  14649. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14650. /**
  14651. * Callback used to let the user override the texture selection on a per mesh basis
  14652. */
  14653. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14654. /**
  14655. * Instantiates a new glow Layer and references it to the scene.
  14656. * @param name The name of the layer
  14657. * @param scene The scene to use the layer in
  14658. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14659. */
  14660. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14661. /**
  14662. * Get the effect name of the layer.
  14663. * @return The effect name
  14664. */
  14665. getEffectName(): string;
  14666. /**
  14667. * Create the merge effect. This is the shader use to blit the information back
  14668. * to the main canvas at the end of the scene rendering.
  14669. */
  14670. protected _createMergeEffect(): Effect;
  14671. /**
  14672. * Creates the render target textures and post processes used in the glow layer.
  14673. */
  14674. protected _createTextureAndPostProcesses(): void;
  14675. /**
  14676. * Checks for the readiness of the element composing the layer.
  14677. * @param subMesh the mesh to check for
  14678. * @param useInstances specify wether or not to use instances to render the mesh
  14679. * @param emissiveTexture the associated emissive texture used to generate the glow
  14680. * @return true if ready otherwise, false
  14681. */
  14682. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14683. /**
  14684. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14685. */
  14686. needStencil(): boolean;
  14687. /**
  14688. * Implementation specific of rendering the generating effect on the main canvas.
  14689. * @param effect The effect used to render through
  14690. */
  14691. protected _internalRender(effect: Effect): void;
  14692. /**
  14693. * Sets the required values for both the emissive texture and and the main color.
  14694. */
  14695. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14696. /**
  14697. * Returns true if the mesh should render, otherwise false.
  14698. * @param mesh The mesh to render
  14699. * @returns true if it should render otherwise false
  14700. */
  14701. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14702. /**
  14703. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14704. * @param mesh The mesh to exclude from the glow layer
  14705. */
  14706. addExcludedMesh(mesh: Mesh): void;
  14707. /**
  14708. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14709. * @param mesh The mesh to remove
  14710. */
  14711. removeExcludedMesh(mesh: Mesh): void;
  14712. /**
  14713. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14714. * @param mesh The mesh to include in the glow layer
  14715. */
  14716. addIncludedOnlyMesh(mesh: Mesh): void;
  14717. /**
  14718. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14719. * @param mesh The mesh to remove
  14720. */
  14721. removeIncludedOnlyMesh(mesh: Mesh): void;
  14722. /**
  14723. * Determine if a given mesh will be used in the glow layer
  14724. * @param mesh The mesh to test
  14725. * @returns true if the mesh will be highlighted by the current glow layer
  14726. */
  14727. hasMesh(mesh: AbstractMesh): boolean;
  14728. /**
  14729. * Free any resources and references associated to a mesh.
  14730. * Internal use
  14731. * @param mesh The mesh to free.
  14732. * @hidden
  14733. */
  14734. _disposeMesh(mesh: Mesh): void;
  14735. /**
  14736. * Gets the class name of the effect layer
  14737. * @returns the string with the class name of the effect layer
  14738. */
  14739. getClassName(): string;
  14740. /**
  14741. * Serializes this glow layer
  14742. * @returns a serialized glow layer object
  14743. */
  14744. serialize(): any;
  14745. /**
  14746. * Creates a Glow Layer from parsed glow layer data
  14747. * @param parsedGlowLayer defines glow layer data
  14748. * @param scene defines the current scene
  14749. * @param rootUrl defines the root URL containing the glow layer information
  14750. * @returns a parsed Glow Layer
  14751. */
  14752. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14753. }
  14754. }
  14755. declare module BABYLON {
  14756. interface AbstractScene {
  14757. /**
  14758. * Return a the first highlight layer of the scene with a given name.
  14759. * @param name The name of the highlight layer to look for.
  14760. * @return The highlight layer if found otherwise null.
  14761. */
  14762. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14763. }
  14764. /**
  14765. * Highlight layer options. This helps customizing the behaviour
  14766. * of the highlight layer.
  14767. */
  14768. interface IHighlightLayerOptions {
  14769. /**
  14770. * Multiplication factor apply to the canvas size to compute the render target size
  14771. * used to generated the glowing objects (the smaller the faster).
  14772. */
  14773. mainTextureRatio: number;
  14774. /**
  14775. * Enforces a fixed size texture to ensure resize independant blur.
  14776. */
  14777. mainTextureFixedSize?: number;
  14778. /**
  14779. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14780. * of the picture to blur (the smaller the faster).
  14781. */
  14782. blurTextureSizeRatio: number;
  14783. /**
  14784. * How big in texel of the blur texture is the vertical blur.
  14785. */
  14786. blurVerticalSize: number;
  14787. /**
  14788. * How big in texel of the blur texture is the horizontal blur.
  14789. */
  14790. blurHorizontalSize: number;
  14791. /**
  14792. * Alpha blending mode used to apply the blur. Default is combine.
  14793. */
  14794. alphaBlendingMode: number;
  14795. /**
  14796. * The camera attached to the layer.
  14797. */
  14798. camera: Nullable<Camera>;
  14799. /**
  14800. * Should we display highlight as a solid stroke?
  14801. */
  14802. isStroke?: boolean;
  14803. /**
  14804. * The rendering group to draw the layer in.
  14805. */
  14806. renderingGroupId: number;
  14807. }
  14808. /**
  14809. * The highlight layer Helps adding a glow effect around a mesh.
  14810. *
  14811. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14812. * glowy meshes to your scene.
  14813. *
  14814. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14815. */
  14816. class HighlightLayer extends EffectLayer {
  14817. name: string;
  14818. /**
  14819. * Effect Name of the highlight layer.
  14820. */
  14821. static readonly EffectName: string;
  14822. /**
  14823. * The neutral color used during the preparation of the glow effect.
  14824. * This is black by default as the blend operation is a blend operation.
  14825. */
  14826. static NeutralColor: Color4;
  14827. /**
  14828. * Stencil value used for glowing meshes.
  14829. */
  14830. static GlowingMeshStencilReference: number;
  14831. /**
  14832. * Stencil value used for the other meshes in the scene.
  14833. */
  14834. static NormalMeshStencilReference: number;
  14835. /**
  14836. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14837. */
  14838. innerGlow: boolean;
  14839. /**
  14840. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14841. */
  14842. outerGlow: boolean;
  14843. /**
  14844. * Specifies the horizontal size of the blur.
  14845. */
  14846. /**
  14847. * Gets the horizontal size of the blur.
  14848. */
  14849. blurHorizontalSize: number;
  14850. /**
  14851. * Specifies the vertical size of the blur.
  14852. */
  14853. /**
  14854. * Gets the vertical size of the blur.
  14855. */
  14856. blurVerticalSize: number;
  14857. /**
  14858. * An event triggered when the highlight layer is being blurred.
  14859. */
  14860. onBeforeBlurObservable: Observable<HighlightLayer>;
  14861. /**
  14862. * An event triggered when the highlight layer has been blurred.
  14863. */
  14864. onAfterBlurObservable: Observable<HighlightLayer>;
  14865. private _instanceGlowingMeshStencilReference;
  14866. private _options;
  14867. private _downSamplePostprocess;
  14868. private _horizontalBlurPostprocess;
  14869. private _verticalBlurPostprocess;
  14870. private _blurTexture;
  14871. private _meshes;
  14872. private _excludedMeshes;
  14873. /**
  14874. * Instantiates a new highlight Layer and references it to the scene..
  14875. * @param name The name of the layer
  14876. * @param scene The scene to use the layer in
  14877. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  14878. */
  14879. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  14880. /**
  14881. * Get the effect name of the layer.
  14882. * @return The effect name
  14883. */
  14884. getEffectName(): string;
  14885. /**
  14886. * Create the merge effect. This is the shader use to blit the information back
  14887. * to the main canvas at the end of the scene rendering.
  14888. */
  14889. protected _createMergeEffect(): Effect;
  14890. /**
  14891. * Creates the render target textures and post processes used in the highlight layer.
  14892. */
  14893. protected _createTextureAndPostProcesses(): void;
  14894. /**
  14895. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14896. */
  14897. needStencil(): boolean;
  14898. /**
  14899. * Checks for the readiness of the element composing the layer.
  14900. * @param subMesh the mesh to check for
  14901. * @param useInstances specify wether or not to use instances to render the mesh
  14902. * @param emissiveTexture the associated emissive texture used to generate the glow
  14903. * @return true if ready otherwise, false
  14904. */
  14905. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14906. /**
  14907. * Implementation specific of rendering the generating effect on the main canvas.
  14908. * @param effect The effect used to render through
  14909. */
  14910. protected _internalRender(effect: Effect): void;
  14911. /**
  14912. * Returns true if the layer contains information to display, otherwise false.
  14913. */
  14914. shouldRender(): boolean;
  14915. /**
  14916. * Returns true if the mesh should render, otherwise false.
  14917. * @param mesh The mesh to render
  14918. * @returns true if it should render otherwise false
  14919. */
  14920. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14921. /**
  14922. * Sets the required values for both the emissive texture and and the main color.
  14923. */
  14924. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14925. /**
  14926. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  14927. * @param mesh The mesh to exclude from the highlight layer
  14928. */
  14929. addExcludedMesh(mesh: Mesh): void;
  14930. /**
  14931. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  14932. * @param mesh The mesh to highlight
  14933. */
  14934. removeExcludedMesh(mesh: Mesh): void;
  14935. /**
  14936. * Determine if a given mesh will be highlighted by the current HighlightLayer
  14937. * @param mesh mesh to test
  14938. * @returns true if the mesh will be highlighted by the current HighlightLayer
  14939. */
  14940. hasMesh(mesh: AbstractMesh): boolean;
  14941. /**
  14942. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  14943. * @param mesh The mesh to highlight
  14944. * @param color The color of the highlight
  14945. * @param glowEmissiveOnly Extract the glow from the emissive texture
  14946. */
  14947. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  14948. /**
  14949. * Remove a mesh from the highlight layer in order to make it stop glowing.
  14950. * @param mesh The mesh to highlight
  14951. */
  14952. removeMesh(mesh: Mesh): void;
  14953. /**
  14954. * Force the stencil to the normal expected value for none glowing parts
  14955. */
  14956. private _defaultStencilReference;
  14957. /**
  14958. * Free any resources and references associated to a mesh.
  14959. * Internal use
  14960. * @param mesh The mesh to free.
  14961. * @hidden
  14962. */
  14963. _disposeMesh(mesh: Mesh): void;
  14964. /**
  14965. * Dispose the highlight layer and free resources.
  14966. */
  14967. dispose(): void;
  14968. /**
  14969. * Gets the class name of the effect layer
  14970. * @returns the string with the class name of the effect layer
  14971. */
  14972. getClassName(): string;
  14973. /**
  14974. * Serializes this Highlight layer
  14975. * @returns a serialized Highlight layer object
  14976. */
  14977. serialize(): any;
  14978. /**
  14979. * Creates a Highlight layer from parsed Highlight layer data
  14980. * @param parsedHightlightLayer defines the Highlight layer data
  14981. * @param scene defines the current scene
  14982. * @param rootUrl defines the root URL containing the Highlight layer information
  14983. * @returns a parsed Highlight layer
  14984. */
  14985. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  14986. }
  14987. }
  14988. declare module BABYLON {
  14989. /**
  14990. * This represents a full screen 2d layer.
  14991. * This can be usefull to display a picture in the background of your scene for instance.
  14992. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14993. */
  14994. class Layer {
  14995. /**
  14996. * Define the name of the layer.
  14997. */
  14998. name: string;
  14999. /**
  15000. * Define the texture the layer should display.
  15001. */
  15002. texture: Nullable<Texture>;
  15003. /**
  15004. * Is the layer in background or foreground.
  15005. */
  15006. isBackground: boolean;
  15007. /**
  15008. * Define the color of the layer (instead of texture).
  15009. */
  15010. color: Color4;
  15011. /**
  15012. * Define the scale of the layer in order to zoom in out of the texture.
  15013. */
  15014. scale: Vector2;
  15015. /**
  15016. * Define an offset for the layer in order to shift the texture.
  15017. */
  15018. offset: Vector2;
  15019. /**
  15020. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  15021. */
  15022. alphaBlendingMode: number;
  15023. /**
  15024. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  15025. * Alpha test will not mix with the background color in case of transparency.
  15026. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  15027. */
  15028. alphaTest: boolean;
  15029. /**
  15030. * Define a mask to restrict the layer to only some of the scene cameras.
  15031. */
  15032. layerMask: number;
  15033. /**
  15034. * Define the list of render target the layer is visible into.
  15035. */
  15036. renderTargetTextures: RenderTargetTexture[];
  15037. /**
  15038. * Define if the layer is only used in renderTarget or if it also
  15039. * renders in the main frame buffer of the canvas.
  15040. */
  15041. renderOnlyInRenderTargetTextures: boolean;
  15042. private _scene;
  15043. private _vertexBuffers;
  15044. private _indexBuffer;
  15045. private _effect;
  15046. private _alphaTestEffect;
  15047. /**
  15048. * An event triggered when the layer is disposed.
  15049. */
  15050. onDisposeObservable: Observable<Layer>;
  15051. private _onDisposeObserver;
  15052. /**
  15053. * Back compatibility with callback before the onDisposeObservable existed.
  15054. * The set callback will be triggered when the layer has been disposed.
  15055. */
  15056. onDispose: () => void;
  15057. /**
  15058. * An event triggered before rendering the scene
  15059. */
  15060. onBeforeRenderObservable: Observable<Layer>;
  15061. private _onBeforeRenderObserver;
  15062. /**
  15063. * Back compatibility with callback before the onBeforeRenderObservable existed.
  15064. * The set callback will be triggered just before rendering the layer.
  15065. */
  15066. onBeforeRender: () => void;
  15067. /**
  15068. * An event triggered after rendering the scene
  15069. */
  15070. onAfterRenderObservable: Observable<Layer>;
  15071. private _onAfterRenderObserver;
  15072. /**
  15073. * Back compatibility with callback before the onAfterRenderObservable existed.
  15074. * The set callback will be triggered just after rendering the layer.
  15075. */
  15076. onAfterRender: () => void;
  15077. /**
  15078. * Instantiates a new layer.
  15079. * This represents a full screen 2d layer.
  15080. * This can be usefull to display a picture in the background of your scene for instance.
  15081. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15082. * @param name Define the name of the layer in the scene
  15083. * @param imgUrl Define the url of the texture to display in the layer
  15084. * @param scene Define the scene the layer belongs to
  15085. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  15086. * @param color Defines a color for the layer
  15087. */
  15088. constructor(
  15089. /**
  15090. * Define the name of the layer.
  15091. */
  15092. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  15093. private _createIndexBuffer;
  15094. /** @hidden */
  15095. _rebuild(): void;
  15096. /**
  15097. * Renders the layer in the scene.
  15098. */
  15099. render(): void;
  15100. /**
  15101. * Disposes and releases the associated ressources.
  15102. */
  15103. dispose(): void;
  15104. }
  15105. }
  15106. declare module BABYLON {
  15107. interface AbstractScene {
  15108. /**
  15109. * The list of layers (background and foreground) of the scene
  15110. */
  15111. layers: Array<Layer>;
  15112. }
  15113. /**
  15114. * Defines the layer scene component responsible to manage any layers
  15115. * in a given scene.
  15116. */
  15117. class LayerSceneComponent implements ISceneComponent {
  15118. /**
  15119. * The component name helpfull to identify the component in the list of scene components.
  15120. */
  15121. readonly name: string;
  15122. /**
  15123. * The scene the component belongs to.
  15124. */
  15125. scene: Scene;
  15126. private _engine;
  15127. /**
  15128. * Creates a new instance of the component for the given scene
  15129. * @param scene Defines the scene to register the component in
  15130. */
  15131. constructor(scene: Scene);
  15132. /**
  15133. * Registers the component in a given scene
  15134. */
  15135. register(): void;
  15136. /**
  15137. * Rebuilds the elements related to this component in case of
  15138. * context lost for instance.
  15139. */
  15140. rebuild(): void;
  15141. /**
  15142. * Disposes the component and the associated ressources.
  15143. */
  15144. dispose(): void;
  15145. private _draw;
  15146. private _drawCameraPredicate;
  15147. private _drawCameraBackground;
  15148. private _drawCameraForeground;
  15149. private _drawRenderTargetPredicate;
  15150. private _drawRenderTargetBackground;
  15151. private _drawRenderTargetForeground;
  15152. }
  15153. }
  15154. declare module BABYLON {
  15155. /**
  15156. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15157. * It controls one of the indiviual texture used in the effect.
  15158. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15159. */
  15160. class LensFlare {
  15161. /**
  15162. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15163. */
  15164. size: number;
  15165. /**
  15166. * 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.
  15167. */
  15168. position: number;
  15169. /**
  15170. * Define the lens color.
  15171. */
  15172. color: Color3;
  15173. /**
  15174. * Define the lens texture.
  15175. */
  15176. texture: Nullable<Texture>;
  15177. /**
  15178. * Define the alpha mode to render this particular lens.
  15179. */
  15180. alphaMode: number;
  15181. private _system;
  15182. /**
  15183. * Creates a new Lens Flare.
  15184. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15185. * It controls one of the indiviual texture used in the effect.
  15186. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15187. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  15188. * @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.
  15189. * @param color Define the lens color
  15190. * @param imgUrl Define the lens texture url
  15191. * @param system Define the `lensFlareSystem` this flare is part of
  15192. * @returns The newly created Lens Flare
  15193. */
  15194. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  15195. /**
  15196. * Instantiates a new Lens Flare.
  15197. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15198. * It controls one of the indiviual texture used in the effect.
  15199. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15200. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  15201. * @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.
  15202. * @param color Define the lens color
  15203. * @param imgUrl Define the lens texture url
  15204. * @param system Define the `lensFlareSystem` this flare is part of
  15205. */
  15206. constructor(
  15207. /**
  15208. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15209. */
  15210. size: number,
  15211. /**
  15212. * 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.
  15213. */
  15214. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  15215. /**
  15216. * Dispose and release the lens flare with its associated resources.
  15217. */
  15218. dispose(): void;
  15219. }
  15220. }
  15221. declare module BABYLON {
  15222. /**
  15223. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15224. * It is usually composed of several `BABYLON.lensFlare`.
  15225. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15226. */
  15227. class LensFlareSystem {
  15228. /**
  15229. * Define the name of the lens flare system
  15230. */
  15231. name: string;
  15232. /**
  15233. * List of lens flares used in this system.
  15234. */
  15235. lensFlares: LensFlare[];
  15236. /**
  15237. * Define a limit from the border the lens flare can be visible.
  15238. */
  15239. borderLimit: number;
  15240. /**
  15241. * Define a viewport border we do not want to see the lens flare in.
  15242. */
  15243. viewportBorder: number;
  15244. /**
  15245. * Define a predicate which could limit the list of meshes able to occlude the effect.
  15246. */
  15247. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  15248. /**
  15249. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  15250. */
  15251. layerMask: number;
  15252. /**
  15253. * Define the id of the lens flare system in the scene.
  15254. * (equal to name by default)
  15255. */
  15256. id: string;
  15257. private _scene;
  15258. private _emitter;
  15259. private _vertexBuffers;
  15260. private _indexBuffer;
  15261. private _effect;
  15262. private _positionX;
  15263. private _positionY;
  15264. private _isEnabled;
  15265. /**
  15266. * Instantiates a lens flare system.
  15267. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15268. * It is usually composed of several `BABYLON.lensFlare`.
  15269. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15270. * @param name Define the name of the lens flare system in the scene
  15271. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  15272. * @param scene Define the scene the lens flare system belongs to
  15273. */
  15274. constructor(
  15275. /**
  15276. * Define the name of the lens flare system
  15277. */
  15278. name: string, emitter: any, scene: Scene);
  15279. /**
  15280. * Define if the lens flare system is enabled.
  15281. */
  15282. isEnabled: boolean;
  15283. /**
  15284. * Get the scene the effects belongs to.
  15285. * @returns the scene holding the lens flare system
  15286. */
  15287. getScene(): Scene;
  15288. /**
  15289. * Get the emitter of the lens flare system.
  15290. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15291. * @returns the emitter of the lens flare system
  15292. */
  15293. getEmitter(): any;
  15294. /**
  15295. * Set the emitter of the lens flare system.
  15296. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15297. * @param newEmitter Define the new emitter of the system
  15298. */
  15299. setEmitter(newEmitter: any): void;
  15300. /**
  15301. * Get the lens flare system emitter position.
  15302. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  15303. * @returns the position
  15304. */
  15305. getEmitterPosition(): Vector3;
  15306. /**
  15307. * @hidden
  15308. */
  15309. computeEffectivePosition(globalViewport: Viewport): boolean;
  15310. /** @hidden */
  15311. _isVisible(): boolean;
  15312. /**
  15313. * @hidden
  15314. */
  15315. render(): boolean;
  15316. /**
  15317. * Dispose and release the lens flare with its associated resources.
  15318. */
  15319. dispose(): void;
  15320. /**
  15321. * Parse a lens flare system from a JSON repressentation
  15322. * @param parsedLensFlareSystem Define the JSON to parse
  15323. * @param scene Define the scene the parsed system should be instantiated in
  15324. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  15325. * @returns the parsed system
  15326. */
  15327. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  15328. /**
  15329. * Serialize the current Lens Flare System into a JSON representation.
  15330. * @returns the serialized JSON
  15331. */
  15332. serialize(): any;
  15333. }
  15334. }
  15335. declare module BABYLON {
  15336. interface AbstractScene {
  15337. /**
  15338. * The list of lens flare system added to the scene
  15339. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15340. */
  15341. lensFlareSystems: Array<LensFlareSystem>;
  15342. /**
  15343. * Removes the given lens flare system from this scene.
  15344. * @param toRemove The lens flare system to remove
  15345. * @returns The index of the removed lens flare system
  15346. */
  15347. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  15348. /**
  15349. * Adds the given lens flare system to this scene
  15350. * @param newLensFlareSystem The lens flare system to add
  15351. */
  15352. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  15353. /**
  15354. * Gets a lens flare system using its name
  15355. * @param name defines the name to look for
  15356. * @returns the lens flare system or null if not found
  15357. */
  15358. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  15359. /**
  15360. * Gets a lens flare system using its id
  15361. * @param id defines the id to look for
  15362. * @returns the lens flare system or null if not found
  15363. */
  15364. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  15365. }
  15366. /**
  15367. * Defines the lens flare scene component responsible to manage any lens flares
  15368. * in a given scene.
  15369. */
  15370. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  15371. /**
  15372. * The component name helpfull to identify the component in the list of scene components.
  15373. */
  15374. readonly name: string;
  15375. /**
  15376. * The scene the component belongs to.
  15377. */
  15378. scene: Scene;
  15379. /**
  15380. * Creates a new instance of the component for the given scene
  15381. * @param scene Defines the scene to register the component in
  15382. */
  15383. constructor(scene: Scene);
  15384. /**
  15385. * Registers the component in a given scene
  15386. */
  15387. register(): void;
  15388. /**
  15389. * Rebuilds the elements related to this component in case of
  15390. * context lost for instance.
  15391. */
  15392. rebuild(): void;
  15393. /**
  15394. * Adds all the element from the container to the scene
  15395. * @param container the container holding the elements
  15396. */
  15397. addFromContainer(container: AbstractScene): void;
  15398. /**
  15399. * Removes all the elements in the container from the scene
  15400. * @param container contains the elements to remove
  15401. */
  15402. removeFromContainer(container: AbstractScene): void;
  15403. /**
  15404. * Serializes the component data to the specified json object
  15405. * @param serializationObject The object to serialize to
  15406. */
  15407. serialize(serializationObject: any): void;
  15408. /**
  15409. * Disposes the component and the associated ressources.
  15410. */
  15411. dispose(): void;
  15412. private _draw;
  15413. }
  15414. }
  15415. declare module BABYLON {
  15416. /**
  15417. * A directional light is defined by a direction (what a surprise!).
  15418. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15419. * 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.
  15420. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15421. */
  15422. class DirectionalLight extends ShadowLight {
  15423. private _shadowFrustumSize;
  15424. /**
  15425. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15426. */
  15427. /**
  15428. * Specifies a fix frustum size for the shadow generation.
  15429. */
  15430. shadowFrustumSize: number;
  15431. private _shadowOrthoScale;
  15432. /**
  15433. * Gets the shadow projection scale against the optimal computed one.
  15434. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15435. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15436. */
  15437. /**
  15438. * Sets the shadow projection scale against the optimal computed one.
  15439. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15440. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15441. */
  15442. shadowOrthoScale: number;
  15443. /**
  15444. * Automatically compute the projection matrix to best fit (including all the casters)
  15445. * on each frame.
  15446. */
  15447. autoUpdateExtends: boolean;
  15448. private _orthoLeft;
  15449. private _orthoRight;
  15450. private _orthoTop;
  15451. private _orthoBottom;
  15452. /**
  15453. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15454. * The directional light is emitted from everywhere in the given direction.
  15455. * It can cast shadows.
  15456. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15457. * @param name The friendly name of the light
  15458. * @param direction The direction of the light
  15459. * @param scene The scene the light belongs to
  15460. */
  15461. constructor(name: string, direction: Vector3, scene: Scene);
  15462. /**
  15463. * Returns the string "DirectionalLight".
  15464. * @return The class name
  15465. */
  15466. getClassName(): string;
  15467. /**
  15468. * Returns the integer 1.
  15469. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15470. */
  15471. getTypeID(): number;
  15472. /**
  15473. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15474. * Returns the DirectionalLight Shadow projection matrix.
  15475. */
  15476. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15477. /**
  15478. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15479. * Returns the DirectionalLight Shadow projection matrix.
  15480. */
  15481. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15482. /**
  15483. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15484. * Returns the DirectionalLight Shadow projection matrix.
  15485. */
  15486. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15487. protected _buildUniformLayout(): void;
  15488. /**
  15489. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15490. * @param effect The effect to update
  15491. * @param lightIndex The index of the light in the effect to update
  15492. * @returns The directional light
  15493. */
  15494. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15495. /**
  15496. * Gets the minZ used for shadow according to both the scene and the light.
  15497. *
  15498. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15499. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15500. * @param activeCamera The camera we are returning the min for
  15501. * @returns the depth min z
  15502. */
  15503. getDepthMinZ(activeCamera: Camera): number;
  15504. /**
  15505. * Gets the maxZ used for shadow according to both the scene and the light.
  15506. *
  15507. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15508. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15509. * @param activeCamera The camera we are returning the max for
  15510. * @returns the depth max z
  15511. */
  15512. getDepthMaxZ(activeCamera: Camera): number;
  15513. /**
  15514. * Prepares the list of defines specific to the light type.
  15515. * @param defines the list of defines
  15516. * @param lightIndex defines the index of the light for the effect
  15517. */
  15518. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15519. }
  15520. }
  15521. declare module BABYLON {
  15522. /**
  15523. * The HemisphericLight simulates the ambient environment light,
  15524. * so the passed direction is the light reflection direction, not the incoming direction.
  15525. */
  15526. class HemisphericLight extends Light {
  15527. /**
  15528. * The groundColor is the light in the opposite direction to the one specified during creation.
  15529. * 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.
  15530. */
  15531. groundColor: Color3;
  15532. /**
  15533. * The light reflection direction, not the incoming direction.
  15534. */
  15535. direction: Vector3;
  15536. /**
  15537. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15538. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15539. * The HemisphericLight can't cast shadows.
  15540. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15541. * @param name The friendly name of the light
  15542. * @param direction The direction of the light reflection
  15543. * @param scene The scene the light belongs to
  15544. */
  15545. constructor(name: string, direction: Vector3, scene: Scene);
  15546. protected _buildUniformLayout(): void;
  15547. /**
  15548. * Returns the string "HemisphericLight".
  15549. * @return The class name
  15550. */
  15551. getClassName(): string;
  15552. /**
  15553. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15554. * Returns the updated direction.
  15555. * @param target The target the direction should point to
  15556. * @return The computed direction
  15557. */
  15558. setDirectionToTarget(target: Vector3): Vector3;
  15559. /**
  15560. * Returns the shadow generator associated to the light.
  15561. * @returns Always null for hemispheric lights because it does not support shadows.
  15562. */
  15563. getShadowGenerator(): Nullable<IShadowGenerator>;
  15564. /**
  15565. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15566. * @param effect The effect to update
  15567. * @param lightIndex The index of the light in the effect to update
  15568. * @returns The hemispheric light
  15569. */
  15570. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15571. /**
  15572. * Computes the world matrix of the node
  15573. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15574. * @param useWasUpdatedFlag defines a reserved property
  15575. * @returns the world matrix
  15576. */
  15577. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15578. /**
  15579. * Returns the integer 3.
  15580. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15581. */
  15582. getTypeID(): number;
  15583. /**
  15584. * Prepares the list of defines specific to the light type.
  15585. * @param defines the list of defines
  15586. * @param lightIndex defines the index of the light for the effect
  15587. */
  15588. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15589. }
  15590. }
  15591. declare module BABYLON {
  15592. /**
  15593. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15594. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15595. * 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.
  15596. */
  15597. abstract class Light extends Node {
  15598. /**
  15599. * Falloff Default: light is falling off following the material specification:
  15600. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15601. */
  15602. static readonly FALLOFF_DEFAULT: number;
  15603. /**
  15604. * Falloff Physical: light is falling off following the inverse squared distance law.
  15605. */
  15606. static readonly FALLOFF_PHYSICAL: number;
  15607. /**
  15608. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15609. * to enhance interoperability with other engines.
  15610. */
  15611. static readonly FALLOFF_GLTF: number;
  15612. /**
  15613. * Falloff Standard: light is falling off like in the standard material
  15614. * to enhance interoperability with other materials.
  15615. */
  15616. static readonly FALLOFF_STANDARD: number;
  15617. /**
  15618. * If every light affecting the material is in this lightmapMode,
  15619. * material.lightmapTexture adds or multiplies
  15620. * (depends on material.useLightmapAsShadowmap)
  15621. * after every other light calculations.
  15622. */
  15623. static readonly LIGHTMAP_DEFAULT: number;
  15624. /**
  15625. * material.lightmapTexture as only diffuse lighting from this light
  15626. * adds only specular lighting from this light
  15627. * adds dynamic shadows
  15628. */
  15629. static readonly LIGHTMAP_SPECULAR: number;
  15630. /**
  15631. * material.lightmapTexture as only lighting
  15632. * no light calculation from this light
  15633. * only adds dynamic shadows from this light
  15634. */
  15635. static readonly LIGHTMAP_SHADOWSONLY: number;
  15636. /**
  15637. * Each light type uses the default quantity according to its type:
  15638. * point/spot lights use luminous intensity
  15639. * directional lights use illuminance
  15640. */
  15641. static readonly INTENSITYMODE_AUTOMATIC: number;
  15642. /**
  15643. * lumen (lm)
  15644. */
  15645. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15646. /**
  15647. * candela (lm/sr)
  15648. */
  15649. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15650. /**
  15651. * lux (lm/m^2)
  15652. */
  15653. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15654. /**
  15655. * nit (cd/m^2)
  15656. */
  15657. static readonly INTENSITYMODE_LUMINANCE: number;
  15658. /**
  15659. * Light type const id of the point light.
  15660. */
  15661. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15662. /**
  15663. * Light type const id of the directional light.
  15664. */
  15665. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15666. /**
  15667. * Light type const id of the spot light.
  15668. */
  15669. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15670. /**
  15671. * Light type const id of the hemispheric light.
  15672. */
  15673. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15674. /**
  15675. * Diffuse gives the basic color to an object.
  15676. */
  15677. diffuse: Color3;
  15678. /**
  15679. * Specular produces a highlight color on an object.
  15680. * Note: This is note affecting PBR materials.
  15681. */
  15682. specular: Color3;
  15683. /**
  15684. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15685. * falling off base on range or angle.
  15686. * This can be set to any values in Light.FALLOFF_x.
  15687. *
  15688. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  15689. * other types of materials.
  15690. */
  15691. falloffType: number;
  15692. /**
  15693. * Strength of the light.
  15694. * Note: By default it is define in the framework own unit.
  15695. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15696. */
  15697. intensity: number;
  15698. private _range;
  15699. protected _inverseSquaredRange: number;
  15700. /**
  15701. * Defines how far from the source the light is impacting in scene units.
  15702. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15703. */
  15704. /**
  15705. * Defines how far from the source the light is impacting in scene units.
  15706. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15707. */
  15708. range: number;
  15709. /**
  15710. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15711. * of light.
  15712. */
  15713. private _photometricScale;
  15714. private _intensityMode;
  15715. /**
  15716. * Gets the photometric scale used to interpret the intensity.
  15717. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15718. */
  15719. /**
  15720. * Sets the photometric scale used to interpret the intensity.
  15721. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15722. */
  15723. intensityMode: number;
  15724. private _radius;
  15725. /**
  15726. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15727. */
  15728. /**
  15729. * sets the light radius used by PBR Materials to simulate soft area lights.
  15730. */
  15731. radius: number;
  15732. private _renderPriority;
  15733. /**
  15734. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15735. * exceeding the number allowed of the materials.
  15736. */
  15737. renderPriority: number;
  15738. private _shadowEnabled;
  15739. /**
  15740. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15741. * the current shadow generator.
  15742. */
  15743. /**
  15744. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15745. * the current shadow generator.
  15746. */
  15747. shadowEnabled: boolean;
  15748. private _includedOnlyMeshes;
  15749. /**
  15750. * Gets the only meshes impacted by this light.
  15751. */
  15752. /**
  15753. * Sets the only meshes impacted by this light.
  15754. */
  15755. includedOnlyMeshes: AbstractMesh[];
  15756. private _excludedMeshes;
  15757. /**
  15758. * Gets the meshes not impacted by this light.
  15759. */
  15760. /**
  15761. * Sets the meshes not impacted by this light.
  15762. */
  15763. excludedMeshes: AbstractMesh[];
  15764. private _excludeWithLayerMask;
  15765. /**
  15766. * Gets the layer id use to find what meshes are not impacted by the light.
  15767. * Inactive if 0
  15768. */
  15769. /**
  15770. * Sets the layer id use to find what meshes are not impacted by the light.
  15771. * Inactive if 0
  15772. */
  15773. excludeWithLayerMask: number;
  15774. private _includeOnlyWithLayerMask;
  15775. /**
  15776. * Gets the layer id use to find what meshes are impacted by the light.
  15777. * Inactive if 0
  15778. */
  15779. /**
  15780. * Sets the layer id use to find what meshes are impacted by the light.
  15781. * Inactive if 0
  15782. */
  15783. includeOnlyWithLayerMask: number;
  15784. private _lightmapMode;
  15785. /**
  15786. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15787. */
  15788. /**
  15789. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15790. */
  15791. lightmapMode: number;
  15792. /**
  15793. * Shadow generator associted to the light.
  15794. * @hidden Internal use only.
  15795. */
  15796. _shadowGenerator: Nullable<IShadowGenerator>;
  15797. /**
  15798. * @hidden Internal use only.
  15799. */
  15800. _excludedMeshesIds: string[];
  15801. /**
  15802. * @hidden Internal use only.
  15803. */
  15804. _includedOnlyMeshesIds: string[];
  15805. /**
  15806. * The current light unifom buffer.
  15807. * @hidden Internal use only.
  15808. */
  15809. _uniformBuffer: UniformBuffer;
  15810. /**
  15811. * Creates a Light object in the scene.
  15812. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15813. * @param name The firendly name of the light
  15814. * @param scene The scene the light belongs too
  15815. */
  15816. constructor(name: string, scene: Scene);
  15817. protected abstract _buildUniformLayout(): void;
  15818. /**
  15819. * Sets the passed Effect "effect" with the Light information.
  15820. * @param effect The effect to update
  15821. * @param lightIndex The index of the light in the effect to update
  15822. * @returns The light
  15823. */
  15824. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15825. /**
  15826. * Returns the string "Light".
  15827. * @returns the class name
  15828. */
  15829. getClassName(): string;
  15830. /**
  15831. * Converts the light information to a readable string for debug purpose.
  15832. * @param fullDetails Supports for multiple levels of logging within scene loading
  15833. * @returns the human readable light info
  15834. */
  15835. toString(fullDetails?: boolean): string;
  15836. /** @hidden */
  15837. protected _syncParentEnabledState(): void;
  15838. /**
  15839. * Set the enabled state of this node.
  15840. * @param value - the new enabled state
  15841. */
  15842. setEnabled(value: boolean): void;
  15843. /**
  15844. * Returns the Light associated shadow generator if any.
  15845. * @return the associated shadow generator.
  15846. */
  15847. getShadowGenerator(): Nullable<IShadowGenerator>;
  15848. /**
  15849. * Returns a Vector3, the absolute light position in the World.
  15850. * @returns the world space position of the light
  15851. */
  15852. getAbsolutePosition(): Vector3;
  15853. /**
  15854. * Specifies if the light will affect the passed mesh.
  15855. * @param mesh The mesh to test against the light
  15856. * @return true the mesh is affected otherwise, false.
  15857. */
  15858. canAffectMesh(mesh: AbstractMesh): boolean;
  15859. /**
  15860. * Sort function to order lights for rendering.
  15861. * @param a First Light object to compare to second.
  15862. * @param b Second Light object to compare first.
  15863. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15864. */
  15865. static CompareLightsPriority(a: Light, b: Light): number;
  15866. /**
  15867. * Releases resources associated with this node.
  15868. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15869. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15870. */
  15871. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15872. /**
  15873. * Returns the light type ID (integer).
  15874. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15875. */
  15876. getTypeID(): number;
  15877. /**
  15878. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  15879. * @returns the scaled intensity in intensity mode unit
  15880. */
  15881. getScaledIntensity(): number;
  15882. /**
  15883. * Returns a new Light object, named "name", from the current one.
  15884. * @param name The name of the cloned light
  15885. * @returns the new created light
  15886. */
  15887. clone(name: string): Nullable<Light>;
  15888. /**
  15889. * Serializes the current light into a Serialization object.
  15890. * @returns the serialized object.
  15891. */
  15892. serialize(): any;
  15893. /**
  15894. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  15895. * This new light is named "name" and added to the passed scene.
  15896. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  15897. * @param name The friendly name of the light
  15898. * @param scene The scene the new light will belong to
  15899. * @returns the constructor function
  15900. */
  15901. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  15902. /**
  15903. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  15904. * @param parsedLight The JSON representation of the light
  15905. * @param scene The scene to create the parsed light in
  15906. * @returns the created light after parsing
  15907. */
  15908. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  15909. private _hookArrayForExcluded;
  15910. private _hookArrayForIncludedOnly;
  15911. private _resyncMeshes;
  15912. /**
  15913. * Forces the meshes to update their light related information in their rendering used effects
  15914. * @hidden Internal Use Only
  15915. */
  15916. _markMeshesAsLightDirty(): void;
  15917. /**
  15918. * Recomputes the cached photometric scale if needed.
  15919. */
  15920. private _computePhotometricScale;
  15921. /**
  15922. * Returns the Photometric Scale according to the light type and intensity mode.
  15923. */
  15924. private _getPhotometricScale;
  15925. /**
  15926. * Reorder the light in the scene according to their defined priority.
  15927. * @hidden Internal Use Only
  15928. */
  15929. _reorderLightsInScene(): void;
  15930. /**
  15931. * Prepares the list of defines specific to the light type.
  15932. * @param defines the list of defines
  15933. * @param lightIndex defines the index of the light for the effect
  15934. */
  15935. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15936. }
  15937. }
  15938. declare module BABYLON {
  15939. /**
  15940. * A point light is a light defined by an unique point in world space.
  15941. * The light is emitted in every direction from this point.
  15942. * A good example of a point light is a standard light bulb.
  15943. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15944. */
  15945. class PointLight extends ShadowLight {
  15946. private _shadowAngle;
  15947. /**
  15948. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15949. * This specifies what angle the shadow will use to be created.
  15950. *
  15951. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15952. */
  15953. /**
  15954. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15955. * This specifies what angle the shadow will use to be created.
  15956. *
  15957. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15958. */
  15959. shadowAngle: number;
  15960. /**
  15961. * Gets the direction if it has been set.
  15962. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15963. */
  15964. /**
  15965. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15966. */
  15967. direction: Vector3;
  15968. /**
  15969. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  15970. * A PointLight emits the light in every direction.
  15971. * It can cast shadows.
  15972. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  15973. * ```javascript
  15974. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  15975. * ```
  15976. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15977. * @param name The light friendly name
  15978. * @param position The position of the point light in the scene
  15979. * @param scene The scene the lights belongs to
  15980. */
  15981. constructor(name: string, position: Vector3, scene: Scene);
  15982. /**
  15983. * Returns the string "PointLight"
  15984. * @returns the class name
  15985. */
  15986. getClassName(): string;
  15987. /**
  15988. * Returns the integer 0.
  15989. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15990. */
  15991. getTypeID(): number;
  15992. /**
  15993. * Specifies wether or not the shadowmap should be a cube texture.
  15994. * @returns true if the shadowmap needs to be a cube texture.
  15995. */
  15996. needCube(): boolean;
  15997. /**
  15998. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  15999. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16000. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16001. */
  16002. getShadowDirection(faceIndex?: number): Vector3;
  16003. /**
  16004. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  16005. * - fov = PI / 2
  16006. * - aspect ratio : 1.0
  16007. * - z-near and far equal to the active camera minZ and maxZ.
  16008. * Returns the PointLight.
  16009. */
  16010. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16011. protected _buildUniformLayout(): void;
  16012. /**
  16013. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  16014. * @param effect The effect to update
  16015. * @param lightIndex The index of the light in the effect to update
  16016. * @returns The point light
  16017. */
  16018. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  16019. /**
  16020. * Prepares the list of defines specific to the light type.
  16021. * @param defines the list of defines
  16022. * @param lightIndex defines the index of the light for the effect
  16023. */
  16024. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16025. }
  16026. }
  16027. declare module BABYLON {
  16028. /**
  16029. * Interface describing all the common properties and methods a shadow light needs to implement.
  16030. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  16031. * as well as binding the different shadow properties to the effects.
  16032. */
  16033. interface IShadowLight extends Light {
  16034. /**
  16035. * The light id in the scene (used in scene.findLighById for instance)
  16036. */
  16037. id: string;
  16038. /**
  16039. * The position the shdow will be casted from.
  16040. */
  16041. position: Vector3;
  16042. /**
  16043. * In 2d mode (needCube being false), the direction used to cast the shadow.
  16044. */
  16045. direction: Vector3;
  16046. /**
  16047. * The transformed position. Position of the light in world space taking parenting in account.
  16048. */
  16049. transformedPosition: Vector3;
  16050. /**
  16051. * The transformed direction. Direction of the light in world space taking parenting in account.
  16052. */
  16053. transformedDirection: Vector3;
  16054. /**
  16055. * The friendly name of the light in the scene.
  16056. */
  16057. name: string;
  16058. /**
  16059. * Defines the shadow projection clipping minimum z value.
  16060. */
  16061. shadowMinZ: number;
  16062. /**
  16063. * Defines the shadow projection clipping maximum z value.
  16064. */
  16065. shadowMaxZ: number;
  16066. /**
  16067. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16068. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16069. */
  16070. computeTransformedInformation(): boolean;
  16071. /**
  16072. * Gets the scene the light belongs to.
  16073. * @returns The scene
  16074. */
  16075. getScene(): Scene;
  16076. /**
  16077. * Callback defining a custom Projection Matrix Builder.
  16078. * This can be used to override the default projection matrix computation.
  16079. */
  16080. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16081. /**
  16082. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16083. * @param matrix The materix to updated with the projection information
  16084. * @param viewMatrix The transform matrix of the light
  16085. * @param renderList The list of mesh to render in the map
  16086. * @returns The current light
  16087. */
  16088. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16089. /**
  16090. * Gets the current depth scale used in ESM.
  16091. * @returns The scale
  16092. */
  16093. getDepthScale(): number;
  16094. /**
  16095. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16096. * @returns true if a cube texture needs to be use
  16097. */
  16098. needCube(): boolean;
  16099. /**
  16100. * Detects if the projection matrix requires to be recomputed this frame.
  16101. * @returns true if it requires to be recomputed otherwise, false.
  16102. */
  16103. needProjectionMatrixCompute(): boolean;
  16104. /**
  16105. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16106. */
  16107. forceProjectionMatrixCompute(): void;
  16108. /**
  16109. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16110. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16111. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16112. */
  16113. getShadowDirection(faceIndex?: number): Vector3;
  16114. /**
  16115. * Gets the minZ used for shadow according to both the scene and the light.
  16116. * @param activeCamera The camera we are returning the min for
  16117. * @returns the depth min z
  16118. */
  16119. getDepthMinZ(activeCamera: Camera): number;
  16120. /**
  16121. * Gets the maxZ used for shadow according to both the scene and the light.
  16122. * @param activeCamera The camera we are returning the max for
  16123. * @returns the depth max z
  16124. */
  16125. getDepthMaxZ(activeCamera: Camera): number;
  16126. }
  16127. /**
  16128. * Base implementation IShadowLight
  16129. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  16130. */
  16131. abstract class ShadowLight extends Light implements IShadowLight {
  16132. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16133. protected _position: Vector3;
  16134. protected _setPosition(value: Vector3): void;
  16135. /**
  16136. * Sets the position the shadow will be casted from. Also use as the light position for both
  16137. * point and spot lights.
  16138. */
  16139. /**
  16140. * Sets the position the shadow will be casted from. Also use as the light position for both
  16141. * point and spot lights.
  16142. */
  16143. position: Vector3;
  16144. protected _direction: Vector3;
  16145. protected _setDirection(value: Vector3): void;
  16146. /**
  16147. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  16148. * Also use as the light direction on spot and directional lights.
  16149. */
  16150. /**
  16151. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  16152. * Also use as the light direction on spot and directional lights.
  16153. */
  16154. direction: Vector3;
  16155. private _shadowMinZ;
  16156. /**
  16157. * Gets the shadow projection clipping minimum z value.
  16158. */
  16159. /**
  16160. * Sets the shadow projection clipping minimum z value.
  16161. */
  16162. shadowMinZ: number;
  16163. private _shadowMaxZ;
  16164. /**
  16165. * Sets the shadow projection clipping maximum z value.
  16166. */
  16167. /**
  16168. * Gets the shadow projection clipping maximum z value.
  16169. */
  16170. shadowMaxZ: number;
  16171. /**
  16172. * Callback defining a custom Projection Matrix Builder.
  16173. * This can be used to override the default projection matrix computation.
  16174. */
  16175. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16176. /**
  16177. * The transformed position. Position of the light in world space taking parenting in account.
  16178. */
  16179. transformedPosition: Vector3;
  16180. /**
  16181. * The transformed direction. Direction of the light in world space taking parenting in account.
  16182. */
  16183. transformedDirection: Vector3;
  16184. private _needProjectionMatrixCompute;
  16185. /**
  16186. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16187. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16188. */
  16189. computeTransformedInformation(): boolean;
  16190. /**
  16191. * Return the depth scale used for the shadow map.
  16192. * @returns the depth scale.
  16193. */
  16194. getDepthScale(): number;
  16195. /**
  16196. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16197. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16198. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16199. */
  16200. getShadowDirection(faceIndex?: number): Vector3;
  16201. /**
  16202. * Returns the ShadowLight absolute position in the World.
  16203. * @returns the position vector in world space
  16204. */
  16205. getAbsolutePosition(): Vector3;
  16206. /**
  16207. * Sets the ShadowLight direction toward the passed target.
  16208. * @param target The point tot target in local space
  16209. * @returns the updated ShadowLight direction
  16210. */
  16211. setDirectionToTarget(target: Vector3): Vector3;
  16212. /**
  16213. * Returns the light rotation in euler definition.
  16214. * @returns the x y z rotation in local space.
  16215. */
  16216. getRotation(): Vector3;
  16217. /**
  16218. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16219. * @returns true if a cube texture needs to be use
  16220. */
  16221. needCube(): boolean;
  16222. /**
  16223. * Detects if the projection matrix requires to be recomputed this frame.
  16224. * @returns true if it requires to be recomputed otherwise, false.
  16225. */
  16226. needProjectionMatrixCompute(): boolean;
  16227. /**
  16228. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16229. */
  16230. forceProjectionMatrixCompute(): void;
  16231. /** @hidden */
  16232. _initCache(): void;
  16233. /** @hidden */
  16234. _isSynchronized(): boolean;
  16235. /**
  16236. * Computes the world matrix of the node
  16237. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  16238. * @returns the world matrix
  16239. */
  16240. computeWorldMatrix(force?: boolean): Matrix;
  16241. /**
  16242. * Gets the minZ used for shadow according to both the scene and the light.
  16243. * @param activeCamera The camera we are returning the min for
  16244. * @returns the depth min z
  16245. */
  16246. getDepthMinZ(activeCamera: Camera): number;
  16247. /**
  16248. * Gets the maxZ used for shadow according to both the scene and the light.
  16249. * @param activeCamera The camera we are returning the max for
  16250. * @returns the depth max z
  16251. */
  16252. getDepthMaxZ(activeCamera: Camera): number;
  16253. /**
  16254. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16255. * @param matrix The materix to updated with the projection information
  16256. * @param viewMatrix The transform matrix of the light
  16257. * @param renderList The list of mesh to render in the map
  16258. * @returns The current light
  16259. */
  16260. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16261. }
  16262. }
  16263. declare module BABYLON {
  16264. /**
  16265. * A spot light is defined by a position, a direction, an angle, and an exponent.
  16266. * These values define a cone of light starting from the position, emitting toward the direction.
  16267. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  16268. * and the exponent defines the speed of the decay of the light with distance (reach).
  16269. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16270. */
  16271. class SpotLight extends ShadowLight {
  16272. private _angle;
  16273. private _innerAngle;
  16274. private _cosHalfAngle;
  16275. private _lightAngleScale;
  16276. private _lightAngleOffset;
  16277. /**
  16278. * Gets the cone angle of the spot light in Radians.
  16279. */
  16280. /**
  16281. * Sets the cone angle of the spot light in Radians.
  16282. */
  16283. angle: number;
  16284. /**
  16285. * Only used in gltf falloff mode, this defines the angle where
  16286. * the directional falloff will start before cutting at angle which could be seen
  16287. * as outer angle.
  16288. */
  16289. /**
  16290. * Only used in gltf falloff mode, this defines the angle where
  16291. * the directional falloff will start before cutting at angle which could be seen
  16292. * as outer angle.
  16293. */
  16294. innerAngle: number;
  16295. private _shadowAngleScale;
  16296. /**
  16297. * Allows scaling the angle of the light for shadow generation only.
  16298. */
  16299. /**
  16300. * Allows scaling the angle of the light for shadow generation only.
  16301. */
  16302. shadowAngleScale: number;
  16303. /**
  16304. * The light decay speed with the distance from the emission spot.
  16305. */
  16306. exponent: number;
  16307. private _projectionTextureMatrix;
  16308. /**
  16309. * Allows reading the projecton texture
  16310. */
  16311. readonly projectionTextureMatrix: Matrix;
  16312. protected _projectionTextureLightNear: number;
  16313. /**
  16314. * Gets the near clip of the Spotlight for texture projection.
  16315. */
  16316. /**
  16317. * Sets the near clip of the Spotlight for texture projection.
  16318. */
  16319. projectionTextureLightNear: number;
  16320. protected _projectionTextureLightFar: number;
  16321. /**
  16322. * Gets the far clip of the Spotlight for texture projection.
  16323. */
  16324. /**
  16325. * Sets the far clip of the Spotlight for texture projection.
  16326. */
  16327. projectionTextureLightFar: number;
  16328. protected _projectionTextureUpDirection: Vector3;
  16329. /**
  16330. * Gets the Up vector of the Spotlight for texture projection.
  16331. */
  16332. /**
  16333. * Sets the Up vector of the Spotlight for texture projection.
  16334. */
  16335. projectionTextureUpDirection: Vector3;
  16336. private _projectionTexture;
  16337. /**
  16338. * Gets the projection texture of the light.
  16339. */
  16340. /**
  16341. * Sets the projection texture of the light.
  16342. */
  16343. projectionTexture: Nullable<BaseTexture>;
  16344. private _projectionTextureViewLightDirty;
  16345. private _projectionTextureProjectionLightDirty;
  16346. private _projectionTextureDirty;
  16347. private _projectionTextureViewTargetVector;
  16348. private _projectionTextureViewLightMatrix;
  16349. private _projectionTextureProjectionLightMatrix;
  16350. private _projectionTextureScalingMatrix;
  16351. /**
  16352. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  16353. * It can cast shadows.
  16354. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16355. * @param name The light friendly name
  16356. * @param position The position of the spot light in the scene
  16357. * @param direction The direction of the light in the scene
  16358. * @param angle The cone angle of the light in Radians
  16359. * @param exponent The light decay speed with the distance from the emission spot
  16360. * @param scene The scene the lights belongs to
  16361. */
  16362. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  16363. /**
  16364. * Returns the string "SpotLight".
  16365. * @returns the class name
  16366. */
  16367. getClassName(): string;
  16368. /**
  16369. * Returns the integer 2.
  16370. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16371. */
  16372. getTypeID(): number;
  16373. /**
  16374. * Overrides the direction setter to recompute the projection texture view light Matrix.
  16375. */
  16376. protected _setDirection(value: Vector3): void;
  16377. /**
  16378. * Overrides the position setter to recompute the projection texture view light Matrix.
  16379. */
  16380. protected _setPosition(value: Vector3): void;
  16381. /**
  16382. * 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.
  16383. * Returns the SpotLight.
  16384. */
  16385. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16386. protected _computeProjectionTextureViewLightMatrix(): void;
  16387. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16388. /**
  16389. * Main function for light texture projection matrix computing.
  16390. */
  16391. protected _computeProjectionTextureMatrix(): void;
  16392. protected _buildUniformLayout(): void;
  16393. private _computeAngleValues;
  16394. /**
  16395. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16396. * @param effect The effect to update
  16397. * @param lightIndex The index of the light in the effect to update
  16398. * @returns The spot light
  16399. */
  16400. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16401. /**
  16402. * Disposes the light and the associated resources.
  16403. */
  16404. dispose(): void;
  16405. /**
  16406. * Prepares the list of defines specific to the light type.
  16407. * @param defines the list of defines
  16408. * @param lightIndex defines the index of the light for the effect
  16409. */
  16410. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16411. }
  16412. }
  16413. declare module BABYLON {
  16414. /**
  16415. * Interface used to present a loading screen while loading a scene
  16416. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16417. */
  16418. interface ILoadingScreen {
  16419. /**
  16420. * Function called to display the loading screen
  16421. */
  16422. displayLoadingUI: () => void;
  16423. /**
  16424. * Function called to hide the loading screen
  16425. */
  16426. hideLoadingUI: () => void;
  16427. /**
  16428. * Gets or sets the color to use for the background
  16429. */
  16430. loadingUIBackgroundColor: string;
  16431. /**
  16432. * Gets or sets the text to display while loading
  16433. */
  16434. loadingUIText: string;
  16435. }
  16436. /**
  16437. * Class used for the default loading screen
  16438. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16439. */
  16440. class DefaultLoadingScreen implements ILoadingScreen {
  16441. private _renderingCanvas;
  16442. private _loadingText;
  16443. private _loadingDivBackgroundColor;
  16444. private _loadingDiv;
  16445. private _loadingTextDiv;
  16446. /**
  16447. * Creates a new default loading screen
  16448. * @param _renderingCanvas defines the canvas used to render the scene
  16449. * @param _loadingText defines the default text to display
  16450. * @param _loadingDivBackgroundColor defines the default background color
  16451. */
  16452. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  16453. /**
  16454. * Function called to display the loading screen
  16455. */
  16456. displayLoadingUI(): void;
  16457. /**
  16458. * Function called to hide the loading screen
  16459. */
  16460. hideLoadingUI(): void;
  16461. /**
  16462. * Gets or sets the text to display while loading
  16463. */
  16464. loadingUIText: string;
  16465. /**
  16466. * Gets or sets the color to use for the background
  16467. */
  16468. loadingUIBackgroundColor: string;
  16469. private _resizeLoadingUI;
  16470. }
  16471. }
  16472. declare module BABYLON {
  16473. /**
  16474. * Class used to represent data loading progression
  16475. */
  16476. class SceneLoaderProgressEvent {
  16477. /** defines if data length to load can be evaluated */
  16478. readonly lengthComputable: boolean;
  16479. /** defines the loaded data length */
  16480. readonly loaded: number;
  16481. /** defines the data length to load */
  16482. readonly total: number;
  16483. /**
  16484. * Create a new progress event
  16485. * @param lengthComputable defines if data length to load can be evaluated
  16486. * @param loaded defines the loaded data length
  16487. * @param total defines the data length to load
  16488. */
  16489. constructor(
  16490. /** defines if data length to load can be evaluated */
  16491. lengthComputable: boolean,
  16492. /** defines the loaded data length */
  16493. loaded: number,
  16494. /** defines the data length to load */
  16495. total: number);
  16496. /**
  16497. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16498. * @param event defines the source event
  16499. * @returns a new SceneLoaderProgressEvent
  16500. */
  16501. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16502. }
  16503. /**
  16504. * Interface used by SceneLoader plugins to define supported file extensions
  16505. */
  16506. interface ISceneLoaderPluginExtensions {
  16507. /**
  16508. * Defines the list of supported extensions
  16509. */
  16510. [extension: string]: {
  16511. isBinary: boolean;
  16512. };
  16513. }
  16514. /**
  16515. * Interface used by SceneLoader plugin factory
  16516. */
  16517. interface ISceneLoaderPluginFactory {
  16518. /**
  16519. * Defines the name of the factory
  16520. */
  16521. name: string;
  16522. /**
  16523. * Function called to create a new plugin
  16524. * @return the new plugin
  16525. */
  16526. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16527. /**
  16528. * Boolean indicating if the plugin can direct load specific data
  16529. */
  16530. canDirectLoad?: (data: string) => boolean;
  16531. }
  16532. /**
  16533. * Interface used to define a SceneLoader plugin
  16534. */
  16535. interface ISceneLoaderPlugin {
  16536. /**
  16537. * The friendly name of this plugin.
  16538. */
  16539. name: string;
  16540. /**
  16541. * The file extensions supported by this plugin.
  16542. */
  16543. extensions: string | ISceneLoaderPluginExtensions;
  16544. /**
  16545. * Import meshes into a scene.
  16546. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16547. * @param scene The scene to import into
  16548. * @param data The data to import
  16549. * @param rootUrl The root url for scene and resources
  16550. * @param meshes The meshes array to import into
  16551. * @param particleSystems The particle systems array to import into
  16552. * @param skeletons The skeletons array to import into
  16553. * @param onError The callback when import fails
  16554. * @returns True if successful or false otherwise
  16555. */
  16556. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16557. /**
  16558. * Load into a scene.
  16559. * @param scene The scene to load into
  16560. * @param data The data to import
  16561. * @param rootUrl The root url for scene and resources
  16562. * @param onError The callback when import fails
  16563. * @returns true if successful or false otherwise
  16564. */
  16565. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16566. /**
  16567. * The callback that returns true if the data can be directly loaded.
  16568. */
  16569. canDirectLoad?: (data: string) => boolean;
  16570. /**
  16571. * The callback that allows custom handling of the root url based on the response url.
  16572. */
  16573. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16574. /**
  16575. * Load into an asset container.
  16576. * @param scene The scene to load into
  16577. * @param data The data to import
  16578. * @param rootUrl The root url for scene and resources
  16579. * @param onError The callback when import fails
  16580. * @returns The loaded asset container
  16581. */
  16582. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16583. }
  16584. /**
  16585. * Interface used to define an async SceneLoader plugin
  16586. */
  16587. interface ISceneLoaderPluginAsync {
  16588. /**
  16589. * The friendly name of this plugin.
  16590. */
  16591. name: string;
  16592. /**
  16593. * The file extensions supported by this plugin.
  16594. */
  16595. extensions: string | ISceneLoaderPluginExtensions;
  16596. /**
  16597. * Import meshes into a scene.
  16598. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16599. * @param scene The scene to import into
  16600. * @param data The data to import
  16601. * @param rootUrl The root url for scene and resources
  16602. * @param onProgress The callback when the load progresses
  16603. * @param fileName Defines the name of the file to load
  16604. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16605. */
  16606. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16607. meshes: AbstractMesh[];
  16608. particleSystems: IParticleSystem[];
  16609. skeletons: Skeleton[];
  16610. animationGroups: AnimationGroup[];
  16611. }>;
  16612. /**
  16613. * Load into a scene.
  16614. * @param scene The scene to load into
  16615. * @param data The data to import
  16616. * @param rootUrl The root url for scene and resources
  16617. * @param onProgress The callback when the load progresses
  16618. * @param fileName Defines the name of the file to load
  16619. * @returns Nothing
  16620. */
  16621. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16622. /**
  16623. * The callback that returns true if the data can be directly loaded.
  16624. */
  16625. canDirectLoad?: (data: string) => boolean;
  16626. /**
  16627. * The callback that allows custom handling of the root url based on the response url.
  16628. */
  16629. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16630. /**
  16631. * Load into an asset container.
  16632. * @param scene The scene to load into
  16633. * @param data The data to import
  16634. * @param rootUrl The root url for scene and resources
  16635. * @param onProgress The callback when the load progresses
  16636. * @param fileName Defines the name of the file to load
  16637. * @returns The loaded asset container
  16638. */
  16639. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16640. }
  16641. /**
  16642. * Class used to load scene from various file formats using registered plugins
  16643. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16644. */
  16645. class SceneLoader {
  16646. private static _ForceFullSceneLoadingForIncremental;
  16647. private static _ShowLoadingScreen;
  16648. private static _CleanBoneMatrixWeights;
  16649. /**
  16650. * No logging while loading
  16651. */
  16652. static readonly NO_LOGGING: number;
  16653. /**
  16654. * Minimal logging while loading
  16655. */
  16656. static readonly MINIMAL_LOGGING: number;
  16657. /**
  16658. * Summary logging while loading
  16659. */
  16660. static readonly SUMMARY_LOGGING: number;
  16661. /**
  16662. * Detailled logging while loading
  16663. */
  16664. static readonly DETAILED_LOGGING: number;
  16665. private static _loggingLevel;
  16666. /**
  16667. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16668. */
  16669. static ForceFullSceneLoadingForIncremental: boolean;
  16670. /**
  16671. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16672. */
  16673. static ShowLoadingScreen: boolean;
  16674. /**
  16675. * Defines the current logging level (while loading the scene)
  16676. * @ignorenaming
  16677. */
  16678. static loggingLevel: number;
  16679. /**
  16680. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16681. */
  16682. static CleanBoneMatrixWeights: boolean;
  16683. /**
  16684. * Event raised when a plugin is used to load a scene
  16685. */
  16686. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16687. private static _registeredPlugins;
  16688. private static _getDefaultPlugin;
  16689. private static _getPluginForExtension;
  16690. private static _getPluginForDirectLoad;
  16691. private static _getPluginForFilename;
  16692. private static _getDirectLoad;
  16693. private static _loadData;
  16694. private static _getFileInfo;
  16695. /**
  16696. * Gets a plugin that can load the given extension
  16697. * @param extension defines the extension to load
  16698. * @returns a plugin or null if none works
  16699. */
  16700. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16701. /**
  16702. * Gets a boolean indicating that the given extension can be loaded
  16703. * @param extension defines the extension to load
  16704. * @returns true if the extension is supported
  16705. */
  16706. static IsPluginForExtensionAvailable(extension: string): boolean;
  16707. /**
  16708. * Adds a new plugin to the list of registered plugins
  16709. * @param plugin defines the plugin to add
  16710. */
  16711. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16712. /**
  16713. * Import meshes into a scene
  16714. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16715. * @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)
  16716. * @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)
  16717. * @param scene the instance of BABYLON.Scene to append to
  16718. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  16719. * @param onProgress a callback with a progress event for each file being loaded
  16720. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16721. * @param pluginExtension the extension used to determine the plugin
  16722. * @returns The loaded plugin
  16723. */
  16724. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16725. /**
  16726. * Import meshes into a scene
  16727. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16728. * @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)
  16729. * @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)
  16730. * @param scene the instance of BABYLON.Scene to append to
  16731. * @param onProgress a callback with a progress event for each file being loaded
  16732. * @param pluginExtension the extension used to determine the plugin
  16733. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16734. */
  16735. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16736. meshes: AbstractMesh[];
  16737. particleSystems: IParticleSystem[];
  16738. skeletons: Skeleton[];
  16739. animationGroups: AnimationGroup[];
  16740. }>;
  16741. /**
  16742. * Load a scene
  16743. * @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)
  16744. * @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)
  16745. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16746. * @param onSuccess a callback with the scene when import succeeds
  16747. * @param onProgress a callback with a progress event for each file being loaded
  16748. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16749. * @param pluginExtension the extension used to determine the plugin
  16750. * @returns The loaded plugin
  16751. */
  16752. static Load(rootUrl: string, sceneFilename: string, engine: Engine, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16753. /**
  16754. * Load a scene
  16755. * @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)
  16756. * @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)
  16757. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16758. * @param onProgress a callback with a progress event for each file being loaded
  16759. * @param pluginExtension the extension used to determine the plugin
  16760. * @returns The loaded scene
  16761. */
  16762. static LoadAsync(rootUrl: string, sceneFilename: string, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16763. /**
  16764. * Append a scene
  16765. * @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)
  16766. * @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)
  16767. * @param scene is the instance of BABYLON.Scene to append to
  16768. * @param onSuccess a callback with the scene when import succeeds
  16769. * @param onProgress a callback with a progress event for each file being loaded
  16770. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16771. * @param pluginExtension the extension used to determine the plugin
  16772. * @returns The loaded plugin
  16773. */
  16774. static Append(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16775. /**
  16776. * Append a scene
  16777. * @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)
  16778. * @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)
  16779. * @param scene is the instance of BABYLON.Scene to append to
  16780. * @param onProgress a callback with a progress event for each file being loaded
  16781. * @param pluginExtension the extension used to determine the plugin
  16782. * @returns The given scene
  16783. */
  16784. static AppendAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16785. /**
  16786. * Load a scene into an asset container
  16787. * @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)
  16788. * @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)
  16789. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16790. * @param onSuccess a callback with the scene when import succeeds
  16791. * @param onProgress a callback with a progress event for each file being loaded
  16792. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16793. * @param pluginExtension the extension used to determine the plugin
  16794. * @returns The loaded plugin
  16795. */
  16796. static LoadAssetContainer(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16797. /**
  16798. * Load a scene into an asset container
  16799. * @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)
  16800. * @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)
  16801. * @param scene is the instance of BABYLON.Scene to append to
  16802. * @param onProgress a callback with a progress event for each file being loaded
  16803. * @param pluginExtension the extension used to determine the plugin
  16804. * @returns The loaded asset container
  16805. */
  16806. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16807. }
  16808. }
  16809. declare module BABYLON {
  16810. /**
  16811. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  16812. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  16813. * 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;
  16814. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  16815. */
  16816. class ColorCurves {
  16817. private _dirty;
  16818. private _tempColor;
  16819. private _globalCurve;
  16820. private _highlightsCurve;
  16821. private _midtonesCurve;
  16822. private _shadowsCurve;
  16823. private _positiveCurve;
  16824. private _negativeCurve;
  16825. private _globalHue;
  16826. private _globalDensity;
  16827. private _globalSaturation;
  16828. private _globalExposure;
  16829. /**
  16830. * Gets the global Hue value.
  16831. * 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).
  16832. */
  16833. /**
  16834. * Sets the global Hue value.
  16835. * 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).
  16836. */
  16837. globalHue: number;
  16838. /**
  16839. * Gets the global Density value.
  16840. * 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.
  16841. * Values less than zero provide a filter of opposite hue.
  16842. */
  16843. /**
  16844. * Sets the global Density value.
  16845. * 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.
  16846. * Values less than zero provide a filter of opposite hue.
  16847. */
  16848. globalDensity: number;
  16849. /**
  16850. * Gets the global Saturation value.
  16851. * 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.
  16852. */
  16853. /**
  16854. * Sets the global Saturation value.
  16855. * 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.
  16856. */
  16857. globalSaturation: number;
  16858. /**
  16859. * Gets the global Exposure value.
  16860. * 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.
  16861. */
  16862. /**
  16863. * Sets the global Exposure value.
  16864. * 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.
  16865. */
  16866. globalExposure: number;
  16867. private _highlightsHue;
  16868. private _highlightsDensity;
  16869. private _highlightsSaturation;
  16870. private _highlightsExposure;
  16871. /**
  16872. * Gets the highlights Hue value.
  16873. * 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).
  16874. */
  16875. /**
  16876. * Sets the highlights Hue value.
  16877. * 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).
  16878. */
  16879. highlightsHue: number;
  16880. /**
  16881. * Gets the highlights Density value.
  16882. * 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.
  16883. * Values less than zero provide a filter of opposite hue.
  16884. */
  16885. /**
  16886. * Sets the highlights Density value.
  16887. * 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.
  16888. * Values less than zero provide a filter of opposite hue.
  16889. */
  16890. highlightsDensity: number;
  16891. /**
  16892. * Gets the highlights Saturation value.
  16893. * 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.
  16894. */
  16895. /**
  16896. * Sets the highlights Saturation value.
  16897. * 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.
  16898. */
  16899. highlightsSaturation: number;
  16900. /**
  16901. * Gets the highlights Exposure value.
  16902. * 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.
  16903. */
  16904. /**
  16905. * Sets the highlights Exposure value.
  16906. * 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.
  16907. */
  16908. highlightsExposure: number;
  16909. private _midtonesHue;
  16910. private _midtonesDensity;
  16911. private _midtonesSaturation;
  16912. private _midtonesExposure;
  16913. /**
  16914. * Gets the midtones Hue value.
  16915. * 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).
  16916. */
  16917. /**
  16918. * Sets the midtones Hue value.
  16919. * 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).
  16920. */
  16921. midtonesHue: number;
  16922. /**
  16923. * Gets the midtones Density value.
  16924. * 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.
  16925. * Values less than zero provide a filter of opposite hue.
  16926. */
  16927. /**
  16928. * Sets the midtones Density value.
  16929. * 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.
  16930. * Values less than zero provide a filter of opposite hue.
  16931. */
  16932. midtonesDensity: number;
  16933. /**
  16934. * Gets the midtones Saturation value.
  16935. * 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.
  16936. */
  16937. /**
  16938. * Sets the midtones Saturation value.
  16939. * 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.
  16940. */
  16941. midtonesSaturation: number;
  16942. /**
  16943. * Gets the midtones Exposure value.
  16944. * 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.
  16945. */
  16946. /**
  16947. * Sets the midtones Exposure value.
  16948. * 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.
  16949. */
  16950. midtonesExposure: number;
  16951. private _shadowsHue;
  16952. private _shadowsDensity;
  16953. private _shadowsSaturation;
  16954. private _shadowsExposure;
  16955. /**
  16956. * Gets the shadows 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. /**
  16960. * Sets the shadows Hue value.
  16961. * 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).
  16962. */
  16963. shadowsHue: number;
  16964. /**
  16965. * Gets the shadows Density value.
  16966. * 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.
  16967. * Values less than zero provide a filter of opposite hue.
  16968. */
  16969. /**
  16970. * Sets the shadows Density value.
  16971. * 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.
  16972. * Values less than zero provide a filter of opposite hue.
  16973. */
  16974. shadowsDensity: number;
  16975. /**
  16976. * Gets the shadows 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. /**
  16980. * Sets the shadows Saturation value.
  16981. * 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.
  16982. */
  16983. shadowsSaturation: number;
  16984. /**
  16985. * Gets the shadows 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. /**
  16989. * Sets the shadows Exposure value.
  16990. * 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.
  16991. */
  16992. shadowsExposure: number;
  16993. /**
  16994. * Returns the class name
  16995. * @returns The class name
  16996. */
  16997. getClassName(): string;
  16998. /**
  16999. * Binds the color curves to the shader.
  17000. * @param colorCurves The color curve to bind
  17001. * @param effect The effect to bind to
  17002. * @param positiveUniform The positive uniform shader parameter
  17003. * @param neutralUniform The neutral uniform shader parameter
  17004. * @param negativeUniform The negative uniform shader parameter
  17005. */
  17006. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  17007. /**
  17008. * Prepare the list of uniforms associated with the ColorCurves effects.
  17009. * @param uniformsList The list of uniforms used in the effect
  17010. */
  17011. static PrepareUniforms(uniformsList: string[]): void;
  17012. /**
  17013. * Returns color grading data based on a hue, density, saturation and exposure value.
  17014. * @param filterHue The hue of the color filter.
  17015. * @param filterDensity The density of the color filter.
  17016. * @param saturation The saturation.
  17017. * @param exposure The exposure.
  17018. * @param result The result data container.
  17019. */
  17020. private getColorGradingDataToRef;
  17021. /**
  17022. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  17023. * @param value The input slider value in range [-100,100].
  17024. * @returns Adjusted value.
  17025. */
  17026. private static applyColorGradingSliderNonlinear;
  17027. /**
  17028. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  17029. * @param hue The hue (H) input.
  17030. * @param saturation The saturation (S) input.
  17031. * @param brightness The brightness (B) input.
  17032. * @result An RGBA color represented as Vector4.
  17033. */
  17034. private static fromHSBToRef;
  17035. /**
  17036. * Returns a value clamped between min and max
  17037. * @param value The value to clamp
  17038. * @param min The minimum of value
  17039. * @param max The maximum of value
  17040. * @returns The clamped value.
  17041. */
  17042. private static clamp;
  17043. /**
  17044. * Clones the current color curve instance.
  17045. * @return The cloned curves
  17046. */
  17047. clone(): ColorCurves;
  17048. /**
  17049. * Serializes the current color curve instance to a json representation.
  17050. * @return a JSON representation
  17051. */
  17052. serialize(): any;
  17053. /**
  17054. * Parses the color curve from a json representation.
  17055. * @param source the JSON source to parse
  17056. * @return The parsed curves
  17057. */
  17058. static Parse(source: any): ColorCurves;
  17059. }
  17060. }
  17061. declare module BABYLON {
  17062. /**
  17063. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  17064. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  17065. */
  17066. class EffectFallbacks {
  17067. private _defines;
  17068. private _currentRank;
  17069. private _maxRank;
  17070. private _mesh;
  17071. /**
  17072. * Removes the fallback from the bound mesh.
  17073. */
  17074. unBindMesh(): void;
  17075. /**
  17076. * Adds a fallback on the specified property.
  17077. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17078. * @param define The name of the define in the shader
  17079. */
  17080. addFallback(rank: number, define: string): void;
  17081. /**
  17082. * Sets the mesh to use CPU skinning when needing to fallback.
  17083. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17084. * @param mesh The mesh to use the fallbacks.
  17085. */
  17086. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  17087. /**
  17088. * Checks to see if more fallbacks are still availible.
  17089. */
  17090. readonly isMoreFallbacks: boolean;
  17091. /**
  17092. * Removes the defines that shoould be removed when falling back.
  17093. * @param currentDefines defines the current define statements for the shader.
  17094. * @param effect defines the current effect we try to compile
  17095. * @returns The resulting defines with defines of the current rank removed.
  17096. */
  17097. reduce(currentDefines: string, effect: Effect): string;
  17098. }
  17099. /**
  17100. * Options to be used when creating an effect.
  17101. */
  17102. class EffectCreationOptions {
  17103. /**
  17104. * Atrributes that will be used in the shader.
  17105. */
  17106. attributes: string[];
  17107. /**
  17108. * Uniform varible names that will be set in the shader.
  17109. */
  17110. uniformsNames: string[];
  17111. /**
  17112. * Uniform buffer varible names that will be set in the shader.
  17113. */
  17114. uniformBuffersNames: string[];
  17115. /**
  17116. * Sampler texture variable names that will be set in the shader.
  17117. */
  17118. samplers: string[];
  17119. /**
  17120. * Define statements that will be set in the shader.
  17121. */
  17122. defines: any;
  17123. /**
  17124. * Possible fallbacks for this effect to improve performance when needed.
  17125. */
  17126. fallbacks: Nullable<EffectFallbacks>;
  17127. /**
  17128. * Callback that will be called when the shader is compiled.
  17129. */
  17130. onCompiled: Nullable<(effect: Effect) => void>;
  17131. /**
  17132. * Callback that will be called if an error occurs during shader compilation.
  17133. */
  17134. onError: Nullable<(effect: Effect, errors: string) => void>;
  17135. /**
  17136. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17137. */
  17138. indexParameters: any;
  17139. /**
  17140. * Max number of lights that can be used in the shader.
  17141. */
  17142. maxSimultaneousLights: number;
  17143. /**
  17144. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  17145. */
  17146. transformFeedbackVaryings: Nullable<string[]>;
  17147. }
  17148. /**
  17149. * Effect containing vertex and fragment shader that can be executed on an object.
  17150. */
  17151. class Effect {
  17152. /**
  17153. * Name of the effect.
  17154. */
  17155. name: any;
  17156. /**
  17157. * String container all the define statements that should be set on the shader.
  17158. */
  17159. defines: string;
  17160. /**
  17161. * Callback that will be called when the shader is compiled.
  17162. */
  17163. onCompiled: Nullable<(effect: Effect) => void>;
  17164. /**
  17165. * Callback that will be called if an error occurs during shader compilation.
  17166. */
  17167. onError: Nullable<(effect: Effect, errors: string) => void>;
  17168. /**
  17169. * Callback that will be called when effect is bound.
  17170. */
  17171. onBind: Nullable<(effect: Effect) => void>;
  17172. /**
  17173. * Unique ID of the effect.
  17174. */
  17175. uniqueId: number;
  17176. /**
  17177. * Observable that will be called when the shader is compiled.
  17178. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  17179. */
  17180. onCompileObservable: Observable<Effect>;
  17181. /**
  17182. * Observable that will be called if an error occurs during shader compilation.
  17183. */
  17184. onErrorObservable: Observable<Effect>;
  17185. /** @hidden */
  17186. _onBindObservable: Nullable<Observable<Effect>>;
  17187. /**
  17188. * Observable that will be called when effect is bound.
  17189. */
  17190. readonly onBindObservable: Observable<Effect>;
  17191. /** @hidden */
  17192. _bonesComputationForcedToCPU: boolean;
  17193. private static _uniqueIdSeed;
  17194. private _engine;
  17195. private _uniformBuffersNames;
  17196. private _uniformsNames;
  17197. private _samplers;
  17198. private _isReady;
  17199. private _compilationError;
  17200. private _attributesNames;
  17201. private _attributes;
  17202. private _uniforms;
  17203. /**
  17204. * Key for the effect.
  17205. * @hidden
  17206. */
  17207. _key: string;
  17208. private _indexParameters;
  17209. private _fallbacks;
  17210. private _vertexSourceCode;
  17211. private _fragmentSourceCode;
  17212. private _vertexSourceCodeOverride;
  17213. private _fragmentSourceCodeOverride;
  17214. private _transformFeedbackVaryings;
  17215. /**
  17216. * Compiled shader to webGL program.
  17217. * @hidden
  17218. */
  17219. _program: WebGLProgram;
  17220. private _valueCache;
  17221. private static _baseCache;
  17222. /**
  17223. * Instantiates an effect.
  17224. * An effect can be used to create/manage/execute vertex and fragment shaders.
  17225. * @param baseName Name of the effect.
  17226. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  17227. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  17228. * @param samplers List of sampler variables that will be passed to the shader.
  17229. * @param engine Engine to be used to render the effect
  17230. * @param defines Define statements to be added to the shader.
  17231. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  17232. * @param onCompiled Callback that will be called when the shader is compiled.
  17233. * @param onError Callback that will be called if an error occurs during shader compilation.
  17234. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17235. */
  17236. 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);
  17237. /**
  17238. * Unique key for this effect
  17239. */
  17240. readonly key: string;
  17241. /**
  17242. * If the effect has been compiled and prepared.
  17243. * @returns if the effect is compiled and prepared.
  17244. */
  17245. isReady(): boolean;
  17246. /**
  17247. * The engine the effect was initialized with.
  17248. * @returns the engine.
  17249. */
  17250. getEngine(): Engine;
  17251. /**
  17252. * The compiled webGL program for the effect
  17253. * @returns the webGL program.
  17254. */
  17255. getProgram(): WebGLProgram;
  17256. /**
  17257. * The set of names of attribute variables for the shader.
  17258. * @returns An array of attribute names.
  17259. */
  17260. getAttributesNames(): string[];
  17261. /**
  17262. * Returns the attribute at the given index.
  17263. * @param index The index of the attribute.
  17264. * @returns The location of the attribute.
  17265. */
  17266. getAttributeLocation(index: number): number;
  17267. /**
  17268. * Returns the attribute based on the name of the variable.
  17269. * @param name of the attribute to look up.
  17270. * @returns the attribute location.
  17271. */
  17272. getAttributeLocationByName(name: string): number;
  17273. /**
  17274. * The number of attributes.
  17275. * @returns the numnber of attributes.
  17276. */
  17277. getAttributesCount(): number;
  17278. /**
  17279. * Gets the index of a uniform variable.
  17280. * @param uniformName of the uniform to look up.
  17281. * @returns the index.
  17282. */
  17283. getUniformIndex(uniformName: string): number;
  17284. /**
  17285. * Returns the attribute based on the name of the variable.
  17286. * @param uniformName of the uniform to look up.
  17287. * @returns the location of the uniform.
  17288. */
  17289. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  17290. /**
  17291. * Returns an array of sampler variable names
  17292. * @returns The array of sampler variable neames.
  17293. */
  17294. getSamplers(): string[];
  17295. /**
  17296. * The error from the last compilation.
  17297. * @returns the error string.
  17298. */
  17299. getCompilationError(): string;
  17300. /**
  17301. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  17302. * @param func The callback to be used.
  17303. */
  17304. executeWhenCompiled(func: (effect: Effect) => void): void;
  17305. private _checkIsReady;
  17306. /** @hidden */
  17307. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  17308. /** @hidden */
  17309. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  17310. /** @hidden */
  17311. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  17312. private _processShaderConversion;
  17313. private _processIncludes;
  17314. private _processPrecision;
  17315. /**
  17316. * Recompiles the webGL program
  17317. * @param vertexSourceCode The source code for the vertex shader.
  17318. * @param fragmentSourceCode The source code for the fragment shader.
  17319. * @param onCompiled Callback called when completed.
  17320. * @param onError Callback called on error.
  17321. * @hidden
  17322. */
  17323. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  17324. /**
  17325. * Gets the uniform locations of the the specified variable names
  17326. * @param names THe names of the variables to lookup.
  17327. * @returns Array of locations in the same order as variable names.
  17328. */
  17329. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  17330. /**
  17331. * Prepares the effect
  17332. * @hidden
  17333. */
  17334. _prepareEffect(): void;
  17335. /**
  17336. * Checks if the effect is supported. (Must be called after compilation)
  17337. */
  17338. readonly isSupported: boolean;
  17339. /**
  17340. * Binds a texture to the engine to be used as output of the shader.
  17341. * @param channel Name of the output variable.
  17342. * @param texture Texture to bind.
  17343. * @hidden
  17344. */
  17345. _bindTexture(channel: string, texture: InternalTexture): void;
  17346. /**
  17347. * Sets a texture on the engine to be used in the shader.
  17348. * @param channel Name of the sampler variable.
  17349. * @param texture Texture to set.
  17350. */
  17351. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  17352. /**
  17353. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  17354. * @param channel Name of the sampler variable.
  17355. * @param texture Texture to set.
  17356. */
  17357. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  17358. /**
  17359. * Sets an array of textures on the engine to be used in the shader.
  17360. * @param channel Name of the variable.
  17361. * @param textures Textures to set.
  17362. */
  17363. setTextureArray(channel: string, textures: BaseTexture[]): void;
  17364. /**
  17365. * 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)
  17366. * @param channel Name of the sampler variable.
  17367. * @param postProcess Post process to get the input texture from.
  17368. */
  17369. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  17370. /**
  17371. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  17372. * 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)
  17373. * @param channel Name of the sampler variable.
  17374. * @param postProcess Post process to get the output texture from.
  17375. */
  17376. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  17377. /** @hidden */
  17378. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  17379. /** @hidden */
  17380. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  17381. /** @hidden */
  17382. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  17383. /** @hidden */
  17384. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  17385. /**
  17386. * Binds a buffer to a uniform.
  17387. * @param buffer Buffer to bind.
  17388. * @param name Name of the uniform variable to bind to.
  17389. */
  17390. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  17391. /**
  17392. * Binds block to a uniform.
  17393. * @param blockName Name of the block to bind.
  17394. * @param index Index to bind.
  17395. */
  17396. bindUniformBlock(blockName: string, index: number): void;
  17397. /**
  17398. * Sets an interger value on a uniform variable.
  17399. * @param uniformName Name of the variable.
  17400. * @param value Value to be set.
  17401. * @returns this effect.
  17402. */
  17403. setInt(uniformName: string, value: number): Effect;
  17404. /**
  17405. * Sets an int array on a uniform variable.
  17406. * @param uniformName Name of the variable.
  17407. * @param array array to be set.
  17408. * @returns this effect.
  17409. */
  17410. setIntArray(uniformName: string, array: Int32Array): Effect;
  17411. /**
  17412. * 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)
  17413. * @param uniformName Name of the variable.
  17414. * @param array array to be set.
  17415. * @returns this effect.
  17416. */
  17417. setIntArray2(uniformName: string, array: Int32Array): Effect;
  17418. /**
  17419. * 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)
  17420. * @param uniformName Name of the variable.
  17421. * @param array array to be set.
  17422. * @returns this effect.
  17423. */
  17424. setIntArray3(uniformName: string, array: Int32Array): Effect;
  17425. /**
  17426. * 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)
  17427. * @param uniformName Name of the variable.
  17428. * @param array array to be set.
  17429. * @returns this effect.
  17430. */
  17431. setIntArray4(uniformName: string, array: Int32Array): Effect;
  17432. /**
  17433. * Sets an float array on a uniform variable.
  17434. * @param uniformName Name of the variable.
  17435. * @param array array to be set.
  17436. * @returns this effect.
  17437. */
  17438. setFloatArray(uniformName: string, array: Float32Array): Effect;
  17439. /**
  17440. * 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)
  17441. * @param uniformName Name of the variable.
  17442. * @param array array to be set.
  17443. * @returns this effect.
  17444. */
  17445. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  17446. /**
  17447. * 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)
  17448. * @param uniformName Name of the variable.
  17449. * @param array array to be set.
  17450. * @returns this effect.
  17451. */
  17452. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  17453. /**
  17454. * 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)
  17455. * @param uniformName Name of the variable.
  17456. * @param array array to be set.
  17457. * @returns this effect.
  17458. */
  17459. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  17460. /**
  17461. * Sets an array on a uniform variable.
  17462. * @param uniformName Name of the variable.
  17463. * @param array array to be set.
  17464. * @returns this effect.
  17465. */
  17466. setArray(uniformName: string, array: number[]): Effect;
  17467. /**
  17468. * 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)
  17469. * @param uniformName Name of the variable.
  17470. * @param array array to be set.
  17471. * @returns this effect.
  17472. */
  17473. setArray2(uniformName: string, array: number[]): Effect;
  17474. /**
  17475. * 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)
  17476. * @param uniformName Name of the variable.
  17477. * @param array array to be set.
  17478. * @returns this effect.
  17479. */
  17480. setArray3(uniformName: string, array: number[]): Effect;
  17481. /**
  17482. * 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)
  17483. * @param uniformName Name of the variable.
  17484. * @param array array to be set.
  17485. * @returns this effect.
  17486. */
  17487. setArray4(uniformName: string, array: number[]): Effect;
  17488. /**
  17489. * Sets matrices on a uniform variable.
  17490. * @param uniformName Name of the variable.
  17491. * @param matrices matrices to be set.
  17492. * @returns this effect.
  17493. */
  17494. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  17495. /**
  17496. * Sets matrix on a uniform variable.
  17497. * @param uniformName Name of the variable.
  17498. * @param matrix matrix to be set.
  17499. * @returns this effect.
  17500. */
  17501. setMatrix(uniformName: string, matrix: Matrix): Effect;
  17502. /**
  17503. * 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)
  17504. * @param uniformName Name of the variable.
  17505. * @param matrix matrix to be set.
  17506. * @returns this effect.
  17507. */
  17508. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  17509. /**
  17510. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  17511. * @param uniformName Name of the variable.
  17512. * @param matrix matrix to be set.
  17513. * @returns this effect.
  17514. */
  17515. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  17516. /**
  17517. * Sets a float on a uniform variable.
  17518. * @param uniformName Name of the variable.
  17519. * @param value value to be set.
  17520. * @returns this effect.
  17521. */
  17522. setFloat(uniformName: string, value: number): Effect;
  17523. /**
  17524. * Sets a boolean on a uniform variable.
  17525. * @param uniformName Name of the variable.
  17526. * @param bool value to be set.
  17527. * @returns this effect.
  17528. */
  17529. setBool(uniformName: string, bool: boolean): Effect;
  17530. /**
  17531. * Sets a Vector2 on a uniform variable.
  17532. * @param uniformName Name of the variable.
  17533. * @param vector2 vector2 to be set.
  17534. * @returns this effect.
  17535. */
  17536. setVector2(uniformName: string, vector2: Vector2): Effect;
  17537. /**
  17538. * Sets a float2 on a uniform variable.
  17539. * @param uniformName Name of the variable.
  17540. * @param x First float in float2.
  17541. * @param y Second float in float2.
  17542. * @returns this effect.
  17543. */
  17544. setFloat2(uniformName: string, x: number, y: number): Effect;
  17545. /**
  17546. * Sets a Vector3 on a uniform variable.
  17547. * @param uniformName Name of the variable.
  17548. * @param vector3 Value to be set.
  17549. * @returns this effect.
  17550. */
  17551. setVector3(uniformName: string, vector3: Vector3): Effect;
  17552. /**
  17553. * Sets a float3 on a uniform variable.
  17554. * @param uniformName Name of the variable.
  17555. * @param x First float in float3.
  17556. * @param y Second float in float3.
  17557. * @param z Third float in float3.
  17558. * @returns this effect.
  17559. */
  17560. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  17561. /**
  17562. * Sets a Vector4 on a uniform variable.
  17563. * @param uniformName Name of the variable.
  17564. * @param vector4 Value to be set.
  17565. * @returns this effect.
  17566. */
  17567. setVector4(uniformName: string, vector4: Vector4): Effect;
  17568. /**
  17569. * Sets a float4 on a uniform variable.
  17570. * @param uniformName Name of the variable.
  17571. * @param x First float in float4.
  17572. * @param y Second float in float4.
  17573. * @param z Third float in float4.
  17574. * @param w Fourth float in float4.
  17575. * @returns this effect.
  17576. */
  17577. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  17578. /**
  17579. * Sets a Color3 on a uniform variable.
  17580. * @param uniformName Name of the variable.
  17581. * @param color3 Value to be set.
  17582. * @returns this effect.
  17583. */
  17584. setColor3(uniformName: string, color3: Color3): Effect;
  17585. /**
  17586. * Sets a Color4 on a uniform variable.
  17587. * @param uniformName Name of the variable.
  17588. * @param color3 Value to be set.
  17589. * @param alpha Alpha value to be set.
  17590. * @returns this effect.
  17591. */
  17592. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  17593. /**
  17594. * Sets a Color4 on a uniform variable
  17595. * @param uniformName defines the name of the variable
  17596. * @param color4 defines the value to be set
  17597. * @returns this effect.
  17598. */
  17599. setDirectColor4(uniformName: string, color4: Color4): Effect;
  17600. /**
  17601. * This function will add a new shader to the shader store
  17602. * @param name the name of the shader
  17603. * @param pixelShader optional pixel shader content
  17604. * @param vertexShader optional vertex shader content
  17605. */
  17606. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  17607. /**
  17608. * Store of each shader (The can be looked up using effect.key)
  17609. */
  17610. static ShadersStore: {
  17611. [key: string]: string;
  17612. };
  17613. /**
  17614. * Store of each included file for a shader (The can be looked up using effect.key)
  17615. */
  17616. static IncludesShadersStore: {
  17617. [key: string]: string;
  17618. };
  17619. /**
  17620. * Resets the cache of effects.
  17621. */
  17622. static ResetCache(): void;
  17623. }
  17624. }
  17625. declare module BABYLON {
  17626. /**
  17627. * This represents all the required information to add a fresnel effect on a material:
  17628. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  17629. */
  17630. class FresnelParameters {
  17631. private _isEnabled;
  17632. /**
  17633. * Define if the fresnel effect is enable or not.
  17634. */
  17635. isEnabled: boolean;
  17636. /**
  17637. * Define the color used on edges (grazing angle)
  17638. */
  17639. leftColor: Color3;
  17640. /**
  17641. * Define the color used on center
  17642. */
  17643. rightColor: Color3;
  17644. /**
  17645. * Define bias applied to computed fresnel term
  17646. */
  17647. bias: number;
  17648. /**
  17649. * Defined the power exponent applied to fresnel term
  17650. */
  17651. power: number;
  17652. /**
  17653. * Clones the current fresnel and its valuues
  17654. * @returns a clone fresnel configuration
  17655. */
  17656. clone(): FresnelParameters;
  17657. /**
  17658. * Serializes the current fresnel parameters to a JSON representation.
  17659. * @return the JSON serialization
  17660. */
  17661. serialize(): any;
  17662. /**
  17663. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  17664. * @param parsedFresnelParameters Define the JSON representation
  17665. * @returns the parsed parameters
  17666. */
  17667. static Parse(parsedFresnelParameters: any): FresnelParameters;
  17668. }
  17669. }
  17670. declare module BABYLON {
  17671. /**
  17672. * Interface to follow in your material defines to integrate easily the
  17673. * Image proccessing functions.
  17674. * @hidden
  17675. */
  17676. interface IImageProcessingConfigurationDefines {
  17677. IMAGEPROCESSING: boolean;
  17678. VIGNETTE: boolean;
  17679. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17680. VIGNETTEBLENDMODEOPAQUE: boolean;
  17681. TONEMAPPING: boolean;
  17682. TONEMAPPING_ACES: boolean;
  17683. CONTRAST: boolean;
  17684. EXPOSURE: boolean;
  17685. COLORCURVES: boolean;
  17686. COLORGRADING: boolean;
  17687. COLORGRADING3D: boolean;
  17688. SAMPLER3DGREENDEPTH: boolean;
  17689. SAMPLER3DBGRMAP: boolean;
  17690. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17691. }
  17692. /**
  17693. * @hidden
  17694. */
  17695. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17696. IMAGEPROCESSING: boolean;
  17697. VIGNETTE: boolean;
  17698. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17699. VIGNETTEBLENDMODEOPAQUE: boolean;
  17700. TONEMAPPING: boolean;
  17701. TONEMAPPING_ACES: boolean;
  17702. CONTRAST: boolean;
  17703. COLORCURVES: boolean;
  17704. COLORGRADING: boolean;
  17705. COLORGRADING3D: boolean;
  17706. SAMPLER3DGREENDEPTH: boolean;
  17707. SAMPLER3DBGRMAP: boolean;
  17708. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17709. EXPOSURE: boolean;
  17710. constructor();
  17711. }
  17712. /**
  17713. * This groups together the common properties used for image processing either in direct forward pass
  17714. * or through post processing effect depending on the use of the image processing pipeline in your scene
  17715. * or not.
  17716. */
  17717. class ImageProcessingConfiguration {
  17718. /**
  17719. * Default tone mapping applied in BabylonJS.
  17720. */
  17721. static readonly TONEMAPPING_STANDARD: number;
  17722. /**
  17723. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  17724. * to other engines rendering to increase portability.
  17725. */
  17726. static readonly TONEMAPPING_ACES: number;
  17727. /**
  17728. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  17729. */
  17730. colorCurves: Nullable<ColorCurves>;
  17731. private _colorCurvesEnabled;
  17732. /**
  17733. * Gets wether the color curves effect is enabled.
  17734. */
  17735. /**
  17736. * Sets wether the color curves effect is enabled.
  17737. */
  17738. colorCurvesEnabled: boolean;
  17739. private _colorGradingTexture;
  17740. /**
  17741. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17742. */
  17743. /**
  17744. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17745. */
  17746. colorGradingTexture: Nullable<BaseTexture>;
  17747. private _colorGradingEnabled;
  17748. /**
  17749. * Gets wether the color grading effect is enabled.
  17750. */
  17751. /**
  17752. * Sets wether the color grading effect is enabled.
  17753. */
  17754. colorGradingEnabled: boolean;
  17755. private _colorGradingWithGreenDepth;
  17756. /**
  17757. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  17758. */
  17759. /**
  17760. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  17761. */
  17762. colorGradingWithGreenDepth: boolean;
  17763. private _colorGradingBGR;
  17764. /**
  17765. * Gets wether the color grading texture contains BGR values.
  17766. */
  17767. /**
  17768. * Sets wether the color grading texture contains BGR values.
  17769. */
  17770. colorGradingBGR: boolean;
  17771. /** @hidden */
  17772. _exposure: number;
  17773. /**
  17774. * Gets the Exposure used in the effect.
  17775. */
  17776. /**
  17777. * Sets the Exposure used in the effect.
  17778. */
  17779. exposure: number;
  17780. private _toneMappingEnabled;
  17781. /**
  17782. * Gets wether the tone mapping effect is enabled.
  17783. */
  17784. /**
  17785. * Sets wether the tone mapping effect is enabled.
  17786. */
  17787. toneMappingEnabled: boolean;
  17788. private _toneMappingType;
  17789. /**
  17790. * Gets the type of tone mapping effect.
  17791. */
  17792. /**
  17793. * Sets the type of tone mapping effect used in BabylonJS.
  17794. */
  17795. toneMappingType: number;
  17796. protected _contrast: number;
  17797. /**
  17798. * Gets the contrast used in the effect.
  17799. */
  17800. /**
  17801. * Sets the contrast used in the effect.
  17802. */
  17803. contrast: number;
  17804. /**
  17805. * Vignette stretch size.
  17806. */
  17807. vignetteStretch: number;
  17808. /**
  17809. * Vignette centre X Offset.
  17810. */
  17811. vignetteCentreX: number;
  17812. /**
  17813. * Vignette centre Y Offset.
  17814. */
  17815. vignetteCentreY: number;
  17816. /**
  17817. * Vignette weight or intensity of the vignette effect.
  17818. */
  17819. vignetteWeight: number;
  17820. /**
  17821. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17822. * if vignetteEnabled is set to true.
  17823. */
  17824. vignetteColor: Color4;
  17825. /**
  17826. * Camera field of view used by the Vignette effect.
  17827. */
  17828. vignetteCameraFov: number;
  17829. private _vignetteBlendMode;
  17830. /**
  17831. * Gets the vignette blend mode allowing different kind of effect.
  17832. */
  17833. /**
  17834. * Sets the vignette blend mode allowing different kind of effect.
  17835. */
  17836. vignetteBlendMode: number;
  17837. private _vignetteEnabled;
  17838. /**
  17839. * Gets wether the vignette effect is enabled.
  17840. */
  17841. /**
  17842. * Sets wether the vignette effect is enabled.
  17843. */
  17844. vignetteEnabled: boolean;
  17845. private _applyByPostProcess;
  17846. /**
  17847. * Gets wether the image processing is applied through a post process or not.
  17848. */
  17849. /**
  17850. * Sets wether the image processing is applied through a post process or not.
  17851. */
  17852. applyByPostProcess: boolean;
  17853. private _isEnabled;
  17854. /**
  17855. * Gets wether the image processing is enabled or not.
  17856. */
  17857. /**
  17858. * Sets wether the image processing is enabled or not.
  17859. */
  17860. isEnabled: boolean;
  17861. /**
  17862. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  17863. */
  17864. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  17865. /**
  17866. * Method called each time the image processing information changes requires to recompile the effect.
  17867. */
  17868. protected _updateParameters(): void;
  17869. /**
  17870. * Gets the current class name.
  17871. * @return "ImageProcessingConfiguration"
  17872. */
  17873. getClassName(): string;
  17874. /**
  17875. * Prepare the list of uniforms associated with the Image Processing effects.
  17876. * @param uniforms The list of uniforms used in the effect
  17877. * @param defines the list of defines currently in use
  17878. */
  17879. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  17880. /**
  17881. * Prepare the list of samplers associated with the Image Processing effects.
  17882. * @param samplersList The list of uniforms used in the effect
  17883. * @param defines the list of defines currently in use
  17884. */
  17885. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  17886. /**
  17887. * Prepare the list of defines associated to the shader.
  17888. * @param defines the list of defines to complete
  17889. * @param forPostProcess Define if we are currently in post process mode or not
  17890. */
  17891. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  17892. /**
  17893. * Returns true if all the image processing information are ready.
  17894. * @returns True if ready, otherwise, false
  17895. */
  17896. isReady(): boolean;
  17897. /**
  17898. * Binds the image processing to the shader.
  17899. * @param effect The effect to bind to
  17900. * @param aspectRatio Define the current aspect ratio of the effect
  17901. */
  17902. bind(effect: Effect, aspectRatio?: number): void;
  17903. /**
  17904. * Clones the current image processing instance.
  17905. * @return The cloned image processing
  17906. */
  17907. clone(): ImageProcessingConfiguration;
  17908. /**
  17909. * Serializes the current image processing instance to a json representation.
  17910. * @return a JSON representation
  17911. */
  17912. serialize(): any;
  17913. /**
  17914. * Parses the image processing from a json representation.
  17915. * @param source the JSON source to parse
  17916. * @return The parsed image processing
  17917. */
  17918. static Parse(source: any): ImageProcessingConfiguration;
  17919. private static _VIGNETTEMODE_MULTIPLY;
  17920. private static _VIGNETTEMODE_OPAQUE;
  17921. /**
  17922. * Used to apply the vignette as a mix with the pixel color.
  17923. */
  17924. static readonly VIGNETTEMODE_MULTIPLY: number;
  17925. /**
  17926. * Used to apply the vignette as a replacement of the pixel color.
  17927. */
  17928. static readonly VIGNETTEMODE_OPAQUE: number;
  17929. }
  17930. }
  17931. declare module BABYLON {
  17932. /**
  17933. * Manages the defines for the Material
  17934. */
  17935. class MaterialDefines {
  17936. private _keys;
  17937. private _isDirty;
  17938. /** @hidden */
  17939. _renderId: number;
  17940. /** @hidden */
  17941. _areLightsDirty: boolean;
  17942. /** @hidden */
  17943. _areAttributesDirty: boolean;
  17944. /** @hidden */
  17945. _areTexturesDirty: boolean;
  17946. /** @hidden */
  17947. _areFresnelDirty: boolean;
  17948. /** @hidden */
  17949. _areMiscDirty: boolean;
  17950. /** @hidden */
  17951. _areImageProcessingDirty: boolean;
  17952. /** @hidden */
  17953. _normals: boolean;
  17954. /** @hidden */
  17955. _uvs: boolean;
  17956. /** @hidden */
  17957. _needNormals: boolean;
  17958. /** @hidden */
  17959. _needUVs: boolean;
  17960. /**
  17961. * Specifies if the material needs to be re-calculated
  17962. */
  17963. readonly isDirty: boolean;
  17964. /**
  17965. * Marks the material to indicate that it has been re-calculated
  17966. */
  17967. markAsProcessed(): void;
  17968. /**
  17969. * Marks the material to indicate that it needs to be re-calculated
  17970. */
  17971. markAsUnprocessed(): void;
  17972. /**
  17973. * Marks the material to indicate all of its defines need to be re-calculated
  17974. */
  17975. markAllAsDirty(): void;
  17976. /**
  17977. * Marks the material to indicate that image processing needs to be re-calculated
  17978. */
  17979. markAsImageProcessingDirty(): void;
  17980. /**
  17981. * Marks the material to indicate the lights need to be re-calculated
  17982. */
  17983. markAsLightDirty(): void;
  17984. /**
  17985. * Marks the attribute state as changed
  17986. */
  17987. markAsAttributesDirty(): void;
  17988. /**
  17989. * Marks the texture state as changed
  17990. */
  17991. markAsTexturesDirty(): void;
  17992. /**
  17993. * Marks the fresnel state as changed
  17994. */
  17995. markAsFresnelDirty(): void;
  17996. /**
  17997. * Marks the misc state as changed
  17998. */
  17999. markAsMiscDirty(): void;
  18000. /**
  18001. * Rebuilds the material defines
  18002. */
  18003. rebuild(): void;
  18004. /**
  18005. * Specifies if two material defines are equal
  18006. * @param other - A material define instance to compare to
  18007. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  18008. */
  18009. isEqual(other: MaterialDefines): boolean;
  18010. /**
  18011. * Clones this instance's defines to another instance
  18012. * @param other - material defines to clone values to
  18013. */
  18014. cloneTo(other: MaterialDefines): void;
  18015. /**
  18016. * Resets the material define values
  18017. */
  18018. reset(): void;
  18019. /**
  18020. * Converts the material define values to a string
  18021. * @returns - String of material define information
  18022. */
  18023. toString(): string;
  18024. }
  18025. /**
  18026. * Base class for the main features of a material in Babylon.js
  18027. */
  18028. class Material implements IAnimatable {
  18029. private static _TriangleFillMode;
  18030. private static _WireFrameFillMode;
  18031. private static _PointFillMode;
  18032. private static _PointListDrawMode;
  18033. private static _LineListDrawMode;
  18034. private static _LineLoopDrawMode;
  18035. private static _LineStripDrawMode;
  18036. private static _TriangleStripDrawMode;
  18037. private static _TriangleFanDrawMode;
  18038. /**
  18039. * Returns the triangle fill mode
  18040. */
  18041. static readonly TriangleFillMode: number;
  18042. /**
  18043. * Returns the wireframe mode
  18044. */
  18045. static readonly WireFrameFillMode: number;
  18046. /**
  18047. * Returns the point fill mode
  18048. */
  18049. static readonly PointFillMode: number;
  18050. /**
  18051. * Returns the point list draw mode
  18052. */
  18053. static readonly PointListDrawMode: number;
  18054. /**
  18055. * Returns the line list draw mode
  18056. */
  18057. static readonly LineListDrawMode: number;
  18058. /**
  18059. * Returns the line loop draw mode
  18060. */
  18061. static readonly LineLoopDrawMode: number;
  18062. /**
  18063. * Returns the line strip draw mode
  18064. */
  18065. static readonly LineStripDrawMode: number;
  18066. /**
  18067. * Returns the triangle strip draw mode
  18068. */
  18069. static readonly TriangleStripDrawMode: number;
  18070. /**
  18071. * Returns the triangle fan draw mode
  18072. */
  18073. static readonly TriangleFanDrawMode: number;
  18074. /**
  18075. * Stores the clock-wise side orientation
  18076. */
  18077. private static _ClockWiseSideOrientation;
  18078. /**
  18079. * Stores the counter clock-wise side orientation
  18080. */
  18081. private static _CounterClockWiseSideOrientation;
  18082. /**
  18083. * Returns the clock-wise side orientation
  18084. */
  18085. static readonly ClockWiseSideOrientation: number;
  18086. /**
  18087. * Returns the counter clock-wise side orientation
  18088. */
  18089. static readonly CounterClockWiseSideOrientation: number;
  18090. /**
  18091. * The dirty texture flag value
  18092. */
  18093. static readonly TextureDirtyFlag: number;
  18094. /**
  18095. * The dirty light flag value
  18096. */
  18097. static readonly LightDirtyFlag: number;
  18098. /**
  18099. * The dirty fresnel flag value
  18100. */
  18101. static readonly FresnelDirtyFlag: number;
  18102. /**
  18103. * The dirty attribute flag value
  18104. */
  18105. static readonly AttributesDirtyFlag: number;
  18106. /**
  18107. * The dirty misc flag value
  18108. */
  18109. static readonly MiscDirtyFlag: number;
  18110. /**
  18111. * The all dirty flag value
  18112. */
  18113. static readonly AllDirtyFlag: number;
  18114. /**
  18115. * The ID of the material
  18116. */
  18117. id: string;
  18118. /**
  18119. * Gets or sets the unique id of the material
  18120. */
  18121. uniqueId: number;
  18122. /**
  18123. * The name of the material
  18124. */
  18125. name: string;
  18126. /**
  18127. * Gets or sets user defined metadata
  18128. */
  18129. metadata: any;
  18130. /**
  18131. * Specifies if the ready state should be checked on each call
  18132. */
  18133. checkReadyOnEveryCall: boolean;
  18134. /**
  18135. * Specifies if the ready state should be checked once
  18136. */
  18137. checkReadyOnlyOnce: boolean;
  18138. /**
  18139. * The state of the material
  18140. */
  18141. state: string;
  18142. /**
  18143. * The alpha value of the material
  18144. */
  18145. protected _alpha: number;
  18146. /**
  18147. * Sets the alpha value of the material
  18148. */
  18149. /**
  18150. * Gets the alpha value of the material
  18151. */
  18152. alpha: number;
  18153. /**
  18154. * Specifies if back face culling is enabled
  18155. */
  18156. protected _backFaceCulling: boolean;
  18157. /**
  18158. * Sets the back-face culling state
  18159. */
  18160. /**
  18161. * Gets the back-face culling state
  18162. */
  18163. backFaceCulling: boolean;
  18164. /**
  18165. * Stores the value for side orientation
  18166. */
  18167. sideOrientation: number;
  18168. /**
  18169. * Callback triggered when the material is compiled
  18170. */
  18171. onCompiled: (effect: Effect) => void;
  18172. /**
  18173. * Callback triggered when an error occurs
  18174. */
  18175. onError: (effect: Effect, errors: string) => void;
  18176. /**
  18177. * Callback triggered to get the render target textures
  18178. */
  18179. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  18180. /**
  18181. * Gets a boolean indicating that current material needs to register RTT
  18182. */
  18183. readonly hasRenderTargetTextures: boolean;
  18184. /**
  18185. * Specifies if the material should be serialized
  18186. */
  18187. doNotSerialize: boolean;
  18188. /**
  18189. * @hidden
  18190. */
  18191. _storeEffectOnSubMeshes: boolean;
  18192. /**
  18193. * Stores the animations for the material
  18194. */
  18195. animations: Array<Animation>;
  18196. /**
  18197. * An event triggered when the material is disposed
  18198. */
  18199. onDisposeObservable: Observable<Material>;
  18200. /**
  18201. * An observer which watches for dispose events
  18202. */
  18203. private _onDisposeObserver;
  18204. private _onUnBindObservable;
  18205. /**
  18206. * Called during a dispose event
  18207. */
  18208. onDispose: () => void;
  18209. private _onBindObservable;
  18210. /**
  18211. * An event triggered when the material is bound
  18212. */
  18213. readonly onBindObservable: Observable<AbstractMesh>;
  18214. /**
  18215. * An observer which watches for bind events
  18216. */
  18217. private _onBindObserver;
  18218. /**
  18219. * Called during a bind event
  18220. */
  18221. onBind: (Mesh: AbstractMesh) => void;
  18222. /**
  18223. * An event triggered when the material is unbound
  18224. */
  18225. readonly onUnBindObservable: Observable<Material>;
  18226. /**
  18227. * Stores the value of the alpha mode
  18228. */
  18229. private _alphaMode;
  18230. /**
  18231. * Sets the value of the alpha mode.
  18232. *
  18233. * | Value | Type | Description |
  18234. * | --- | --- | --- |
  18235. * | 0 | ALPHA_DISABLE | |
  18236. * | 1 | ALPHA_ADD | |
  18237. * | 2 | ALPHA_COMBINE | |
  18238. * | 3 | ALPHA_SUBTRACT | |
  18239. * | 4 | ALPHA_MULTIPLY | |
  18240. * | 5 | ALPHA_MAXIMIZED | |
  18241. * | 6 | ALPHA_ONEONE | |
  18242. * | 7 | ALPHA_PREMULTIPLIED | |
  18243. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  18244. * | 9 | ALPHA_INTERPOLATE | |
  18245. * | 10 | ALPHA_SCREENMODE | |
  18246. *
  18247. */
  18248. /**
  18249. * Gets the value of the alpha mode
  18250. */
  18251. alphaMode: number;
  18252. /**
  18253. * Stores the state of the need depth pre-pass value
  18254. */
  18255. private _needDepthPrePass;
  18256. /**
  18257. * Sets the need depth pre-pass value
  18258. */
  18259. /**
  18260. * Gets the depth pre-pass value
  18261. */
  18262. needDepthPrePass: boolean;
  18263. /**
  18264. * Specifies if depth writing should be disabled
  18265. */
  18266. disableDepthWrite: boolean;
  18267. /**
  18268. * Specifies if depth writing should be forced
  18269. */
  18270. forceDepthWrite: boolean;
  18271. /**
  18272. * Specifies if there should be a separate pass for culling
  18273. */
  18274. separateCullingPass: boolean;
  18275. /**
  18276. * Stores the state specifing if fog should be enabled
  18277. */
  18278. private _fogEnabled;
  18279. /**
  18280. * Sets the state for enabling fog
  18281. */
  18282. /**
  18283. * Gets the value of the fog enabled state
  18284. */
  18285. fogEnabled: boolean;
  18286. /**
  18287. * Stores the size of points
  18288. */
  18289. pointSize: number;
  18290. /**
  18291. * Stores the z offset value
  18292. */
  18293. zOffset: number;
  18294. /**
  18295. * Gets a value specifying if wireframe mode is enabled
  18296. */
  18297. /**
  18298. * Sets the state of wireframe mode
  18299. */
  18300. wireframe: boolean;
  18301. /**
  18302. * Gets the value specifying if point clouds are enabled
  18303. */
  18304. /**
  18305. * Sets the state of point cloud mode
  18306. */
  18307. pointsCloud: boolean;
  18308. /**
  18309. * Gets the material fill mode
  18310. */
  18311. /**
  18312. * Sets the material fill mode
  18313. */
  18314. fillMode: number;
  18315. /**
  18316. * @hidden
  18317. * Stores the effects for the material
  18318. */
  18319. _effect: Nullable<Effect>;
  18320. /**
  18321. * @hidden
  18322. * Specifies if the material was previously ready
  18323. */
  18324. _wasPreviouslyReady: boolean;
  18325. /**
  18326. * Specifies if uniform buffers should be used
  18327. */
  18328. private _useUBO;
  18329. /**
  18330. * Stores a reference to the scene
  18331. */
  18332. private _scene;
  18333. /**
  18334. * Stores the fill mode state
  18335. */
  18336. private _fillMode;
  18337. /**
  18338. * Specifies if the depth write state should be cached
  18339. */
  18340. private _cachedDepthWriteState;
  18341. /**
  18342. * Stores the uniform buffer
  18343. */
  18344. protected _uniformBuffer: UniformBuffer;
  18345. /** @hidden */
  18346. _indexInSceneMaterialArray: number;
  18347. /** @hidden */
  18348. meshMap: Nullable<{
  18349. [id: string]: AbstractMesh | undefined;
  18350. }>;
  18351. /**
  18352. * Creates a material instance
  18353. * @param name defines the name of the material
  18354. * @param scene defines the scene to reference
  18355. * @param doNotAdd specifies if the material should be added to the scene
  18356. */
  18357. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  18358. /**
  18359. * Returns a string representation of the current material
  18360. * @param fullDetails defines a boolean indicating which levels of logging is desired
  18361. * @returns a string with material information
  18362. */
  18363. toString(fullDetails?: boolean): string;
  18364. /**
  18365. * Gets the class name of the material
  18366. * @returns a string with the class name of the material
  18367. */
  18368. getClassName(): string;
  18369. /**
  18370. * Specifies if updates for the material been locked
  18371. */
  18372. readonly isFrozen: boolean;
  18373. /**
  18374. * Locks updates for the material
  18375. */
  18376. freeze(): void;
  18377. /**
  18378. * Unlocks updates for the material
  18379. */
  18380. unfreeze(): void;
  18381. /**
  18382. * Specifies if the material is ready to be used
  18383. * @param mesh defines the mesh to check
  18384. * @param useInstances specifies if instances should be used
  18385. * @returns a boolean indicating if the material is ready to be used
  18386. */
  18387. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18388. /**
  18389. * Specifies that the submesh is ready to be used
  18390. * @param mesh defines the mesh to check
  18391. * @param subMesh defines which submesh to check
  18392. * @param useInstances specifies that instances should be used
  18393. * @returns a boolean indicating that the submesh is ready or not
  18394. */
  18395. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18396. /**
  18397. * Returns the material effect
  18398. * @returns the effect associated with the material
  18399. */
  18400. getEffect(): Nullable<Effect>;
  18401. /**
  18402. * Returns the current scene
  18403. * @returns a Scene
  18404. */
  18405. getScene(): Scene;
  18406. /**
  18407. * Specifies if the material will require alpha blending
  18408. * @returns a boolean specifying if alpha blending is needed
  18409. */
  18410. needAlphaBlending(): boolean;
  18411. /**
  18412. * Specifies if the mesh will require alpha blending
  18413. * @param mesh defines the mesh to check
  18414. * @returns a boolean specifying if alpha blending is needed for the mesh
  18415. */
  18416. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  18417. /**
  18418. * Specifies if this material should be rendered in alpha test mode
  18419. * @returns a boolean specifying if an alpha test is needed.
  18420. */
  18421. needAlphaTesting(): boolean;
  18422. /**
  18423. * Gets the texture used for the alpha test
  18424. * @returns the texture to use for alpha testing
  18425. */
  18426. getAlphaTestTexture(): Nullable<BaseTexture>;
  18427. /**
  18428. * Marks the material to indicate that it needs to be re-calculated
  18429. */
  18430. markDirty(): void;
  18431. /** @hidden */
  18432. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  18433. /**
  18434. * Binds the material to the mesh
  18435. * @param world defines the world transformation matrix
  18436. * @param mesh defines the mesh to bind the material to
  18437. */
  18438. bind(world: Matrix, mesh?: Mesh): void;
  18439. /**
  18440. * Binds the submesh to the material
  18441. * @param world defines the world transformation matrix
  18442. * @param mesh defines the mesh containing the submesh
  18443. * @param subMesh defines the submesh to bind the material to
  18444. */
  18445. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18446. /**
  18447. * Binds the world matrix to the material
  18448. * @param world defines the world transformation matrix
  18449. */
  18450. bindOnlyWorldMatrix(world: Matrix): void;
  18451. /**
  18452. * Binds the scene's uniform buffer to the effect.
  18453. * @param effect defines the effect to bind to the scene uniform buffer
  18454. * @param sceneUbo defines the uniform buffer storing scene data
  18455. */
  18456. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  18457. /**
  18458. * Binds the view matrix to the effect
  18459. * @param effect defines the effect to bind the view matrix to
  18460. */
  18461. bindView(effect: Effect): void;
  18462. /**
  18463. * Binds the view projection matrix to the effect
  18464. * @param effect defines the effect to bind the view projection matrix to
  18465. */
  18466. bindViewProjection(effect: Effect): void;
  18467. /**
  18468. * Specifies if material alpha testing should be turned on for the mesh
  18469. * @param mesh defines the mesh to check
  18470. */
  18471. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  18472. /**
  18473. * Processes to execute after binding the material to a mesh
  18474. * @param mesh defines the rendered mesh
  18475. */
  18476. protected _afterBind(mesh?: Mesh): void;
  18477. /**
  18478. * Unbinds the material from the mesh
  18479. */
  18480. unbind(): void;
  18481. /**
  18482. * Gets the active textures from the material
  18483. * @returns an array of textures
  18484. */
  18485. getActiveTextures(): BaseTexture[];
  18486. /**
  18487. * Specifies if the material uses a texture
  18488. * @param texture defines the texture to check against the material
  18489. * @returns a boolean specifying if the material uses the texture
  18490. */
  18491. hasTexture(texture: BaseTexture): boolean;
  18492. /**
  18493. * Makes a duplicate of the material, and gives it a new name
  18494. * @param name defines the new name for the duplicated material
  18495. * @returns the cloned material
  18496. */
  18497. clone(name: string): Nullable<Material>;
  18498. /**
  18499. * Gets the meshes bound to the material
  18500. * @returns an array of meshes bound to the material
  18501. */
  18502. getBindedMeshes(): AbstractMesh[];
  18503. /**
  18504. * Force shader compilation
  18505. * @param mesh defines the mesh associated with this material
  18506. * @param onCompiled defines a function to execute once the material is compiled
  18507. * @param options defines the options to configure the compilation
  18508. */
  18509. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18510. clipPlane: boolean;
  18511. }>): void;
  18512. /**
  18513. * Force shader compilation
  18514. * @param mesh defines the mesh that will use this material
  18515. * @param options defines additional options for compiling the shaders
  18516. * @returns a promise that resolves when the compilation completes
  18517. */
  18518. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18519. clipPlane: boolean;
  18520. }>): Promise<void>;
  18521. private static readonly _ImageProcessingDirtyCallBack;
  18522. private static readonly _TextureDirtyCallBack;
  18523. private static readonly _FresnelDirtyCallBack;
  18524. private static readonly _MiscDirtyCallBack;
  18525. private static readonly _LightsDirtyCallBack;
  18526. private static readonly _AttributeDirtyCallBack;
  18527. private static _FresnelAndMiscDirtyCallBack;
  18528. private static _TextureAndMiscDirtyCallBack;
  18529. private static readonly _DirtyCallbackArray;
  18530. private static readonly _RunDirtyCallBacks;
  18531. /**
  18532. * Marks a define in the material to indicate that it needs to be re-computed
  18533. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18534. */
  18535. markAsDirty(flag: number): void;
  18536. /**
  18537. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18538. * @param func defines a function which checks material defines against the submeshes
  18539. */
  18540. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18541. /**
  18542. * Indicates that image processing needs to be re-calculated for all submeshes
  18543. */
  18544. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18545. /**
  18546. * Indicates that textures need to be re-calculated for all submeshes
  18547. */
  18548. protected _markAllSubMeshesAsTexturesDirty(): void;
  18549. /**
  18550. * Indicates that fresnel needs to be re-calculated for all submeshes
  18551. */
  18552. protected _markAllSubMeshesAsFresnelDirty(): void;
  18553. /**
  18554. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18555. */
  18556. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18557. /**
  18558. * Indicates that lights need to be re-calculated for all submeshes
  18559. */
  18560. protected _markAllSubMeshesAsLightsDirty(): void;
  18561. /**
  18562. * Indicates that attributes need to be re-calculated for all submeshes
  18563. */
  18564. protected _markAllSubMeshesAsAttributesDirty(): void;
  18565. /**
  18566. * Indicates that misc needs to be re-calculated for all submeshes
  18567. */
  18568. protected _markAllSubMeshesAsMiscDirty(): void;
  18569. /**
  18570. * Indicates that textures and misc need to be re-calculated for all submeshes
  18571. */
  18572. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18573. /**
  18574. * Disposes the material
  18575. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18576. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18577. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18578. */
  18579. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18580. /** @hidden */
  18581. private releaseVertexArrayObject;
  18582. /**
  18583. * Serializes this material
  18584. * @returns the serialized material object
  18585. */
  18586. serialize(): any;
  18587. /**
  18588. * Creates a MultiMaterial from parsed MultiMaterial data.
  18589. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  18590. * @param scene defines the hosting scene
  18591. * @returns a new MultiMaterial
  18592. */
  18593. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  18594. /**
  18595. * Creates a material from parsed material data
  18596. * @param parsedMaterial defines parsed material data
  18597. * @param scene defines the hosting scene
  18598. * @param rootUrl defines the root URL to use to load textures
  18599. * @returns a new material
  18600. */
  18601. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18602. }
  18603. }
  18604. declare module BABYLON {
  18605. /**
  18606. * "Static Class" containing the most commonly used helper while dealing with material for
  18607. * rendering purpose.
  18608. *
  18609. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  18610. *
  18611. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  18612. */
  18613. class MaterialHelper {
  18614. /**
  18615. * Bind the current view position to an effect.
  18616. * @param effect The effect to be bound
  18617. * @param scene The scene the eyes position is used from
  18618. */
  18619. static BindEyePosition(effect: Effect, scene: Scene): void;
  18620. /**
  18621. * Helps preparing the defines values about the UVs in used in the effect.
  18622. * UVs are shared as much as we can accross channels in the shaders.
  18623. * @param texture The texture we are preparing the UVs for
  18624. * @param defines The defines to update
  18625. * @param key The channel key "diffuse", "specular"... used in the shader
  18626. */
  18627. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  18628. /**
  18629. * Binds a texture matrix value to its corrsponding uniform
  18630. * @param texture The texture to bind the matrix for
  18631. * @param uniformBuffer The uniform buffer receivin the data
  18632. * @param key The channel key "diffuse", "specular"... used in the shader
  18633. */
  18634. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  18635. /**
  18636. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  18637. * @param mesh defines the current mesh
  18638. * @param scene defines the current scene
  18639. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  18640. * @param pointsCloud defines if point cloud rendering has to be turned on
  18641. * @param fogEnabled defines if fog has to be turned on
  18642. * @param alphaTest defines if alpha testing has to be turned on
  18643. * @param defines defines the current list of defines
  18644. */
  18645. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  18646. /**
  18647. * Helper used to prepare the list of defines associated with frame values for shader compilation
  18648. * @param scene defines the current scene
  18649. * @param engine defines the current engine
  18650. * @param defines specifies the list of active defines
  18651. * @param useInstances defines if instances have to be turned on
  18652. * @param useClipPlane defines if clip plane have to be turned on
  18653. */
  18654. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  18655. /**
  18656. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  18657. * @param mesh The mesh containing the geometry data we will draw
  18658. * @param defines The defines to update
  18659. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  18660. * @param useBones Precise whether bones should be used or not (override mesh info)
  18661. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  18662. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  18663. * @returns false if defines are considered not dirty and have not been checked
  18664. */
  18665. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  18666. /**
  18667. * Prepares the defines related to the light information passed in parameter
  18668. * @param scene The scene we are intending to draw
  18669. * @param mesh The mesh the effect is compiling for
  18670. * @param defines The defines to update
  18671. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  18672. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  18673. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  18674. * @returns true if normals will be required for the rest of the effect
  18675. */
  18676. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  18677. /**
  18678. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  18679. * that won t be acctive due to defines being turned off.
  18680. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  18681. * @param samplersList The samplers list
  18682. * @param defines The defines helping in the list generation
  18683. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  18684. */
  18685. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  18686. /**
  18687. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  18688. * @param defines The defines to update while falling back
  18689. * @param fallbacks The authorized effect fallbacks
  18690. * @param maxSimultaneousLights The maximum number of lights allowed
  18691. * @param rank the current rank of the Effect
  18692. * @returns The newly affected rank
  18693. */
  18694. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  18695. /**
  18696. * Prepares the list of attributes required for morph targets according to the effect defines.
  18697. * @param attribs The current list of supported attribs
  18698. * @param mesh The mesh to prepare the morph targets attributes for
  18699. * @param defines The current Defines of the effect
  18700. */
  18701. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  18702. /**
  18703. * Prepares the list of attributes required for bones according to the effect defines.
  18704. * @param attribs The current list of supported attribs
  18705. * @param mesh The mesh to prepare the bones attributes for
  18706. * @param defines The current Defines of the effect
  18707. * @param fallbacks The current efffect fallback strategy
  18708. */
  18709. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  18710. /**
  18711. * Prepares the list of attributes required for instances according to the effect defines.
  18712. * @param attribs The current list of supported attribs
  18713. * @param defines The current Defines of the effect
  18714. */
  18715. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  18716. /**
  18717. * Binds the light shadow information to the effect for the given mesh.
  18718. * @param light The light containing the generator
  18719. * @param scene The scene the lights belongs to
  18720. * @param mesh The mesh we are binding the information to render
  18721. * @param lightIndex The light index in the effect used to render the mesh
  18722. * @param effect The effect we are binding the data to
  18723. */
  18724. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  18725. /**
  18726. * Binds the light information to the effect.
  18727. * @param light The light containing the generator
  18728. * @param effect The effect we are binding the data to
  18729. * @param lightIndex The light index in the effect used to render
  18730. */
  18731. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  18732. /**
  18733. * Binds the lights information from the scene to the effect for the given mesh.
  18734. * @param scene The scene the lights belongs to
  18735. * @param mesh The mesh we are binding the information to render
  18736. * @param effect The effect we are binding the data to
  18737. * @param defines The generated defines for the effect
  18738. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  18739. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  18740. */
  18741. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  18742. private static _tempFogColor;
  18743. /**
  18744. * Binds the fog information from the scene to the effect for the given mesh.
  18745. * @param scene The scene the lights belongs to
  18746. * @param mesh The mesh we are binding the information to render
  18747. * @param effect The effect we are binding the data to
  18748. * @param linearSpace Defines if the fog effect is applied in linear space
  18749. */
  18750. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  18751. /**
  18752. * Binds the bones information from the mesh to the effect.
  18753. * @param mesh The mesh we are binding the information to render
  18754. * @param effect The effect we are binding the data to
  18755. */
  18756. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  18757. /**
  18758. * Binds the morph targets information from the mesh to the effect.
  18759. * @param abstractMesh The mesh we are binding the information to render
  18760. * @param effect The effect we are binding the data to
  18761. */
  18762. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  18763. /**
  18764. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  18765. * @param defines The generated defines used in the effect
  18766. * @param effect The effect we are binding the data to
  18767. * @param scene The scene we are willing to render with logarithmic scale for
  18768. */
  18769. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  18770. /**
  18771. * Binds the clip plane information from the scene to the effect.
  18772. * @param scene The scene the clip plane information are extracted from
  18773. * @param effect The effect we are binding the data to
  18774. */
  18775. static BindClipPlane(effect: Effect, scene: Scene): void;
  18776. }
  18777. }
  18778. declare module BABYLON {
  18779. /**
  18780. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18781. * separate meshes. This can be use to improve performances.
  18782. * @see http://doc.babylonjs.com/how_to/multi_materials
  18783. */
  18784. class MultiMaterial extends Material {
  18785. private _subMaterials;
  18786. /**
  18787. * Gets or Sets the list of Materials used within the multi material.
  18788. * They need to be ordered according to the submeshes order in the associated mesh
  18789. */
  18790. subMaterials: Nullable<Material>[];
  18791. /**
  18792. * Function used to align with Node.getChildren()
  18793. * @returns the list of Materials used within the multi material
  18794. */
  18795. getChildren(): Nullable<Material>[];
  18796. /**
  18797. * Instantiates a new Multi Material
  18798. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18799. * separate meshes. This can be use to improve performances.
  18800. * @see http://doc.babylonjs.com/how_to/multi_materials
  18801. * @param name Define the name in the scene
  18802. * @param scene Define the scene the material belongs to
  18803. */
  18804. constructor(name: string, scene: Scene);
  18805. private _hookArray;
  18806. /**
  18807. * Get one of the submaterial by its index in the submaterials array
  18808. * @param index The index to look the sub material at
  18809. * @returns The Material if the index has been defined
  18810. */
  18811. getSubMaterial(index: number): Nullable<Material>;
  18812. /**
  18813. * Get the list of active textures for the whole sub materials list.
  18814. * @returns All the textures that will be used during the rendering
  18815. */
  18816. getActiveTextures(): BaseTexture[];
  18817. /**
  18818. * Gets the current class name of the material e.g. "MultiMaterial"
  18819. * Mainly use in serialization.
  18820. * @returns the class name
  18821. */
  18822. getClassName(): string;
  18823. /**
  18824. * Checks if the material is ready to render the requested sub mesh
  18825. * @param mesh Define the mesh the submesh belongs to
  18826. * @param subMesh Define the sub mesh to look readyness for
  18827. * @param useInstances Define whether or not the material is used with instances
  18828. * @returns true if ready, otherwise false
  18829. */
  18830. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18831. /**
  18832. * Clones the current material and its related sub materials
  18833. * @param name Define the name of the newly cloned material
  18834. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  18835. * @returns the cloned material
  18836. */
  18837. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  18838. /**
  18839. * Serializes the materials into a JSON representation.
  18840. * @returns the JSON representation
  18841. */
  18842. serialize(): any;
  18843. /**
  18844. * Dispose the material and release its associated resources
  18845. * @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)
  18846. * @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)
  18847. */
  18848. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18849. }
  18850. }
  18851. declare module BABYLON {
  18852. /**
  18853. * Base class of materials working in push mode in babylon JS
  18854. * @hidden
  18855. */
  18856. class PushMaterial extends Material {
  18857. protected _activeEffect: Effect;
  18858. protected _normalMatrix: Matrix;
  18859. /**
  18860. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  18861. * This means that the material can keep using a previous shader while a new one is being compiled.
  18862. * This is mostly used when shader parallel compilation is supported (true by default)
  18863. */
  18864. allowShaderHotSwapping: boolean;
  18865. constructor(name: string, scene: Scene);
  18866. getEffect(): Effect;
  18867. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18868. /**
  18869. * Binds the given world matrix to the active effect
  18870. *
  18871. * @param world the matrix to bind
  18872. */
  18873. bindOnlyWorldMatrix(world: Matrix): void;
  18874. /**
  18875. * Binds the given normal matrix to the active effect
  18876. *
  18877. * @param normalMatrix the matrix to bind
  18878. */
  18879. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  18880. bind(world: Matrix, mesh?: Mesh): void;
  18881. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  18882. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  18883. }
  18884. }
  18885. declare module BABYLON {
  18886. /**
  18887. * Defines the options associated with the creation of a shader material.
  18888. */
  18889. interface IShaderMaterialOptions {
  18890. /**
  18891. * Does the material work in alpha blend mode
  18892. */
  18893. needAlphaBlending: boolean;
  18894. /**
  18895. * Does the material work in alpha test mode
  18896. */
  18897. needAlphaTesting: boolean;
  18898. /**
  18899. * The list of attribute names used in the shader
  18900. */
  18901. attributes: string[];
  18902. /**
  18903. * The list of unifrom names used in the shader
  18904. */
  18905. uniforms: string[];
  18906. /**
  18907. * The list of UBO names used in the shader
  18908. */
  18909. uniformBuffers: string[];
  18910. /**
  18911. * The list of sampler names used in the shader
  18912. */
  18913. samplers: string[];
  18914. /**
  18915. * The list of defines used in the shader
  18916. */
  18917. defines: string[];
  18918. }
  18919. /**
  18920. * 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.
  18921. *
  18922. * This returned material effects how the mesh will look based on the code in the shaders.
  18923. *
  18924. * @see http://doc.babylonjs.com/how_to/shader_material
  18925. */
  18926. class ShaderMaterial extends Material {
  18927. private _shaderPath;
  18928. private _options;
  18929. private _textures;
  18930. private _textureArrays;
  18931. private _floats;
  18932. private _ints;
  18933. private _floatsArrays;
  18934. private _colors3;
  18935. private _colors3Arrays;
  18936. private _colors4;
  18937. private _vectors2;
  18938. private _vectors3;
  18939. private _vectors4;
  18940. private _matrices;
  18941. private _matrices3x3;
  18942. private _matrices2x2;
  18943. private _vectors2Arrays;
  18944. private _vectors3Arrays;
  18945. private _cachedWorldViewMatrix;
  18946. private _renderId;
  18947. /**
  18948. * Instantiate a new shader material.
  18949. * 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.
  18950. * This returned material effects how the mesh will look based on the code in the shaders.
  18951. * @see http://doc.babylonjs.com/how_to/shader_material
  18952. * @param name Define the name of the material in the scene
  18953. * @param scene Define the scene the material belongs to
  18954. * @param shaderPath Defines the route to the shader code in one of three ways:
  18955. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  18956. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18957. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18958. * @param options Define the options used to create the shader
  18959. */
  18960. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18961. /**
  18962. * Gets the current class name of the material e.g. "ShaderMaterial"
  18963. * Mainly use in serialization.
  18964. * @returns the class name
  18965. */
  18966. getClassName(): string;
  18967. /**
  18968. * Specifies if the material will require alpha blending
  18969. * @returns a boolean specifying if alpha blending is needed
  18970. */
  18971. needAlphaBlending(): boolean;
  18972. /**
  18973. * Specifies if this material should be rendered in alpha test mode
  18974. * @returns a boolean specifying if an alpha test is needed.
  18975. */
  18976. needAlphaTesting(): boolean;
  18977. private _checkUniform;
  18978. /**
  18979. * Set a texture in the shader.
  18980. * @param name Define the name of the uniform samplers as defined in the shader
  18981. * @param texture Define the texture to bind to this sampler
  18982. * @return the material itself allowing "fluent" like uniform updates
  18983. */
  18984. setTexture(name: string, texture: Texture): ShaderMaterial;
  18985. /**
  18986. * Set a texture array in the shader.
  18987. * @param name Define the name of the uniform sampler array as defined in the shader
  18988. * @param textures Define the list of textures to bind to this sampler
  18989. * @return the material itself allowing "fluent" like uniform updates
  18990. */
  18991. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18992. /**
  18993. * Set a float in the shader.
  18994. * @param name Define the name of the uniform as defined in the shader
  18995. * @param value Define the value to give to the uniform
  18996. * @return the material itself allowing "fluent" like uniform updates
  18997. */
  18998. setFloat(name: string, value: number): ShaderMaterial;
  18999. /**
  19000. * Set a int in the shader.
  19001. * @param name Define the name of the uniform as defined in the shader
  19002. * @param value Define the value to give to the uniform
  19003. * @return the material itself allowing "fluent" like uniform updates
  19004. */
  19005. setInt(name: string, value: number): ShaderMaterial;
  19006. /**
  19007. * Set an array of floats in the shader.
  19008. * @param name Define the name of the uniform as defined in the shader
  19009. * @param value Define the value to give to the uniform
  19010. * @return the material itself allowing "fluent" like uniform updates
  19011. */
  19012. setFloats(name: string, value: number[]): ShaderMaterial;
  19013. /**
  19014. * Set a vec3 in the shader from a Color3.
  19015. * @param name Define the name of the uniform as defined in the shader
  19016. * @param value Define the value to give to the uniform
  19017. * @return the material itself allowing "fluent" like uniform updates
  19018. */
  19019. setColor3(name: string, value: Color3): ShaderMaterial;
  19020. /**
  19021. * Set a vec3 array in the shader from a Color3 array.
  19022. * @param name Define the name of the uniform as defined in the shader
  19023. * @param value Define the value to give to the uniform
  19024. * @return the material itself allowing "fluent" like uniform updates
  19025. */
  19026. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19027. /**
  19028. * Set a vec4 in the shader from a Color4.
  19029. * @param name Define the name of the uniform as defined in the shader
  19030. * @param value Define the value to give to the uniform
  19031. * @return the material itself allowing "fluent" like uniform updates
  19032. */
  19033. setColor4(name: string, value: Color4): ShaderMaterial;
  19034. /**
  19035. * Set a vec2 in the shader from a Vector2.
  19036. * @param name Define the name of the uniform as defined in the shader
  19037. * @param value Define the value to give to the uniform
  19038. * @return the material itself allowing "fluent" like uniform updates
  19039. */
  19040. setVector2(name: string, value: Vector2): ShaderMaterial;
  19041. /**
  19042. * Set a vec3 in the shader from a Vector3.
  19043. * @param name Define the name of the uniform as defined in the shader
  19044. * @param value Define the value to give to the uniform
  19045. * @return the material itself allowing "fluent" like uniform updates
  19046. */
  19047. setVector3(name: string, value: Vector3): ShaderMaterial;
  19048. /**
  19049. * Set a vec4 in the shader from a Vector4.
  19050. * @param name Define the name of the uniform as defined in the shader
  19051. * @param value Define the value to give to the uniform
  19052. * @return the material itself allowing "fluent" like uniform updates
  19053. */
  19054. setVector4(name: string, value: Vector4): ShaderMaterial;
  19055. /**
  19056. * Set a mat4 in the shader from a Matrix.
  19057. * @param name Define the name of the uniform as defined in the shader
  19058. * @param value Define the value to give to the uniform
  19059. * @return the material itself allowing "fluent" like uniform updates
  19060. */
  19061. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19062. /**
  19063. * Set a mat3 in the shader from a Float32Array.
  19064. * @param name Define the name of the uniform as defined in the shader
  19065. * @param value Define the value to give to the uniform
  19066. * @return the material itself allowing "fluent" like uniform updates
  19067. */
  19068. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19069. /**
  19070. * Set a mat2 in the shader from a Float32Array.
  19071. * @param name Define the name of the uniform as defined in the shader
  19072. * @param value Define the value to give to the uniform
  19073. * @return the material itself allowing "fluent" like uniform updates
  19074. */
  19075. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19076. /**
  19077. * Set a vec2 array in the shader from a number array.
  19078. * @param name Define the name of the uniform as defined in the shader
  19079. * @param value Define the value to give to the uniform
  19080. * @return the material itself allowing "fluent" like uniform updates
  19081. */
  19082. setArray2(name: string, value: number[]): ShaderMaterial;
  19083. /**
  19084. * Set a vec3 array in the shader from a number array.
  19085. * @param name Define the name of the uniform as defined in the shader
  19086. * @param value Define the value to give to the uniform
  19087. * @return the material itself allowing "fluent" like uniform updates
  19088. */
  19089. setArray3(name: string, value: number[]): ShaderMaterial;
  19090. private _checkCache;
  19091. /**
  19092. * Checks if the material is ready to render the requested mesh
  19093. * @param mesh Define the mesh to render
  19094. * @param useInstances Define whether or not the material is used with instances
  19095. * @returns true if ready, otherwise false
  19096. */
  19097. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19098. /**
  19099. * Binds the world matrix to the material
  19100. * @param world defines the world transformation matrix
  19101. */
  19102. bindOnlyWorldMatrix(world: Matrix): void;
  19103. /**
  19104. * Binds the material to the mesh
  19105. * @param world defines the world transformation matrix
  19106. * @param mesh defines the mesh to bind the material to
  19107. */
  19108. bind(world: Matrix, mesh?: Mesh): void;
  19109. /**
  19110. * Gets the active textures from the material
  19111. * @returns an array of textures
  19112. */
  19113. getActiveTextures(): BaseTexture[];
  19114. /**
  19115. * Specifies if the material uses a texture
  19116. * @param texture defines the texture to check against the material
  19117. * @returns a boolean specifying if the material uses the texture
  19118. */
  19119. hasTexture(texture: BaseTexture): boolean;
  19120. /**
  19121. * Makes a duplicate of the material, and gives it a new name
  19122. * @param name defines the new name for the duplicated material
  19123. * @returns the cloned material
  19124. */
  19125. clone(name: string): ShaderMaterial;
  19126. /**
  19127. * Disposes the material
  19128. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19129. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19130. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19131. */
  19132. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19133. /**
  19134. * Serializes this material in a JSON representation
  19135. * @returns the serialized material object
  19136. */
  19137. serialize(): any;
  19138. /**
  19139. * Creates a shader material from parsed shader material data
  19140. * @param source defines the JSON represnetation of the material
  19141. * @param scene defines the hosting scene
  19142. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19143. * @returns a new material
  19144. */
  19145. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19146. }
  19147. }
  19148. declare module BABYLON {
  19149. /** @hidden */
  19150. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  19151. MAINUV1: boolean;
  19152. MAINUV2: boolean;
  19153. DIFFUSE: boolean;
  19154. DIFFUSEDIRECTUV: number;
  19155. AMBIENT: boolean;
  19156. AMBIENTDIRECTUV: number;
  19157. OPACITY: boolean;
  19158. OPACITYDIRECTUV: number;
  19159. OPACITYRGB: boolean;
  19160. REFLECTION: boolean;
  19161. EMISSIVE: boolean;
  19162. EMISSIVEDIRECTUV: number;
  19163. SPECULAR: boolean;
  19164. SPECULARDIRECTUV: number;
  19165. BUMP: boolean;
  19166. BUMPDIRECTUV: number;
  19167. PARALLAX: boolean;
  19168. PARALLAXOCCLUSION: boolean;
  19169. SPECULAROVERALPHA: boolean;
  19170. CLIPPLANE: boolean;
  19171. CLIPPLANE2: boolean;
  19172. CLIPPLANE3: boolean;
  19173. CLIPPLANE4: boolean;
  19174. ALPHATEST: boolean;
  19175. DEPTHPREPASS: boolean;
  19176. ALPHAFROMDIFFUSE: boolean;
  19177. POINTSIZE: boolean;
  19178. FOG: boolean;
  19179. SPECULARTERM: boolean;
  19180. DIFFUSEFRESNEL: boolean;
  19181. OPACITYFRESNEL: boolean;
  19182. REFLECTIONFRESNEL: boolean;
  19183. REFRACTIONFRESNEL: boolean;
  19184. EMISSIVEFRESNEL: boolean;
  19185. FRESNEL: boolean;
  19186. NORMAL: boolean;
  19187. UV1: boolean;
  19188. UV2: boolean;
  19189. VERTEXCOLOR: boolean;
  19190. VERTEXALPHA: boolean;
  19191. NUM_BONE_INFLUENCERS: number;
  19192. BonesPerMesh: number;
  19193. BONETEXTURE: boolean;
  19194. INSTANCES: boolean;
  19195. GLOSSINESS: boolean;
  19196. ROUGHNESS: boolean;
  19197. EMISSIVEASILLUMINATION: boolean;
  19198. LINKEMISSIVEWITHDIFFUSE: boolean;
  19199. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19200. LIGHTMAP: boolean;
  19201. LIGHTMAPDIRECTUV: number;
  19202. OBJECTSPACE_NORMALMAP: boolean;
  19203. USELIGHTMAPASSHADOWMAP: boolean;
  19204. REFLECTIONMAP_3D: boolean;
  19205. REFLECTIONMAP_SPHERICAL: boolean;
  19206. REFLECTIONMAP_PLANAR: boolean;
  19207. REFLECTIONMAP_CUBIC: boolean;
  19208. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19209. REFLECTIONMAP_PROJECTION: boolean;
  19210. REFLECTIONMAP_SKYBOX: boolean;
  19211. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  19212. REFLECTIONMAP_EXPLICIT: boolean;
  19213. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19214. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19215. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19216. INVERTCUBICMAP: boolean;
  19217. LOGARITHMICDEPTH: boolean;
  19218. REFRACTION: boolean;
  19219. REFRACTIONMAP_3D: boolean;
  19220. REFLECTIONOVERALPHA: boolean;
  19221. TWOSIDEDLIGHTING: boolean;
  19222. SHADOWFLOAT: boolean;
  19223. MORPHTARGETS: boolean;
  19224. MORPHTARGETS_NORMAL: boolean;
  19225. MORPHTARGETS_TANGENT: boolean;
  19226. NUM_MORPH_INFLUENCERS: number;
  19227. NONUNIFORMSCALING: boolean;
  19228. PREMULTIPLYALPHA: boolean;
  19229. IMAGEPROCESSING: boolean;
  19230. VIGNETTE: boolean;
  19231. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19232. VIGNETTEBLENDMODEOPAQUE: boolean;
  19233. TONEMAPPING: boolean;
  19234. TONEMAPPING_ACES: boolean;
  19235. CONTRAST: boolean;
  19236. COLORCURVES: boolean;
  19237. COLORGRADING: boolean;
  19238. COLORGRADING3D: boolean;
  19239. SAMPLER3DGREENDEPTH: boolean;
  19240. SAMPLER3DBGRMAP: boolean;
  19241. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19242. /**
  19243. * If the reflection texture on this material is in linear color space
  19244. * @hidden
  19245. */
  19246. IS_REFLECTION_LINEAR: boolean;
  19247. /**
  19248. * If the refraction texture on this material is in linear color space
  19249. * @hidden
  19250. */
  19251. IS_REFRACTION_LINEAR: boolean;
  19252. EXPOSURE: boolean;
  19253. constructor();
  19254. setReflectionMode(modeToEnable: string): void;
  19255. }
  19256. /**
  19257. * This is the default material used in Babylon. It is the best trade off between quality
  19258. * and performances.
  19259. * @see http://doc.babylonjs.com/babylon101/materials
  19260. */
  19261. class StandardMaterial extends PushMaterial {
  19262. private _diffuseTexture;
  19263. /**
  19264. * The basic texture of the material as viewed under a light.
  19265. */
  19266. diffuseTexture: Nullable<BaseTexture>;
  19267. private _ambientTexture;
  19268. /**
  19269. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19270. */
  19271. ambientTexture: Nullable<BaseTexture>;
  19272. private _opacityTexture;
  19273. /**
  19274. * Define the transparency of the material from a texture.
  19275. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19276. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19277. */
  19278. opacityTexture: Nullable<BaseTexture>;
  19279. private _reflectionTexture;
  19280. /**
  19281. * Define the texture used to display the reflection.
  19282. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19283. */
  19284. reflectionTexture: Nullable<BaseTexture>;
  19285. private _emissiveTexture;
  19286. /**
  19287. * Define texture of the material as if self lit.
  19288. * This will be mixed in the final result even in the absence of light.
  19289. */
  19290. emissiveTexture: Nullable<BaseTexture>;
  19291. private _specularTexture;
  19292. /**
  19293. * Define how the color and intensity of the highlight given by the light in the material.
  19294. */
  19295. specularTexture: Nullable<BaseTexture>;
  19296. private _bumpTexture;
  19297. /**
  19298. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19299. * 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.
  19300. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  19301. */
  19302. bumpTexture: Nullable<BaseTexture>;
  19303. private _lightmapTexture;
  19304. /**
  19305. * Complex lighting can be computationally expensive to compute at runtime.
  19306. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19307. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  19308. */
  19309. lightmapTexture: Nullable<BaseTexture>;
  19310. private _refractionTexture;
  19311. /**
  19312. * Define the texture used to display the refraction.
  19313. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19314. */
  19315. refractionTexture: Nullable<BaseTexture>;
  19316. /**
  19317. * The color of the material lit by the environmental background lighting.
  19318. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19319. */
  19320. ambientColor: Color3;
  19321. /**
  19322. * The basic color of the material as viewed under a light.
  19323. */
  19324. diffuseColor: Color3;
  19325. /**
  19326. * Define how the color and intensity of the highlight given by the light in the material.
  19327. */
  19328. specularColor: Color3;
  19329. /**
  19330. * Define the color of the material as if self lit.
  19331. * This will be mixed in the final result even in the absence of light.
  19332. */
  19333. emissiveColor: Color3;
  19334. /**
  19335. * Defines how sharp are the highlights in the material.
  19336. * The bigger the value the sharper giving a more glossy feeling to the result.
  19337. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19338. */
  19339. specularPower: number;
  19340. private _useAlphaFromDiffuseTexture;
  19341. /**
  19342. * Does the transparency come from the diffuse texture alpha channel.
  19343. */
  19344. useAlphaFromDiffuseTexture: boolean;
  19345. private _useEmissiveAsIllumination;
  19346. /**
  19347. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19348. */
  19349. useEmissiveAsIllumination: boolean;
  19350. private _linkEmissiveWithDiffuse;
  19351. /**
  19352. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19353. * the emissive level when the final color is close to one.
  19354. */
  19355. linkEmissiveWithDiffuse: boolean;
  19356. private _useSpecularOverAlpha;
  19357. /**
  19358. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19359. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19360. */
  19361. useSpecularOverAlpha: boolean;
  19362. private _useReflectionOverAlpha;
  19363. /**
  19364. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19365. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19366. */
  19367. useReflectionOverAlpha: boolean;
  19368. private _disableLighting;
  19369. /**
  19370. * Does lights from the scene impacts this material.
  19371. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19372. */
  19373. disableLighting: boolean;
  19374. private _useObjectSpaceNormalMap;
  19375. /**
  19376. * Allows using an object space normal map (instead of tangent space).
  19377. */
  19378. useObjectSpaceNormalMap: boolean;
  19379. private _useParallax;
  19380. /**
  19381. * Is parallax enabled or not.
  19382. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19383. */
  19384. useParallax: boolean;
  19385. private _useParallaxOcclusion;
  19386. /**
  19387. * Is parallax occlusion enabled or not.
  19388. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19389. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19390. */
  19391. useParallaxOcclusion: boolean;
  19392. /**
  19393. * 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.
  19394. */
  19395. parallaxScaleBias: number;
  19396. private _roughness;
  19397. /**
  19398. * Helps to define how blurry the reflections should appears in the material.
  19399. */
  19400. roughness: number;
  19401. /**
  19402. * In case of refraction, define the value of the indice of refraction.
  19403. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19404. */
  19405. indexOfRefraction: number;
  19406. /**
  19407. * Invert the refraction texture alongside the y axis.
  19408. * It can be usefull with procedural textures or probe for instance.
  19409. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19410. */
  19411. invertRefractionY: boolean;
  19412. /**
  19413. * Defines the alpha limits in alpha test mode.
  19414. */
  19415. alphaCutOff: number;
  19416. private _useLightmapAsShadowmap;
  19417. /**
  19418. * In case of light mapping, define whether the map contains light or shadow informations.
  19419. */
  19420. useLightmapAsShadowmap: boolean;
  19421. private _diffuseFresnelParameters;
  19422. /**
  19423. * Define the diffuse fresnel parameters of the material.
  19424. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19425. */
  19426. diffuseFresnelParameters: FresnelParameters;
  19427. private _opacityFresnelParameters;
  19428. /**
  19429. * Define the opacity fresnel parameters of the material.
  19430. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19431. */
  19432. opacityFresnelParameters: FresnelParameters;
  19433. private _reflectionFresnelParameters;
  19434. /**
  19435. * Define the reflection fresnel parameters of the material.
  19436. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19437. */
  19438. reflectionFresnelParameters: FresnelParameters;
  19439. private _refractionFresnelParameters;
  19440. /**
  19441. * Define the refraction fresnel parameters of the material.
  19442. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19443. */
  19444. refractionFresnelParameters: FresnelParameters;
  19445. private _emissiveFresnelParameters;
  19446. /**
  19447. * Define the emissive fresnel parameters of the material.
  19448. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19449. */
  19450. emissiveFresnelParameters: FresnelParameters;
  19451. private _useReflectionFresnelFromSpecular;
  19452. /**
  19453. * If true automatically deducts the fresnels values from the material specularity.
  19454. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19455. */
  19456. useReflectionFresnelFromSpecular: boolean;
  19457. private _useGlossinessFromSpecularMapAlpha;
  19458. /**
  19459. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19460. */
  19461. useGlossinessFromSpecularMapAlpha: boolean;
  19462. private _maxSimultaneousLights;
  19463. /**
  19464. * Defines the maximum number of lights that can be used in the material
  19465. */
  19466. maxSimultaneousLights: number;
  19467. private _invertNormalMapX;
  19468. /**
  19469. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19470. */
  19471. invertNormalMapX: boolean;
  19472. private _invertNormalMapY;
  19473. /**
  19474. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19475. */
  19476. invertNormalMapY: boolean;
  19477. private _twoSidedLighting;
  19478. /**
  19479. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19480. */
  19481. twoSidedLighting: boolean;
  19482. /**
  19483. * Default configuration related to image processing available in the standard Material.
  19484. */
  19485. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19486. /**
  19487. * Gets the image processing configuration used either in this material.
  19488. */
  19489. /**
  19490. * Sets the Default image processing configuration used either in the this material.
  19491. *
  19492. * If sets to null, the scene one is in use.
  19493. */
  19494. imageProcessingConfiguration: ImageProcessingConfiguration;
  19495. /**
  19496. * Keep track of the image processing observer to allow dispose and replace.
  19497. */
  19498. private _imageProcessingObserver;
  19499. /**
  19500. * Attaches a new image processing configuration to the Standard Material.
  19501. * @param configuration
  19502. */
  19503. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19504. /**
  19505. * Gets wether the color curves effect is enabled.
  19506. */
  19507. /**
  19508. * Sets wether the color curves effect is enabled.
  19509. */
  19510. cameraColorCurvesEnabled: boolean;
  19511. /**
  19512. * Gets wether the color grading effect is enabled.
  19513. */
  19514. /**
  19515. * Gets wether the color grading effect is enabled.
  19516. */
  19517. cameraColorGradingEnabled: boolean;
  19518. /**
  19519. * Gets wether tonemapping is enabled or not.
  19520. */
  19521. /**
  19522. * Sets wether tonemapping is enabled or not
  19523. */
  19524. cameraToneMappingEnabled: boolean;
  19525. /**
  19526. * The camera exposure used on this material.
  19527. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19528. * This corresponds to a photographic exposure.
  19529. */
  19530. /**
  19531. * The camera exposure used on this material.
  19532. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19533. * This corresponds to a photographic exposure.
  19534. */
  19535. cameraExposure: number;
  19536. /**
  19537. * Gets The camera contrast used on this material.
  19538. */
  19539. /**
  19540. * Sets The camera contrast used on this material.
  19541. */
  19542. cameraContrast: number;
  19543. /**
  19544. * Gets the Color Grading 2D Lookup Texture.
  19545. */
  19546. /**
  19547. * Sets the Color Grading 2D Lookup Texture.
  19548. */
  19549. cameraColorGradingTexture: Nullable<BaseTexture>;
  19550. /**
  19551. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19552. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19553. * 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;
  19554. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19555. */
  19556. /**
  19557. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19558. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19559. * 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;
  19560. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19561. */
  19562. cameraColorCurves: Nullable<ColorCurves>;
  19563. /**
  19564. * Custom callback helping to override the default shader used in the material.
  19565. */
  19566. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  19567. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19568. protected _worldViewProjectionMatrix: Matrix;
  19569. protected _globalAmbientColor: Color3;
  19570. protected _useLogarithmicDepth: boolean;
  19571. /**
  19572. * Instantiates a new standard material.
  19573. * This is the default material used in Babylon. It is the best trade off between quality
  19574. * and performances.
  19575. * @see http://doc.babylonjs.com/babylon101/materials
  19576. * @param name Define the name of the material in the scene
  19577. * @param scene Define the scene the material belong to
  19578. */
  19579. constructor(name: string, scene: Scene);
  19580. /**
  19581. * Gets a boolean indicating that current material needs to register RTT
  19582. */
  19583. readonly hasRenderTargetTextures: boolean;
  19584. /**
  19585. * Gets the current class name of the material e.g. "StandardMaterial"
  19586. * Mainly use in serialization.
  19587. * @returns the class name
  19588. */
  19589. getClassName(): string;
  19590. /**
  19591. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19592. * You can try switching to logarithmic depth.
  19593. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19594. */
  19595. useLogarithmicDepth: boolean;
  19596. /**
  19597. * Specifies if the material will require alpha blending
  19598. * @returns a boolean specifying if alpha blending is needed
  19599. */
  19600. needAlphaBlending(): boolean;
  19601. /**
  19602. * Specifies if this material should be rendered in alpha test mode
  19603. * @returns a boolean specifying if an alpha test is needed.
  19604. */
  19605. needAlphaTesting(): boolean;
  19606. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19607. /**
  19608. * Get the texture used for alpha test purpose.
  19609. * @returns the diffuse texture in case of the standard material.
  19610. */
  19611. getAlphaTestTexture(): Nullable<BaseTexture>;
  19612. /**
  19613. * Get if the submesh is ready to be used and all its information available.
  19614. * Child classes can use it to update shaders
  19615. * @param mesh defines the mesh to check
  19616. * @param subMesh defines which submesh to check
  19617. * @param useInstances specifies that instances should be used
  19618. * @returns a boolean indicating that the submesh is ready or not
  19619. */
  19620. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19621. /**
  19622. * Builds the material UBO layouts.
  19623. * Used internally during the effect preparation.
  19624. */
  19625. buildUniformLayout(): void;
  19626. /**
  19627. * Unbinds the material from the mesh
  19628. */
  19629. unbind(): void;
  19630. /**
  19631. * Binds the submesh to this material by preparing the effect and shader to draw
  19632. * @param world defines the world transformation matrix
  19633. * @param mesh defines the mesh containing the submesh
  19634. * @param subMesh defines the submesh to bind the material to
  19635. */
  19636. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19637. /**
  19638. * Get the list of animatables in the material.
  19639. * @returns the list of animatables object used in the material
  19640. */
  19641. getAnimatables(): IAnimatable[];
  19642. /**
  19643. * Gets the active textures from the material
  19644. * @returns an array of textures
  19645. */
  19646. getActiveTextures(): BaseTexture[];
  19647. /**
  19648. * Specifies if the material uses a texture
  19649. * @param texture defines the texture to check against the material
  19650. * @returns a boolean specifying if the material uses the texture
  19651. */
  19652. hasTexture(texture: BaseTexture): boolean;
  19653. /**
  19654. * Disposes the material
  19655. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19656. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19657. */
  19658. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19659. /**
  19660. * Makes a duplicate of the material, and gives it a new name
  19661. * @param name defines the new name for the duplicated material
  19662. * @returns the cloned material
  19663. */
  19664. clone(name: string): StandardMaterial;
  19665. /**
  19666. * Serializes this material in a JSON representation
  19667. * @returns the serialized material object
  19668. */
  19669. serialize(): any;
  19670. /**
  19671. * Creates a standard material from parsed material data
  19672. * @param source defines the JSON represnetation of the material
  19673. * @param scene defines the hosting scene
  19674. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19675. * @returns a new material
  19676. */
  19677. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19678. private static _DiffuseTextureEnabled;
  19679. /**
  19680. * Are diffuse textures enabled in the application.
  19681. */
  19682. static DiffuseTextureEnabled: boolean;
  19683. private static _AmbientTextureEnabled;
  19684. /**
  19685. * Are ambient textures enabled in the application.
  19686. */
  19687. static AmbientTextureEnabled: boolean;
  19688. private static _OpacityTextureEnabled;
  19689. /**
  19690. * Are opacity textures enabled in the application.
  19691. */
  19692. static OpacityTextureEnabled: boolean;
  19693. private static _ReflectionTextureEnabled;
  19694. /**
  19695. * Are reflection textures enabled in the application.
  19696. */
  19697. static ReflectionTextureEnabled: boolean;
  19698. private static _EmissiveTextureEnabled;
  19699. /**
  19700. * Are emissive textures enabled in the application.
  19701. */
  19702. static EmissiveTextureEnabled: boolean;
  19703. private static _SpecularTextureEnabled;
  19704. /**
  19705. * Are specular textures enabled in the application.
  19706. */
  19707. static SpecularTextureEnabled: boolean;
  19708. private static _BumpTextureEnabled;
  19709. /**
  19710. * Are bump textures enabled in the application.
  19711. */
  19712. static BumpTextureEnabled: boolean;
  19713. private static _LightmapTextureEnabled;
  19714. /**
  19715. * Are lightmap textures enabled in the application.
  19716. */
  19717. static LightmapTextureEnabled: boolean;
  19718. private static _RefractionTextureEnabled;
  19719. /**
  19720. * Are refraction textures enabled in the application.
  19721. */
  19722. static RefractionTextureEnabled: boolean;
  19723. private static _ColorGradingTextureEnabled;
  19724. /**
  19725. * Are color grading textures enabled in the application.
  19726. */
  19727. static ColorGradingTextureEnabled: boolean;
  19728. private static _FresnelEnabled;
  19729. /**
  19730. * Are fresnels enabled in the application.
  19731. */
  19732. static FresnelEnabled: boolean;
  19733. }
  19734. }
  19735. declare module BABYLON {
  19736. /**
  19737. * Uniform buffer objects.
  19738. *
  19739. * Handles blocks of uniform on the GPU.
  19740. *
  19741. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19742. *
  19743. * For more information, please refer to :
  19744. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19745. */
  19746. class UniformBuffer {
  19747. private _engine;
  19748. private _buffer;
  19749. private _data;
  19750. private _bufferData;
  19751. private _dynamic?;
  19752. private _uniformLocations;
  19753. private _uniformSizes;
  19754. private _uniformLocationPointer;
  19755. private _needSync;
  19756. private _noUBO;
  19757. private _currentEffect;
  19758. private static _MAX_UNIFORM_SIZE;
  19759. private static _tempBuffer;
  19760. /**
  19761. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  19762. * This is dynamic to allow compat with webgl 1 and 2.
  19763. * You will need to pass the name of the uniform as well as the value.
  19764. */
  19765. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  19766. /**
  19767. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  19768. * This is dynamic to allow compat with webgl 1 and 2.
  19769. * You will need to pass the name of the uniform as well as the value.
  19770. */
  19771. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  19772. /**
  19773. * Lambda to Update a single float in a uniform buffer.
  19774. * This is dynamic to allow compat with webgl 1 and 2.
  19775. * You will need to pass the name of the uniform as well as the value.
  19776. */
  19777. updateFloat: (name: string, x: number) => void;
  19778. /**
  19779. * Lambda to Update a vec2 of float in a uniform buffer.
  19780. * This is dynamic to allow compat with webgl 1 and 2.
  19781. * You will need to pass the name of the uniform as well as the value.
  19782. */
  19783. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  19784. /**
  19785. * Lambda to Update a vec3 of float in a uniform buffer.
  19786. * This is dynamic to allow compat with webgl 1 and 2.
  19787. * You will need to pass the name of the uniform as well as the value.
  19788. */
  19789. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  19790. /**
  19791. * Lambda to Update a vec4 of float in a uniform buffer.
  19792. * This is dynamic to allow compat with webgl 1 and 2.
  19793. * You will need to pass the name of the uniform as well as the value.
  19794. */
  19795. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  19796. /**
  19797. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  19798. * This is dynamic to allow compat with webgl 1 and 2.
  19799. * You will need to pass the name of the uniform as well as the value.
  19800. */
  19801. updateMatrix: (name: string, mat: Matrix) => void;
  19802. /**
  19803. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  19804. * This is dynamic to allow compat with webgl 1 and 2.
  19805. * You will need to pass the name of the uniform as well as the value.
  19806. */
  19807. updateVector3: (name: string, vector: Vector3) => void;
  19808. /**
  19809. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  19810. * This is dynamic to allow compat with webgl 1 and 2.
  19811. * You will need to pass the name of the uniform as well as the value.
  19812. */
  19813. updateVector4: (name: string, vector: Vector4) => void;
  19814. /**
  19815. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  19816. * This is dynamic to allow compat with webgl 1 and 2.
  19817. * You will need to pass the name of the uniform as well as the value.
  19818. */
  19819. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  19820. /**
  19821. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  19822. * This is dynamic to allow compat with webgl 1 and 2.
  19823. * You will need to pass the name of the uniform as well as the value.
  19824. */
  19825. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  19826. /**
  19827. * Instantiates a new Uniform buffer objects.
  19828. *
  19829. * Handles blocks of uniform on the GPU.
  19830. *
  19831. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19832. *
  19833. * For more information, please refer to :
  19834. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19835. * @param engine Define the engine the buffer is associated with
  19836. * @param data Define the data contained in the buffer
  19837. * @param dynamic Define if the buffer is updatable
  19838. */
  19839. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  19840. /**
  19841. * Indicates if the buffer is using the WebGL2 UBO implementation,
  19842. * or just falling back on setUniformXXX calls.
  19843. */
  19844. readonly useUbo: boolean;
  19845. /**
  19846. * Indicates if the WebGL underlying uniform buffer is in sync
  19847. * with the javascript cache data.
  19848. */
  19849. readonly isSync: boolean;
  19850. /**
  19851. * Indicates if the WebGL underlying uniform buffer is dynamic.
  19852. * Also, a dynamic UniformBuffer will disable cache verification and always
  19853. * update the underlying WebGL uniform buffer to the GPU.
  19854. * @returns if Dynamic, otherwise false
  19855. */
  19856. isDynamic(): boolean;
  19857. /**
  19858. * The data cache on JS side.
  19859. * @returns the underlying data as a float array
  19860. */
  19861. getData(): Float32Array;
  19862. /**
  19863. * The underlying WebGL Uniform buffer.
  19864. * @returns the webgl buffer
  19865. */
  19866. getBuffer(): Nullable<WebGLBuffer>;
  19867. /**
  19868. * std140 layout specifies how to align data within an UBO structure.
  19869. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  19870. * for specs.
  19871. */
  19872. private _fillAlignment;
  19873. /**
  19874. * Adds an uniform in the buffer.
  19875. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  19876. * for the layout to be correct !
  19877. * @param name Name of the uniform, as used in the uniform block in the shader.
  19878. * @param size Data size, or data directly.
  19879. */
  19880. addUniform(name: string, size: number | number[]): void;
  19881. /**
  19882. * Adds a Matrix 4x4 to the uniform buffer.
  19883. * @param name Name of the uniform, as used in the uniform block in the shader.
  19884. * @param mat A 4x4 matrix.
  19885. */
  19886. addMatrix(name: string, mat: Matrix): void;
  19887. /**
  19888. * Adds a vec2 to the uniform buffer.
  19889. * @param name Name of the uniform, as used in the uniform block in the shader.
  19890. * @param x Define the x component value of the vec2
  19891. * @param y Define the y component value of the vec2
  19892. */
  19893. addFloat2(name: string, x: number, y: number): void;
  19894. /**
  19895. * Adds a vec3 to the uniform buffer.
  19896. * @param name Name of the uniform, as used in the uniform block in the shader.
  19897. * @param x Define the x component value of the vec3
  19898. * @param y Define the y component value of the vec3
  19899. * @param z Define the z component value of the vec3
  19900. */
  19901. addFloat3(name: string, x: number, y: number, z: number): void;
  19902. /**
  19903. * Adds a vec3 to the uniform buffer.
  19904. * @param name Name of the uniform, as used in the uniform block in the shader.
  19905. * @param color Define the vec3 from a Color
  19906. */
  19907. addColor3(name: string, color: Color3): void;
  19908. /**
  19909. * Adds a vec4 to the uniform buffer.
  19910. * @param name Name of the uniform, as used in the uniform block in the shader.
  19911. * @param color Define the rgb components from a Color
  19912. * @param alpha Define the a component of the vec4
  19913. */
  19914. addColor4(name: string, color: Color3, alpha: number): void;
  19915. /**
  19916. * Adds a vec3 to the uniform buffer.
  19917. * @param name Name of the uniform, as used in the uniform block in the shader.
  19918. * @param vector Define the vec3 components from a Vector
  19919. */
  19920. addVector3(name: string, vector: Vector3): void;
  19921. /**
  19922. * Adds a Matrix 3x3 to the uniform buffer.
  19923. * @param name Name of the uniform, as used in the uniform block in the shader.
  19924. */
  19925. addMatrix3x3(name: string): void;
  19926. /**
  19927. * Adds a Matrix 2x2 to the uniform buffer.
  19928. * @param name Name of the uniform, as used in the uniform block in the shader.
  19929. */
  19930. addMatrix2x2(name: string): void;
  19931. /**
  19932. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  19933. */
  19934. create(): void;
  19935. /** @hidden */
  19936. _rebuild(): void;
  19937. /**
  19938. * Updates the WebGL Uniform Buffer on the GPU.
  19939. * If the `dynamic` flag is set to true, no cache comparison is done.
  19940. * Otherwise, the buffer will be updated only if the cache differs.
  19941. */
  19942. update(): void;
  19943. /**
  19944. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  19945. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19946. * @param data Define the flattened data
  19947. * @param size Define the size of the data.
  19948. */
  19949. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  19950. private _updateMatrix3x3ForUniform;
  19951. private _updateMatrix3x3ForEffect;
  19952. private _updateMatrix2x2ForEffect;
  19953. private _updateMatrix2x2ForUniform;
  19954. private _updateFloatForEffect;
  19955. private _updateFloatForUniform;
  19956. private _updateFloat2ForEffect;
  19957. private _updateFloat2ForUniform;
  19958. private _updateFloat3ForEffect;
  19959. private _updateFloat3ForUniform;
  19960. private _updateFloat4ForEffect;
  19961. private _updateFloat4ForUniform;
  19962. private _updateMatrixForEffect;
  19963. private _updateMatrixForUniform;
  19964. private _updateVector3ForEffect;
  19965. private _updateVector3ForUniform;
  19966. private _updateVector4ForEffect;
  19967. private _updateVector4ForUniform;
  19968. private _updateColor3ForEffect;
  19969. private _updateColor3ForUniform;
  19970. private _updateColor4ForEffect;
  19971. private _updateColor4ForUniform;
  19972. /**
  19973. * Sets a sampler uniform on the effect.
  19974. * @param name Define the name of the sampler.
  19975. * @param texture Define the texture to set in the sampler
  19976. */
  19977. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  19978. /**
  19979. * Directly updates the value of the uniform in the cache AND on the GPU.
  19980. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19981. * @param data Define the flattened data
  19982. */
  19983. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  19984. /**
  19985. * Binds this uniform buffer to an effect.
  19986. * @param effect Define the effect to bind the buffer to
  19987. * @param name Name of the uniform block in the shader.
  19988. */
  19989. bindToEffect(effect: Effect, name: string): void;
  19990. /**
  19991. * Disposes the uniform buffer.
  19992. */
  19993. dispose(): void;
  19994. }
  19995. }
  19996. declare module BABYLON {
  19997. /**
  19998. * Scalar computation library
  19999. */
  20000. class Scalar {
  20001. /**
  20002. * Two pi constants convenient for computation.
  20003. */
  20004. static TwoPi: number;
  20005. /**
  20006. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  20007. * @param a number
  20008. * @param b number
  20009. * @param epsilon (default = 1.401298E-45)
  20010. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  20011. */
  20012. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  20013. /**
  20014. * Returns a string : the upper case translation of the number i to hexadecimal.
  20015. * @param i number
  20016. * @returns the upper case translation of the number i to hexadecimal.
  20017. */
  20018. static ToHex(i: number): string;
  20019. /**
  20020. * Returns -1 if value is negative and +1 is value is positive.
  20021. * @param value the value
  20022. * @returns the value itself if it's equal to zero.
  20023. */
  20024. static Sign(value: number): number;
  20025. /**
  20026. * Returns the value itself if it's between min and max.
  20027. * Returns min if the value is lower than min.
  20028. * Returns max if the value is greater than max.
  20029. * @param value the value to clmap
  20030. * @param min the min value to clamp to (default: 0)
  20031. * @param max the max value to clamp to (default: 1)
  20032. * @returns the clamped value
  20033. */
  20034. static Clamp(value: number, min?: number, max?: number): number;
  20035. /**
  20036. * the log2 of value.
  20037. * @param value the value to compute log2 of
  20038. * @returns the log2 of value.
  20039. */
  20040. static Log2(value: number): number;
  20041. /**
  20042. * Loops the value, so that it is never larger than length and never smaller than 0.
  20043. *
  20044. * This is similar to the modulo operator but it works with floating point numbers.
  20045. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  20046. * With t = 5 and length = 2.5, the result would be 0.0.
  20047. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  20048. * @param value the value
  20049. * @param length the length
  20050. * @returns the looped value
  20051. */
  20052. static Repeat(value: number, length: number): number;
  20053. /**
  20054. * Normalize the value between 0.0 and 1.0 using min and max values
  20055. * @param value value to normalize
  20056. * @param min max to normalize between
  20057. * @param max min to normalize between
  20058. * @returns the normalized value
  20059. */
  20060. static Normalize(value: number, min: number, max: number): number;
  20061. /**
  20062. * Denormalize the value from 0.0 and 1.0 using min and max values
  20063. * @param normalized value to denormalize
  20064. * @param min max to denormalize between
  20065. * @param max min to denormalize between
  20066. * @returns the denormalized value
  20067. */
  20068. static Denormalize(normalized: number, min: number, max: number): number;
  20069. /**
  20070. * Calculates the shortest difference between two given angles given in degrees.
  20071. * @param current current angle in degrees
  20072. * @param target target angle in degrees
  20073. * @returns the delta
  20074. */
  20075. static DeltaAngle(current: number, target: number): number;
  20076. /**
  20077. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  20078. * @param tx value
  20079. * @param length length
  20080. * @returns The returned value will move back and forth between 0 and length
  20081. */
  20082. static PingPong(tx: number, length: number): number;
  20083. /**
  20084. * Interpolates between min and max with smoothing at the limits.
  20085. *
  20086. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  20087. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  20088. * @param from from
  20089. * @param to to
  20090. * @param tx value
  20091. * @returns the smooth stepped value
  20092. */
  20093. static SmoothStep(from: number, to: number, tx: number): number;
  20094. /**
  20095. * Moves a value current towards target.
  20096. *
  20097. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  20098. * Negative values of maxDelta pushes the value away from target.
  20099. * @param current current value
  20100. * @param target target value
  20101. * @param maxDelta max distance to move
  20102. * @returns resulting value
  20103. */
  20104. static MoveTowards(current: number, target: number, maxDelta: number): number;
  20105. /**
  20106. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  20107. *
  20108. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  20109. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  20110. * @param current current value
  20111. * @param target target value
  20112. * @param maxDelta max distance to move
  20113. * @returns resulting angle
  20114. */
  20115. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  20116. /**
  20117. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  20118. * @param start start value
  20119. * @param end target value
  20120. * @param amount amount to lerp between
  20121. * @returns the lerped value
  20122. */
  20123. static Lerp(start: number, end: number, amount: number): number;
  20124. /**
  20125. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  20126. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  20127. * @param start start value
  20128. * @param end target value
  20129. * @param amount amount to lerp between
  20130. * @returns the lerped value
  20131. */
  20132. static LerpAngle(start: number, end: number, amount: number): number;
  20133. /**
  20134. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  20135. * @param a start value
  20136. * @param b target value
  20137. * @param value value between a and b
  20138. * @returns the inverseLerp value
  20139. */
  20140. static InverseLerp(a: number, b: number, value: number): number;
  20141. /**
  20142. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  20143. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  20144. * @param value1 spline value
  20145. * @param tangent1 spline value
  20146. * @param value2 spline value
  20147. * @param tangent2 spline value
  20148. * @param amount input value
  20149. * @returns hermite result
  20150. */
  20151. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  20152. /**
  20153. * Returns a random float number between and min and max values
  20154. * @param min min value of random
  20155. * @param max max value of random
  20156. * @returns random value
  20157. */
  20158. static RandomRange(min: number, max: number): number;
  20159. /**
  20160. * This function returns percentage of a number in a given range.
  20161. *
  20162. * RangeToPercent(40,20,60) will return 0.5 (50%)
  20163. * RangeToPercent(34,0,100) will return 0.34 (34%)
  20164. * @param number to convert to percentage
  20165. * @param min min range
  20166. * @param max max range
  20167. * @returns the percentage
  20168. */
  20169. static RangeToPercent(number: number, min: number, max: number): number;
  20170. /**
  20171. * This function returns number that corresponds to the percentage in a given range.
  20172. *
  20173. * PercentToRange(0.34,0,100) will return 34.
  20174. * @param percent to convert to number
  20175. * @param min min range
  20176. * @param max max range
  20177. * @returns the number
  20178. */
  20179. static PercentToRange(percent: number, min: number, max: number): number;
  20180. /**
  20181. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  20182. * @param angle The angle to normalize in radian.
  20183. * @return The converted angle.
  20184. */
  20185. static NormalizeRadians(angle: number): number;
  20186. }
  20187. }
  20188. declare module BABYLON {
  20189. /**
  20190. * Constant used to convert a value to gamma space
  20191. * @ignorenaming
  20192. */
  20193. const ToGammaSpace: number;
  20194. /**
  20195. * Constant used to convert a value to linear space
  20196. * @ignorenaming
  20197. */
  20198. const ToLinearSpace = 2.2;
  20199. /**
  20200. * Constant used to define the minimal number value in Babylon.js
  20201. * @ignorenaming
  20202. */
  20203. const Epsilon = 0.001;
  20204. /**
  20205. * Class used to hold a RBG color
  20206. */
  20207. class Color3 {
  20208. /**
  20209. * Defines the red component (between 0 and 1, default is 0)
  20210. */
  20211. r: number;
  20212. /**
  20213. * Defines the green component (between 0 and 1, default is 0)
  20214. */
  20215. g: number;
  20216. /**
  20217. * Defines the blue component (between 0 and 1, default is 0)
  20218. */
  20219. b: number;
  20220. /**
  20221. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  20222. * @param r defines the red component (between 0 and 1, default is 0)
  20223. * @param g defines the green component (between 0 and 1, default is 0)
  20224. * @param b defines the blue component (between 0 and 1, default is 0)
  20225. */
  20226. constructor(
  20227. /**
  20228. * Defines the red component (between 0 and 1, default is 0)
  20229. */
  20230. r?: number,
  20231. /**
  20232. * Defines the green component (between 0 and 1, default is 0)
  20233. */
  20234. g?: number,
  20235. /**
  20236. * Defines the blue component (between 0 and 1, default is 0)
  20237. */
  20238. b?: number);
  20239. /**
  20240. * Creates a string with the Color3 current values
  20241. * @returns the string representation of the Color3 object
  20242. */
  20243. toString(): string;
  20244. /**
  20245. * Returns the string "Color3"
  20246. * @returns "Color3"
  20247. */
  20248. getClassName(): string;
  20249. /**
  20250. * Compute the Color3 hash code
  20251. * @returns an unique number that can be used to hash Color3 objects
  20252. */
  20253. getHashCode(): number;
  20254. /**
  20255. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  20256. * @param array defines the array where to store the r,g,b components
  20257. * @param index defines an optional index in the target array to define where to start storing values
  20258. * @returns the current Color3 object
  20259. */
  20260. toArray(array: FloatArray, index?: number): Color3;
  20261. /**
  20262. * Returns a new Color4 object from the current Color3 and the given alpha
  20263. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  20264. * @returns a new Color4 object
  20265. */
  20266. toColor4(alpha?: number): Color4;
  20267. /**
  20268. * Returns a new array populated with 3 numeric elements : red, green and blue values
  20269. * @returns the new array
  20270. */
  20271. asArray(): number[];
  20272. /**
  20273. * Returns the luminance value
  20274. * @returns a float value
  20275. */
  20276. toLuminance(): number;
  20277. /**
  20278. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  20279. * @param otherColor defines the second operand
  20280. * @returns the new Color3 object
  20281. */
  20282. multiply(otherColor: DeepImmutable<Color3>): Color3;
  20283. /**
  20284. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  20285. * @param otherColor defines the second operand
  20286. * @param result defines the Color3 object where to store the result
  20287. * @returns the current Color3
  20288. */
  20289. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20290. /**
  20291. * Determines equality between Color3 objects
  20292. * @param otherColor defines the second operand
  20293. * @returns true if the rgb values are equal to the given ones
  20294. */
  20295. equals(otherColor: DeepImmutable<Color3>): boolean;
  20296. /**
  20297. * Determines equality between the current Color3 object and a set of r,b,g values
  20298. * @param r defines the red component to check
  20299. * @param g defines the green component to check
  20300. * @param b defines the blue component to check
  20301. * @returns true if the rgb values are equal to the given ones
  20302. */
  20303. equalsFloats(r: number, g: number, b: number): boolean;
  20304. /**
  20305. * Multiplies in place each rgb value by scale
  20306. * @param scale defines the scaling factor
  20307. * @returns the updated Color3
  20308. */
  20309. scale(scale: number): Color3;
  20310. /**
  20311. * Multiplies the rgb values by scale and stores the result into "result"
  20312. * @param scale defines the scaling factor
  20313. * @param result defines the Color3 object where to store the result
  20314. * @returns the unmodified current Color3
  20315. */
  20316. scaleToRef(scale: number, result: Color3): Color3;
  20317. /**
  20318. * Scale the current Color3 values by a factor and add the result to a given Color3
  20319. * @param scale defines the scale factor
  20320. * @param result defines color to store the result into
  20321. * @returns the unmodified current Color3
  20322. */
  20323. scaleAndAddToRef(scale: number, result: Color3): Color3;
  20324. /**
  20325. * Clamps the rgb values by the min and max values and stores the result into "result"
  20326. * @param min defines minimum clamping value (default is 0)
  20327. * @param max defines maximum clamping value (default is 1)
  20328. * @param result defines color to store the result into
  20329. * @returns the original Color3
  20330. */
  20331. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  20332. /**
  20333. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  20334. * @param otherColor defines the second operand
  20335. * @returns the new Color3
  20336. */
  20337. add(otherColor: DeepImmutable<Color3>): Color3;
  20338. /**
  20339. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  20340. * @param otherColor defines the second operand
  20341. * @param result defines Color3 object to store the result into
  20342. * @returns the unmodified current Color3
  20343. */
  20344. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20345. /**
  20346. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  20347. * @param otherColor defines the second operand
  20348. * @returns the new Color3
  20349. */
  20350. subtract(otherColor: DeepImmutable<Color3>): Color3;
  20351. /**
  20352. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  20353. * @param otherColor defines the second operand
  20354. * @param result defines Color3 object to store the result into
  20355. * @returns the unmodified current Color3
  20356. */
  20357. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20358. /**
  20359. * Copy the current object
  20360. * @returns a new Color3 copied the current one
  20361. */
  20362. clone(): Color3;
  20363. /**
  20364. * Copies the rgb values from the source in the current Color3
  20365. * @param source defines the source Color3 object
  20366. * @returns the updated Color3 object
  20367. */
  20368. copyFrom(source: DeepImmutable<Color3>): Color3;
  20369. /**
  20370. * Updates the Color3 rgb values from the given floats
  20371. * @param r defines the red component to read from
  20372. * @param g defines the green component to read from
  20373. * @param b defines the blue component to read from
  20374. * @returns the current Color3 object
  20375. */
  20376. copyFromFloats(r: number, g: number, b: number): Color3;
  20377. /**
  20378. * Updates the Color3 rgb values from the given floats
  20379. * @param r defines the red component to read from
  20380. * @param g defines the green component to read from
  20381. * @param b defines the blue component to read from
  20382. * @returns the current Color3 object
  20383. */
  20384. set(r: number, g: number, b: number): Color3;
  20385. /**
  20386. * Compute the Color3 hexadecimal code as a string
  20387. * @returns a string containing the hexadecimal representation of the Color3 object
  20388. */
  20389. toHexString(): string;
  20390. /**
  20391. * Computes a new Color3 converted from the current one to linear space
  20392. * @returns a new Color3 object
  20393. */
  20394. toLinearSpace(): Color3;
  20395. /**
  20396. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  20397. * @param convertedColor defines the Color3 object where to store the linear space version
  20398. * @returns the unmodified Color3
  20399. */
  20400. toLinearSpaceToRef(convertedColor: Color3): Color3;
  20401. /**
  20402. * Computes a new Color3 converted from the current one to gamma space
  20403. * @returns a new Color3 object
  20404. */
  20405. toGammaSpace(): Color3;
  20406. /**
  20407. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  20408. * @param convertedColor defines the Color3 object where to store the gamma space version
  20409. * @returns the unmodified Color3
  20410. */
  20411. toGammaSpaceToRef(convertedColor: Color3): Color3;
  20412. /**
  20413. * Creates a new Color3 from the string containing valid hexadecimal values
  20414. * @param hex defines a string containing valid hexadecimal values
  20415. * @returns a new Color3 object
  20416. */
  20417. static FromHexString(hex: string): Color3;
  20418. /**
  20419. * Creates a new Vector3 from the starting index of the given array
  20420. * @param array defines the source array
  20421. * @param offset defines an offset in the source array
  20422. * @returns a new Color3 object
  20423. */
  20424. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  20425. /**
  20426. * Creates a new Color3 from integer values (< 256)
  20427. * @param r defines the red component to read from (value between 0 and 255)
  20428. * @param g defines the green component to read from (value between 0 and 255)
  20429. * @param b defines the blue component to read from (value between 0 and 255)
  20430. * @returns a new Color3 object
  20431. */
  20432. static FromInts(r: number, g: number, b: number): Color3;
  20433. /**
  20434. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20435. * @param start defines the start Color3 value
  20436. * @param end defines the end Color3 value
  20437. * @param amount defines the gradient value between start and end
  20438. * @returns a new Color3 object
  20439. */
  20440. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  20441. /**
  20442. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20443. * @param left defines the start value
  20444. * @param right defines the end value
  20445. * @param amount defines the gradient factor
  20446. * @param result defines the Color3 object where to store the result
  20447. */
  20448. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  20449. /**
  20450. * Returns a Color3 value containing a red color
  20451. * @returns a new Color3 object
  20452. */
  20453. static Red(): Color3;
  20454. /**
  20455. * Returns a Color3 value containing a green color
  20456. * @returns a new Color3 object
  20457. */
  20458. static Green(): Color3;
  20459. /**
  20460. * Returns a Color3 value containing a blue color
  20461. * @returns a new Color3 object
  20462. */
  20463. static Blue(): Color3;
  20464. /**
  20465. * Returns a Color3 value containing a black color
  20466. * @returns a new Color3 object
  20467. */
  20468. static Black(): Color3;
  20469. /**
  20470. * Returns a Color3 value containing a white color
  20471. * @returns a new Color3 object
  20472. */
  20473. static White(): Color3;
  20474. /**
  20475. * Returns a Color3 value containing a purple color
  20476. * @returns a new Color3 object
  20477. */
  20478. static Purple(): Color3;
  20479. /**
  20480. * Returns a Color3 value containing a magenta color
  20481. * @returns a new Color3 object
  20482. */
  20483. static Magenta(): Color3;
  20484. /**
  20485. * Returns a Color3 value containing a yellow color
  20486. * @returns a new Color3 object
  20487. */
  20488. static Yellow(): Color3;
  20489. /**
  20490. * Returns a Color3 value containing a gray color
  20491. * @returns a new Color3 object
  20492. */
  20493. static Gray(): Color3;
  20494. /**
  20495. * Returns a Color3 value containing a teal color
  20496. * @returns a new Color3 object
  20497. */
  20498. static Teal(): Color3;
  20499. /**
  20500. * Returns a Color3 value containing a random color
  20501. * @returns a new Color3 object
  20502. */
  20503. static Random(): Color3;
  20504. }
  20505. /**
  20506. * Class used to hold a RBGA color
  20507. */
  20508. class Color4 {
  20509. /**
  20510. * Defines the red component (between 0 and 1, default is 0)
  20511. */
  20512. r: number;
  20513. /**
  20514. * Defines the green component (between 0 and 1, default is 0)
  20515. */
  20516. g: number;
  20517. /**
  20518. * Defines the blue component (between 0 and 1, default is 0)
  20519. */
  20520. b: number;
  20521. /**
  20522. * Defines the alpha component (between 0 and 1, default is 1)
  20523. */
  20524. a: number;
  20525. /**
  20526. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  20527. * @param r defines the red component (between 0 and 1, default is 0)
  20528. * @param g defines the green component (between 0 and 1, default is 0)
  20529. * @param b defines the blue component (between 0 and 1, default is 0)
  20530. * @param a defines the alpha component (between 0 and 1, default is 1)
  20531. */
  20532. constructor(
  20533. /**
  20534. * Defines the red component (between 0 and 1, default is 0)
  20535. */
  20536. r?: number,
  20537. /**
  20538. * Defines the green component (between 0 and 1, default is 0)
  20539. */
  20540. g?: number,
  20541. /**
  20542. * Defines the blue component (between 0 and 1, default is 0)
  20543. */
  20544. b?: number,
  20545. /**
  20546. * Defines the alpha component (between 0 and 1, default is 1)
  20547. */
  20548. a?: number);
  20549. /**
  20550. * Adds in place the given Color4 values to the current Color4 object
  20551. * @param right defines the second operand
  20552. * @returns the current updated Color4 object
  20553. */
  20554. addInPlace(right: DeepImmutable<Color4>): Color4;
  20555. /**
  20556. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  20557. * @returns the new array
  20558. */
  20559. asArray(): number[];
  20560. /**
  20561. * Stores from the starting index in the given array the Color4 successive values
  20562. * @param array defines the array where to store the r,g,b components
  20563. * @param index defines an optional index in the target array to define where to start storing values
  20564. * @returns the current Color4 object
  20565. */
  20566. toArray(array: number[], index?: number): Color4;
  20567. /**
  20568. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  20569. * @param right defines the second operand
  20570. * @returns a new Color4 object
  20571. */
  20572. add(right: DeepImmutable<Color4>): Color4;
  20573. /**
  20574. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  20575. * @param right defines the second operand
  20576. * @returns a new Color4 object
  20577. */
  20578. subtract(right: DeepImmutable<Color4>): Color4;
  20579. /**
  20580. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  20581. * @param right defines the second operand
  20582. * @param result defines the Color4 object where to store the result
  20583. * @returns the current Color4 object
  20584. */
  20585. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  20586. /**
  20587. * Creates a new Color4 with the current Color4 values multiplied by scale
  20588. * @param scale defines the scaling factor to apply
  20589. * @returns a new Color4 object
  20590. */
  20591. scale(scale: number): Color4;
  20592. /**
  20593. * Multiplies the current Color4 values by scale and stores the result in "result"
  20594. * @param scale defines the scaling factor to apply
  20595. * @param result defines the Color4 object where to store the result
  20596. * @returns the current unmodified Color4
  20597. */
  20598. scaleToRef(scale: number, result: Color4): Color4;
  20599. /**
  20600. * Scale the current Color4 values by a factor and add the result to a given Color4
  20601. * @param scale defines the scale factor
  20602. * @param result defines the Color4 object where to store the result
  20603. * @returns the unmodified current Color4
  20604. */
  20605. scaleAndAddToRef(scale: number, result: Color4): Color4;
  20606. /**
  20607. * Clamps the rgb values by the min and max values and stores the result into "result"
  20608. * @param min defines minimum clamping value (default is 0)
  20609. * @param max defines maximum clamping value (default is 1)
  20610. * @param result defines color to store the result into.
  20611. * @returns the cuurent Color4
  20612. */
  20613. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  20614. /**
  20615. * Multipy an Color4 value by another and return a new Color4 object
  20616. * @param color defines the Color4 value to multiply by
  20617. * @returns a new Color4 object
  20618. */
  20619. multiply(color: Color4): Color4;
  20620. /**
  20621. * Multipy a Color4 value by another and push the result in a reference value
  20622. * @param color defines the Color4 value to multiply by
  20623. * @param result defines the Color4 to fill the result in
  20624. * @returns the result Color4
  20625. */
  20626. multiplyToRef(color: Color4, result: Color4): Color4;
  20627. /**
  20628. * Creates a string with the Color4 current values
  20629. * @returns the string representation of the Color4 object
  20630. */
  20631. toString(): string;
  20632. /**
  20633. * Returns the string "Color4"
  20634. * @returns "Color4"
  20635. */
  20636. getClassName(): string;
  20637. /**
  20638. * Compute the Color4 hash code
  20639. * @returns an unique number that can be used to hash Color4 objects
  20640. */
  20641. getHashCode(): number;
  20642. /**
  20643. * Creates a new Color4 copied from the current one
  20644. * @returns a new Color4 object
  20645. */
  20646. clone(): Color4;
  20647. /**
  20648. * Copies the given Color4 values into the current one
  20649. * @param source defines the source Color4 object
  20650. * @returns the current updated Color4 object
  20651. */
  20652. copyFrom(source: Color4): Color4;
  20653. /**
  20654. * Copies the given float values into the current one
  20655. * @param r defines the red component to read from
  20656. * @param g defines the green component to read from
  20657. * @param b defines the blue component to read from
  20658. * @param a defines the alpha component to read from
  20659. * @returns the current updated Color4 object
  20660. */
  20661. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  20662. /**
  20663. * Copies the given float values into the current one
  20664. * @param r defines the red component to read from
  20665. * @param g defines the green component to read from
  20666. * @param b defines the blue component to read from
  20667. * @param a defines the alpha component to read from
  20668. * @returns the current updated Color4 object
  20669. */
  20670. set(r: number, g: number, b: number, a: number): Color4;
  20671. /**
  20672. * Compute the Color4 hexadecimal code as a string
  20673. * @returns a string containing the hexadecimal representation of the Color4 object
  20674. */
  20675. toHexString(): string;
  20676. /**
  20677. * Computes a new Color4 converted from the current one to linear space
  20678. * @returns a new Color4 object
  20679. */
  20680. toLinearSpace(): Color4;
  20681. /**
  20682. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  20683. * @param convertedColor defines the Color4 object where to store the linear space version
  20684. * @returns the unmodified Color4
  20685. */
  20686. toLinearSpaceToRef(convertedColor: Color4): Color4;
  20687. /**
  20688. * Computes a new Color4 converted from the current one to gamma space
  20689. * @returns a new Color4 object
  20690. */
  20691. toGammaSpace(): Color4;
  20692. /**
  20693. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  20694. * @param convertedColor defines the Color4 object where to store the gamma space version
  20695. * @returns the unmodified Color4
  20696. */
  20697. toGammaSpaceToRef(convertedColor: Color4): Color4;
  20698. /**
  20699. * Creates a new Color4 from the string containing valid hexadecimal values
  20700. * @param hex defines a string containing valid hexadecimal values
  20701. * @returns a new Color4 object
  20702. */
  20703. static FromHexString(hex: string): Color4;
  20704. /**
  20705. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20706. * @param left defines the start value
  20707. * @param right defines the end value
  20708. * @param amount defines the gradient factor
  20709. * @returns a new Color4 object
  20710. */
  20711. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  20712. /**
  20713. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20714. * @param left defines the start value
  20715. * @param right defines the end value
  20716. * @param amount defines the gradient factor
  20717. * @param result defines the Color4 object where to store data
  20718. */
  20719. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  20720. /**
  20721. * Creates a new Color4 from a Color3 and an alpha value
  20722. * @param color3 defines the source Color3 to read from
  20723. * @param alpha defines the alpha component (1.0 by default)
  20724. * @returns a new Color4 object
  20725. */
  20726. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  20727. /**
  20728. * Creates a new Color4 from the starting index element of the given array
  20729. * @param array defines the source array to read from
  20730. * @param offset defines the offset in the source array
  20731. * @returns a new Color4 object
  20732. */
  20733. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  20734. /**
  20735. * Creates a new Color3 from integer values (< 256)
  20736. * @param r defines the red component to read from (value between 0 and 255)
  20737. * @param g defines the green component to read from (value between 0 and 255)
  20738. * @param b defines the blue component to read from (value between 0 and 255)
  20739. * @param a defines the alpha component to read from (value between 0 and 255)
  20740. * @returns a new Color3 object
  20741. */
  20742. static FromInts(r: number, g: number, b: number, a: number): Color4;
  20743. /**
  20744. * Check the content of a given array and convert it to an array containing RGBA data
  20745. * If the original array was already containing count * 4 values then it is returned directly
  20746. * @param colors defines the array to check
  20747. * @param count defines the number of RGBA data to expect
  20748. * @returns an array containing count * 4 values (RGBA)
  20749. */
  20750. static CheckColors4(colors: number[], count: number): number[];
  20751. }
  20752. /**
  20753. * Class representing a vector containing 2 coordinates
  20754. */
  20755. class Vector2 {
  20756. /** defines the first coordinate */
  20757. x: number;
  20758. /** defines the second coordinate */
  20759. y: number;
  20760. /**
  20761. * Creates a new Vector2 from the given x and y coordinates
  20762. * @param x defines the first coordinate
  20763. * @param y defines the second coordinate
  20764. */
  20765. constructor(
  20766. /** defines the first coordinate */
  20767. x?: number,
  20768. /** defines the second coordinate */
  20769. y?: number);
  20770. /**
  20771. * Gets a string with the Vector2 coordinates
  20772. * @returns a string with the Vector2 coordinates
  20773. */
  20774. toString(): string;
  20775. /**
  20776. * Gets class name
  20777. * @returns the string "Vector2"
  20778. */
  20779. getClassName(): string;
  20780. /**
  20781. * Gets current vector hash code
  20782. * @returns the Vector2 hash code as a number
  20783. */
  20784. getHashCode(): number;
  20785. /**
  20786. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  20787. * @param array defines the source array
  20788. * @param index defines the offset in source array
  20789. * @returns the current Vector2
  20790. */
  20791. toArray(array: FloatArray, index?: number): Vector2;
  20792. /**
  20793. * Copy the current vector to an array
  20794. * @returns a new array with 2 elements: the Vector2 coordinates.
  20795. */
  20796. asArray(): number[];
  20797. /**
  20798. * Sets the Vector2 coordinates with the given Vector2 coordinates
  20799. * @param source defines the source Vector2
  20800. * @returns the current updated Vector2
  20801. */
  20802. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  20803. /**
  20804. * Sets the Vector2 coordinates with the given floats
  20805. * @param x defines the first coordinate
  20806. * @param y defines the second coordinate
  20807. * @returns the current updated Vector2
  20808. */
  20809. copyFromFloats(x: number, y: number): Vector2;
  20810. /**
  20811. * Sets the Vector2 coordinates with the given floats
  20812. * @param x defines the first coordinate
  20813. * @param y defines the second coordinate
  20814. * @returns the current updated Vector2
  20815. */
  20816. set(x: number, y: number): Vector2;
  20817. /**
  20818. * Add another vector with the current one
  20819. * @param otherVector defines the other vector
  20820. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  20821. */
  20822. add(otherVector: DeepImmutable<Vector2>): Vector2;
  20823. /**
  20824. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  20825. * @param otherVector defines the other vector
  20826. * @param result defines the target vector
  20827. * @returns the unmodified current Vector2
  20828. */
  20829. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20830. /**
  20831. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  20832. * @param otherVector defines the other vector
  20833. * @returns the current updated Vector2
  20834. */
  20835. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20836. /**
  20837. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  20838. * @param otherVector defines the other vector
  20839. * @returns a new Vector2
  20840. */
  20841. addVector3(otherVector: Vector3): Vector2;
  20842. /**
  20843. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  20844. * @param otherVector defines the other vector
  20845. * @returns a new Vector2
  20846. */
  20847. subtract(otherVector: Vector2): Vector2;
  20848. /**
  20849. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  20850. * @param otherVector defines the other vector
  20851. * @param result defines the target vector
  20852. * @returns the unmodified current Vector2
  20853. */
  20854. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20855. /**
  20856. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  20857. * @param otherVector defines the other vector
  20858. * @returns the current updated Vector2
  20859. */
  20860. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20861. /**
  20862. * Multiplies in place the current Vector2 coordinates by the given ones
  20863. * @param otherVector defines the other vector
  20864. * @returns the current updated Vector2
  20865. */
  20866. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20867. /**
  20868. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  20869. * @param otherVector defines the other vector
  20870. * @returns a new Vector2
  20871. */
  20872. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  20873. /**
  20874. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  20875. * @param otherVector defines the other vector
  20876. * @param result defines the target vector
  20877. * @returns the unmodified current Vector2
  20878. */
  20879. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20880. /**
  20881. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  20882. * @param x defines the first coordinate
  20883. * @param y defines the second coordinate
  20884. * @returns a new Vector2
  20885. */
  20886. multiplyByFloats(x: number, y: number): Vector2;
  20887. /**
  20888. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  20889. * @param otherVector defines the other vector
  20890. * @returns a new Vector2
  20891. */
  20892. divide(otherVector: Vector2): Vector2;
  20893. /**
  20894. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  20895. * @param otherVector defines the other vector
  20896. * @param result defines the target vector
  20897. * @returns the unmodified current Vector2
  20898. */
  20899. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20900. /**
  20901. * Divides the current Vector2 coordinates by the given ones
  20902. * @param otherVector defines the other vector
  20903. * @returns the current updated Vector2
  20904. */
  20905. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20906. /**
  20907. * Gets a new Vector2 with current Vector2 negated coordinates
  20908. * @returns a new Vector2
  20909. */
  20910. negate(): Vector2;
  20911. /**
  20912. * Multiply the Vector2 coordinates by scale
  20913. * @param scale defines the scaling factor
  20914. * @returns the current updated Vector2
  20915. */
  20916. scaleInPlace(scale: number): Vector2;
  20917. /**
  20918. * Returns a new Vector2 scaled by "scale" from the current Vector2
  20919. * @param scale defines the scaling factor
  20920. * @returns a new Vector2
  20921. */
  20922. scale(scale: number): Vector2;
  20923. /**
  20924. * Scale the current Vector2 values by a factor to a given Vector2
  20925. * @param scale defines the scale factor
  20926. * @param result defines the Vector2 object where to store the result
  20927. * @returns the unmodified current Vector2
  20928. */
  20929. scaleToRef(scale: number, result: Vector2): Vector2;
  20930. /**
  20931. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  20932. * @param scale defines the scale factor
  20933. * @param result defines the Vector2 object where to store the result
  20934. * @returns the unmodified current Vector2
  20935. */
  20936. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  20937. /**
  20938. * Gets a boolean if two vectors are equals
  20939. * @param otherVector defines the other vector
  20940. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  20941. */
  20942. equals(otherVector: DeepImmutable<Vector2>): boolean;
  20943. /**
  20944. * Gets a boolean if two vectors are equals (using an epsilon value)
  20945. * @param otherVector defines the other vector
  20946. * @param epsilon defines the minimal distance to consider equality
  20947. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  20948. */
  20949. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  20950. /**
  20951. * Gets a new Vector2 from current Vector2 floored values
  20952. * @returns a new Vector2
  20953. */
  20954. floor(): Vector2;
  20955. /**
  20956. * Gets a new Vector2 from current Vector2 floored values
  20957. * @returns a new Vector2
  20958. */
  20959. fract(): Vector2;
  20960. /**
  20961. * Gets the length of the vector
  20962. * @returns the vector length (float)
  20963. */
  20964. length(): number;
  20965. /**
  20966. * Gets the vector squared length
  20967. * @returns the vector squared length (float)
  20968. */
  20969. lengthSquared(): number;
  20970. /**
  20971. * Normalize the vector
  20972. * @returns the current updated Vector2
  20973. */
  20974. normalize(): Vector2;
  20975. /**
  20976. * Gets a new Vector2 copied from the Vector2
  20977. * @returns a new Vector2
  20978. */
  20979. clone(): Vector2;
  20980. /**
  20981. * Gets a new Vector2(0, 0)
  20982. * @returns a new Vector2
  20983. */
  20984. static Zero(): Vector2;
  20985. /**
  20986. * Gets a new Vector2(1, 1)
  20987. * @returns a new Vector2
  20988. */
  20989. static One(): Vector2;
  20990. /**
  20991. * Gets a new Vector2 set from the given index element of the given array
  20992. * @param array defines the data source
  20993. * @param offset defines the offset in the data source
  20994. * @returns a new Vector2
  20995. */
  20996. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  20997. /**
  20998. * Sets "result" from the given index element of the given array
  20999. * @param array defines the data source
  21000. * @param offset defines the offset in the data source
  21001. * @param result defines the target vector
  21002. */
  21003. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  21004. /**
  21005. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  21006. * @param value1 defines 1st point of control
  21007. * @param value2 defines 2nd point of control
  21008. * @param value3 defines 3rd point of control
  21009. * @param value4 defines 4th point of control
  21010. * @param amount defines the interpolation factor
  21011. * @returns a new Vector2
  21012. */
  21013. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  21014. /**
  21015. * 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".
  21016. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  21017. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  21018. * @param value defines the value to clamp
  21019. * @param min defines the lower limit
  21020. * @param max defines the upper limit
  21021. * @returns a new Vector2
  21022. */
  21023. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  21024. /**
  21025. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  21026. * @param value1 defines the 1st control point
  21027. * @param tangent1 defines the outgoing tangent
  21028. * @param value2 defines the 2nd control point
  21029. * @param tangent2 defines the incoming tangent
  21030. * @param amount defines the interpolation factor
  21031. * @returns a new Vector2
  21032. */
  21033. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  21034. /**
  21035. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  21036. * @param start defines the start vector
  21037. * @param end defines the end vector
  21038. * @param amount defines the interpolation factor
  21039. * @returns a new Vector2
  21040. */
  21041. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  21042. /**
  21043. * Gets the dot product of the vector "left" and the vector "right"
  21044. * @param left defines first vector
  21045. * @param right defines second vector
  21046. * @returns the dot product (float)
  21047. */
  21048. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  21049. /**
  21050. * Returns a new Vector2 equal to the normalized given vector
  21051. * @param vector defines the vector to normalize
  21052. * @returns a new Vector2
  21053. */
  21054. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  21055. /**
  21056. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  21057. * @param left defines 1st vector
  21058. * @param right defines 2nd vector
  21059. * @returns a new Vector2
  21060. */
  21061. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  21062. /**
  21063. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  21064. * @param left defines 1st vector
  21065. * @param right defines 2nd vector
  21066. * @returns a new Vector2
  21067. */
  21068. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  21069. /**
  21070. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  21071. * @param vector defines the vector to transform
  21072. * @param transformation defines the matrix to apply
  21073. * @returns a new Vector2
  21074. */
  21075. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  21076. /**
  21077. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  21078. * @param vector defines the vector to transform
  21079. * @param transformation defines the matrix to apply
  21080. * @param result defines the target vector
  21081. */
  21082. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  21083. /**
  21084. * Determines if a given vector is included in a triangle
  21085. * @param p defines the vector to test
  21086. * @param p0 defines 1st triangle point
  21087. * @param p1 defines 2nd triangle point
  21088. * @param p2 defines 3rd triangle point
  21089. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  21090. */
  21091. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  21092. /**
  21093. * Gets the distance between the vectors "value1" and "value2"
  21094. * @param value1 defines first vector
  21095. * @param value2 defines second vector
  21096. * @returns the distance between vectors
  21097. */
  21098. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  21099. /**
  21100. * Returns the squared distance between the vectors "value1" and "value2"
  21101. * @param value1 defines first vector
  21102. * @param value2 defines second vector
  21103. * @returns the squared distance between vectors
  21104. */
  21105. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  21106. /**
  21107. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  21108. * @param value1 defines first vector
  21109. * @param value2 defines second vector
  21110. * @returns a new Vector2
  21111. */
  21112. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  21113. /**
  21114. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  21115. * @param p defines the middle point
  21116. * @param segA defines one point of the segment
  21117. * @param segB defines the other point of the segment
  21118. * @returns the shortest distance
  21119. */
  21120. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  21121. }
  21122. /**
  21123. * Classed used to store (x,y,z) vector representation
  21124. * A Vector3 is the main object used in 3D geometry
  21125. * It can represent etiher the coordinates of a point the space, either a direction
  21126. * Reminder: Babylon.js uses a left handed forward facing system
  21127. */
  21128. class Vector3 {
  21129. /**
  21130. * Defines the first coordinates (on X axis)
  21131. */
  21132. x: number;
  21133. /**
  21134. * Defines the second coordinates (on Y axis)
  21135. */
  21136. y: number;
  21137. /**
  21138. * Defines the third coordinates (on Z axis)
  21139. */
  21140. z: number;
  21141. /**
  21142. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  21143. * @param x defines the first coordinates (on X axis)
  21144. * @param y defines the second coordinates (on Y axis)
  21145. * @param z defines the third coordinates (on Z axis)
  21146. */
  21147. constructor(
  21148. /**
  21149. * Defines the first coordinates (on X axis)
  21150. */
  21151. x?: number,
  21152. /**
  21153. * Defines the second coordinates (on Y axis)
  21154. */
  21155. y?: number,
  21156. /**
  21157. * Defines the third coordinates (on Z axis)
  21158. */
  21159. z?: number);
  21160. /**
  21161. * Creates a string representation of the Vector3
  21162. * @returns a string with the Vector3 coordinates.
  21163. */
  21164. toString(): string;
  21165. /**
  21166. * Gets the class name
  21167. * @returns the string "Vector3"
  21168. */
  21169. getClassName(): string;
  21170. /**
  21171. * Creates the Vector3 hash code
  21172. * @returns a number which tends to be unique between Vector3 instances
  21173. */
  21174. getHashCode(): number;
  21175. /**
  21176. * Creates an array containing three elements : the coordinates of the Vector3
  21177. * @returns a new array of numbers
  21178. */
  21179. asArray(): number[];
  21180. /**
  21181. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  21182. * @param array defines the destination array
  21183. * @param index defines the offset in the destination array
  21184. * @returns the current Vector3
  21185. */
  21186. toArray(array: FloatArray, index?: number): Vector3;
  21187. /**
  21188. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  21189. * @returns a new Quaternion object, computed from the Vector3 coordinates
  21190. */
  21191. toQuaternion(): Quaternion;
  21192. /**
  21193. * Adds the given vector to the current Vector3
  21194. * @param otherVector defines the second operand
  21195. * @returns the current updated Vector3
  21196. */
  21197. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21198. /**
  21199. * Adds the given coordinates to the current Vector3
  21200. * @param x defines the x coordinate of the operand
  21201. * @param y defines the y coordinate of the operand
  21202. * @param z defines the z coordinate of the operand
  21203. * @returns the current updated Vector3
  21204. */
  21205. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21206. /**
  21207. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  21208. * @param otherVector defines the second operand
  21209. * @returns the resulting Vector3
  21210. */
  21211. add(otherVector: DeepImmutable<Vector3>): Vector3;
  21212. /**
  21213. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  21214. * @param otherVector defines the second operand
  21215. * @param result defines the Vector3 object where to store the result
  21216. * @returns the current Vector3
  21217. */
  21218. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21219. /**
  21220. * Subtract the given vector from the current Vector3
  21221. * @param otherVector defines the second operand
  21222. * @returns the current updated Vector3
  21223. */
  21224. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21225. /**
  21226. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  21227. * @param otherVector defines the second operand
  21228. * @returns the resulting Vector3
  21229. */
  21230. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  21231. /**
  21232. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  21233. * @param otherVector defines the second operand
  21234. * @param result defines the Vector3 object where to store the result
  21235. * @returns the current Vector3
  21236. */
  21237. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21238. /**
  21239. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  21240. * @param x defines the x coordinate of the operand
  21241. * @param y defines the y coordinate of the operand
  21242. * @param z defines the z coordinate of the operand
  21243. * @returns the resulting Vector3
  21244. */
  21245. subtractFromFloats(x: number, y: number, z: number): Vector3;
  21246. /**
  21247. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  21248. * @param x defines the x coordinate of the operand
  21249. * @param y defines the y coordinate of the operand
  21250. * @param z defines the z coordinate of the operand
  21251. * @param result defines the Vector3 object where to store the result
  21252. * @returns the current Vector3
  21253. */
  21254. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  21255. /**
  21256. * Gets a new Vector3 set with the current Vector3 negated coordinates
  21257. * @returns a new Vector3
  21258. */
  21259. negate(): Vector3;
  21260. /**
  21261. * Multiplies the Vector3 coordinates by the float "scale"
  21262. * @param scale defines the multiplier factor
  21263. * @returns the current updated Vector3
  21264. */
  21265. scaleInPlace(scale: number): Vector3;
  21266. /**
  21267. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  21268. * @param scale defines the multiplier factor
  21269. * @returns a new Vector3
  21270. */
  21271. scale(scale: number): Vector3;
  21272. /**
  21273. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  21274. * @param scale defines the multiplier factor
  21275. * @param result defines the Vector3 object where to store the result
  21276. * @returns the current Vector3
  21277. */
  21278. scaleToRef(scale: number, result: Vector3): Vector3;
  21279. /**
  21280. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  21281. * @param scale defines the scale factor
  21282. * @param result defines the Vector3 object where to store the result
  21283. * @returns the unmodified current Vector3
  21284. */
  21285. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  21286. /**
  21287. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  21288. * @param otherVector defines the second operand
  21289. * @returns true if both vectors are equals
  21290. */
  21291. equals(otherVector: DeepImmutable<Vector3>): boolean;
  21292. /**
  21293. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  21294. * @param otherVector defines the second operand
  21295. * @param epsilon defines the minimal distance to define values as equals
  21296. * @returns true if both vectors are distant less than epsilon
  21297. */
  21298. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  21299. /**
  21300. * Returns true if the current Vector3 coordinates equals the given floats
  21301. * @param x defines the x coordinate of the operand
  21302. * @param y defines the y coordinate of the operand
  21303. * @param z defines the z coordinate of the operand
  21304. * @returns true if both vectors are equals
  21305. */
  21306. equalsToFloats(x: number, y: number, z: number): boolean;
  21307. /**
  21308. * Multiplies the current Vector3 coordinates by the given ones
  21309. * @param otherVector defines the second operand
  21310. * @returns the current updated Vector3
  21311. */
  21312. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21313. /**
  21314. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  21315. * @param otherVector defines the second operand
  21316. * @returns the new Vector3
  21317. */
  21318. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  21319. /**
  21320. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  21321. * @param otherVector defines the second operand
  21322. * @param result defines the Vector3 object where to store the result
  21323. * @returns the current Vector3
  21324. */
  21325. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21326. /**
  21327. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  21328. * @param x defines the x coordinate of the operand
  21329. * @param y defines the y coordinate of the operand
  21330. * @param z defines the z coordinate of the operand
  21331. * @returns the new Vector3
  21332. */
  21333. multiplyByFloats(x: number, y: number, z: number): Vector3;
  21334. /**
  21335. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  21336. * @param otherVector defines the second operand
  21337. * @returns the new Vector3
  21338. */
  21339. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  21340. /**
  21341. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  21342. * @param otherVector defines the second operand
  21343. * @param result defines the Vector3 object where to store the result
  21344. * @returns the current Vector3
  21345. */
  21346. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21347. /**
  21348. * Divides the current Vector3 coordinates by the given ones.
  21349. * @param otherVector defines the second operand
  21350. * @returns the current updated Vector3
  21351. */
  21352. divideInPlace(otherVector: Vector3): Vector3;
  21353. /**
  21354. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  21355. * @param other defines the second operand
  21356. * @returns the current updated Vector3
  21357. */
  21358. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21359. /**
  21360. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  21361. * @param other defines the second operand
  21362. * @returns the current updated Vector3
  21363. */
  21364. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21365. /**
  21366. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  21367. * @param x defines the x coordinate of the operand
  21368. * @param y defines the y coordinate of the operand
  21369. * @param z defines the z coordinate of the operand
  21370. * @returns the current updated Vector3
  21371. */
  21372. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21373. /**
  21374. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  21375. * @param x defines the x coordinate of the operand
  21376. * @param y defines the y coordinate of the operand
  21377. * @param z defines the z coordinate of the operand
  21378. * @returns the current updated Vector3
  21379. */
  21380. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21381. /**
  21382. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  21383. */
  21384. readonly isNonUniform: boolean;
  21385. /**
  21386. * Gets a new Vector3 from current Vector3 floored values
  21387. * @returns a new Vector3
  21388. */
  21389. floor(): Vector3;
  21390. /**
  21391. * Gets a new Vector3 from current Vector3 floored values
  21392. * @returns a new Vector3
  21393. */
  21394. fract(): Vector3;
  21395. /**
  21396. * Gets the length of the Vector3
  21397. * @returns the length of the Vecto3
  21398. */
  21399. length(): number;
  21400. /**
  21401. * Gets the squared length of the Vector3
  21402. * @returns squared length of the Vector3
  21403. */
  21404. lengthSquared(): number;
  21405. /**
  21406. * Normalize the current Vector3.
  21407. * Please note that this is an in place operation.
  21408. * @returns the current updated Vector3
  21409. */
  21410. normalize(): Vector3;
  21411. /**
  21412. * Reorders the x y z properties of the vector in place
  21413. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  21414. * @returns the current updated vector
  21415. */
  21416. reorderInPlace(order: string): this;
  21417. /**
  21418. * Rotates the vector around 0,0,0 by a quaternion
  21419. * @param quaternion the rotation quaternion
  21420. * @param result vector to store the result
  21421. * @returns the resulting vector
  21422. */
  21423. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  21424. /**
  21425. * Rotates a vector around a given point
  21426. * @param quaternion the rotation quaternion
  21427. * @param point the point to rotate around
  21428. * @param result vector to store the result
  21429. * @returns the resulting vector
  21430. */
  21431. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  21432. /**
  21433. * Normalize the current Vector3 with the given input length.
  21434. * Please note that this is an in place operation.
  21435. * @param len the length of the vector
  21436. * @returns the current updated Vector3
  21437. */
  21438. normalizeFromLength(len: number): Vector3;
  21439. /**
  21440. * Normalize the current Vector3 to a new vector
  21441. * @returns the new Vector3
  21442. */
  21443. normalizeToNew(): Vector3;
  21444. /**
  21445. * Normalize the current Vector3 to the reference
  21446. * @param reference define the Vector3 to update
  21447. * @returns the updated Vector3
  21448. */
  21449. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  21450. /**
  21451. * Creates a new Vector3 copied from the current Vector3
  21452. * @returns the new Vector3
  21453. */
  21454. clone(): Vector3;
  21455. /**
  21456. * Copies the given vector coordinates to the current Vector3 ones
  21457. * @param source defines the source Vector3
  21458. * @returns the current updated Vector3
  21459. */
  21460. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  21461. /**
  21462. * Copies the given floats to the current Vector3 coordinates
  21463. * @param x defines the x coordinate of the operand
  21464. * @param y defines the y coordinate of the operand
  21465. * @param z defines the z coordinate of the operand
  21466. * @returns the current updated Vector3
  21467. */
  21468. copyFromFloats(x: number, y: number, z: number): Vector3;
  21469. /**
  21470. * Copies the given floats to the current Vector3 coordinates
  21471. * @param x defines the x coordinate of the operand
  21472. * @param y defines the y coordinate of the operand
  21473. * @param z defines the z coordinate of the operand
  21474. * @returns the current updated Vector3
  21475. */
  21476. set(x: number, y: number, z: number): Vector3;
  21477. /**
  21478. * Copies the given float to the current Vector3 coordinates
  21479. * @param v defines the x, y and z coordinates of the operand
  21480. * @returns the current updated Vector3
  21481. */
  21482. setAll(v: number): Vector3;
  21483. /**
  21484. * Get the clip factor between two vectors
  21485. * @param vector0 defines the first operand
  21486. * @param vector1 defines the second operand
  21487. * @param axis defines the axis to use
  21488. * @param size defines the size along the axis
  21489. * @returns the clip factor
  21490. */
  21491. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  21492. /**
  21493. * Get angle between two vectors
  21494. * @param vector0 angle between vector0 and vector1
  21495. * @param vector1 angle between vector0 and vector1
  21496. * @param normal direction of the normal
  21497. * @return the angle between vector0 and vector1
  21498. */
  21499. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  21500. /**
  21501. * Returns a new Vector3 set from the index "offset" of the given array
  21502. * @param array defines the source array
  21503. * @param offset defines the offset in the source array
  21504. * @returns the new Vector3
  21505. */
  21506. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  21507. /**
  21508. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  21509. * This function is deprecated. Use FromArray instead
  21510. * @param array defines the source array
  21511. * @param offset defines the offset in the source array
  21512. * @returns the new Vector3
  21513. */
  21514. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  21515. /**
  21516. * Sets the given vector "result" with the element values from the index "offset" of the given array
  21517. * @param array defines the source array
  21518. * @param offset defines the offset in the source array
  21519. * @param result defines the Vector3 where to store the result
  21520. */
  21521. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  21522. /**
  21523. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  21524. * This function is deprecated. Use FromArrayToRef instead.
  21525. * @param array defines the source array
  21526. * @param offset defines the offset in the source array
  21527. * @param result defines the Vector3 where to store the result
  21528. */
  21529. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  21530. /**
  21531. * Sets the given vector "result" with the given floats.
  21532. * @param x defines the x coordinate of the source
  21533. * @param y defines the y coordinate of the source
  21534. * @param z defines the z coordinate of the source
  21535. * @param result defines the Vector3 where to store the result
  21536. */
  21537. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  21538. /**
  21539. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  21540. * @returns a new empty Vector3
  21541. */
  21542. static Zero(): Vector3;
  21543. /**
  21544. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  21545. * @returns a new unit Vector3
  21546. */
  21547. static One(): Vector3;
  21548. /**
  21549. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  21550. * @returns a new up Vector3
  21551. */
  21552. static Up(): Vector3;
  21553. /**
  21554. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  21555. * @returns a new down Vector3
  21556. */
  21557. static Down(): Vector3;
  21558. /**
  21559. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  21560. * @returns a new forward Vector3
  21561. */
  21562. static Forward(): Vector3;
  21563. /**
  21564. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  21565. * @returns a new forward Vector3
  21566. */
  21567. static Backward(): Vector3;
  21568. /**
  21569. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  21570. * @returns a new right Vector3
  21571. */
  21572. static Right(): Vector3;
  21573. /**
  21574. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  21575. * @returns a new left Vector3
  21576. */
  21577. static Left(): Vector3;
  21578. /**
  21579. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  21580. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21581. * @param vector defines the Vector3 to transform
  21582. * @param transformation defines the transformation matrix
  21583. * @returns the transformed Vector3
  21584. */
  21585. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21586. /**
  21587. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  21588. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21589. * @param vector defines the Vector3 to transform
  21590. * @param transformation defines the transformation matrix
  21591. * @param result defines the Vector3 where to store the result
  21592. */
  21593. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21594. /**
  21595. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  21596. * This method computes tranformed coordinates only, not transformed direction vectors
  21597. * @param x define the x coordinate of the source vector
  21598. * @param y define the y coordinate of the source vector
  21599. * @param z define the z coordinate of the source vector
  21600. * @param transformation defines the transformation matrix
  21601. * @param result defines the Vector3 where to store the result
  21602. */
  21603. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21604. /**
  21605. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  21606. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21607. * @param vector defines the Vector3 to transform
  21608. * @param transformation defines the transformation matrix
  21609. * @returns the new Vector3
  21610. */
  21611. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21612. /**
  21613. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  21614. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21615. * @param vector defines the Vector3 to transform
  21616. * @param transformation defines the transformation matrix
  21617. * @param result defines the Vector3 where to store the result
  21618. */
  21619. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21620. /**
  21621. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  21622. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21623. * @param x define the x coordinate of the source vector
  21624. * @param y define the y coordinate of the source vector
  21625. * @param z define the z coordinate of the source vector
  21626. * @param transformation defines the transformation matrix
  21627. * @param result defines the Vector3 where to store the result
  21628. */
  21629. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21630. /**
  21631. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  21632. * @param value1 defines the first control point
  21633. * @param value2 defines the second control point
  21634. * @param value3 defines the third control point
  21635. * @param value4 defines the fourth control point
  21636. * @param amount defines the amount on the spline to use
  21637. * @returns the new Vector3
  21638. */
  21639. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  21640. /**
  21641. * 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"
  21642. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21643. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21644. * @param value defines the current value
  21645. * @param min defines the lower range value
  21646. * @param max defines the upper range value
  21647. * @returns the new Vector3
  21648. */
  21649. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  21650. /**
  21651. * 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"
  21652. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21653. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21654. * @param value defines the current value
  21655. * @param min defines the lower range value
  21656. * @param max defines the upper range value
  21657. * @param result defines the Vector3 where to store the result
  21658. */
  21659. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  21660. /**
  21661. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  21662. * @param value1 defines the first control point
  21663. * @param tangent1 defines the first tangent vector
  21664. * @param value2 defines the second control point
  21665. * @param tangent2 defines the second tangent vector
  21666. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  21667. * @returns the new Vector3
  21668. */
  21669. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  21670. /**
  21671. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  21672. * @param start defines the start value
  21673. * @param end defines the end value
  21674. * @param amount max defines amount between both (between 0 and 1)
  21675. * @returns the new Vector3
  21676. */
  21677. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  21678. /**
  21679. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  21680. * @param start defines the start value
  21681. * @param end defines the end value
  21682. * @param amount max defines amount between both (between 0 and 1)
  21683. * @param result defines the Vector3 where to store the result
  21684. */
  21685. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  21686. /**
  21687. * Returns the dot product (float) between the vectors "left" and "right"
  21688. * @param left defines the left operand
  21689. * @param right defines the right operand
  21690. * @returns the dot product
  21691. */
  21692. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  21693. /**
  21694. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  21695. * The cross product is then orthogonal to both "left" and "right"
  21696. * @param left defines the left operand
  21697. * @param right defines the right operand
  21698. * @returns the cross product
  21699. */
  21700. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21701. /**
  21702. * Sets the given vector "result" with the cross product of "left" and "right"
  21703. * The cross product is then orthogonal to both "left" and "right"
  21704. * @param left defines the left operand
  21705. * @param right defines the right operand
  21706. * @param result defines the Vector3 where to store the result
  21707. */
  21708. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  21709. /**
  21710. * Returns a new Vector3 as the normalization of the given vector
  21711. * @param vector defines the Vector3 to normalize
  21712. * @returns the new Vector3
  21713. */
  21714. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  21715. /**
  21716. * Sets the given vector "result" with the normalization of the given first vector
  21717. * @param vector defines the Vector3 to normalize
  21718. * @param result defines the Vector3 where to store the result
  21719. */
  21720. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  21721. /**
  21722. * Project a Vector3 onto screen space
  21723. * @param vector defines the Vector3 to project
  21724. * @param world defines the world matrix to use
  21725. * @param transform defines the transform (view x projection) matrix to use
  21726. * @param viewport defines the screen viewport to use
  21727. * @returns the new Vector3
  21728. */
  21729. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  21730. /** @hidden */
  21731. private static UnprojectFromInvertedMatrixToRef;
  21732. /**
  21733. * Unproject from screen space to object space
  21734. * @param source defines the screen space Vector3 to use
  21735. * @param viewportWidth defines the current width of the viewport
  21736. * @param viewportHeight defines the current height of the viewport
  21737. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21738. * @param transform defines the transform (view x projection) matrix to use
  21739. * @returns the new Vector3
  21740. */
  21741. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  21742. /**
  21743. * Unproject from screen space to object space
  21744. * @param source defines the screen space Vector3 to use
  21745. * @param viewportWidth defines the current width of the viewport
  21746. * @param viewportHeight defines the current height of the viewport
  21747. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21748. * @param view defines the view matrix to use
  21749. * @param projection defines the projection matrix to use
  21750. * @returns the new Vector3
  21751. */
  21752. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  21753. /**
  21754. * Unproject from screen space to object space
  21755. * @param source defines the screen space Vector3 to use
  21756. * @param viewportWidth defines the current width of the viewport
  21757. * @param viewportHeight defines the current height of the viewport
  21758. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21759. * @param view defines the view matrix to use
  21760. * @param projection defines the projection matrix to use
  21761. * @param result defines the Vector3 where to store the result
  21762. */
  21763. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21764. /**
  21765. * Unproject from screen space to object space
  21766. * @param sourceX defines the screen space x coordinate to use
  21767. * @param sourceY defines the screen space y coordinate to use
  21768. * @param sourceZ defines the screen space z coordinate to use
  21769. * @param viewportWidth defines the current width of the viewport
  21770. * @param viewportHeight defines the current height of the viewport
  21771. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21772. * @param view defines the view matrix to use
  21773. * @param projection defines the projection matrix to use
  21774. * @param result defines the Vector3 where to store the result
  21775. */
  21776. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21777. /**
  21778. * Unproject a ray from screen space to object space
  21779. * @param sourceX defines the screen space x coordinate to use
  21780. * @param sourceY defines the screen space y coordinate to use
  21781. * @param viewportWidth defines the current width of the viewport
  21782. * @param viewportHeight defines the current height of the viewport
  21783. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21784. * @param view defines the view matrix to use
  21785. * @param projection defines the projection matrix to use
  21786. * @param ray defines the Ray where to store the result
  21787. */
  21788. static UnprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, ray: Ray): void;
  21789. /**
  21790. * Gets the minimal coordinate values between two Vector3
  21791. * @param left defines the first operand
  21792. * @param right defines the second operand
  21793. * @returns the new Vector3
  21794. */
  21795. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21796. /**
  21797. * Gets the maximal coordinate values between two Vector3
  21798. * @param left defines the first operand
  21799. * @param right defines the second operand
  21800. * @returns the new Vector3
  21801. */
  21802. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21803. /**
  21804. * Returns the distance between the vectors "value1" and "value2"
  21805. * @param value1 defines the first operand
  21806. * @param value2 defines the second operand
  21807. * @returns the distance
  21808. */
  21809. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21810. /**
  21811. * Returns the squared distance between the vectors "value1" and "value2"
  21812. * @param value1 defines the first operand
  21813. * @param value2 defines the second operand
  21814. * @returns the squared distance
  21815. */
  21816. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21817. /**
  21818. * Returns a new Vector3 located at the center between "value1" and "value2"
  21819. * @param value1 defines the first operand
  21820. * @param value2 defines the second operand
  21821. * @returns the new Vector3
  21822. */
  21823. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  21824. /**
  21825. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  21826. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  21827. * to something in order to rotate it from its local system to the given target system
  21828. * Note: axis1, axis2 and axis3 are normalized during this operation
  21829. * @param axis1 defines the first axis
  21830. * @param axis2 defines the second axis
  21831. * @param axis3 defines the third axis
  21832. * @returns a new Vector3
  21833. */
  21834. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  21835. /**
  21836. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  21837. * @param axis1 defines the first axis
  21838. * @param axis2 defines the second axis
  21839. * @param axis3 defines the third axis
  21840. * @param ref defines the Vector3 where to store the result
  21841. */
  21842. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  21843. }
  21844. /**
  21845. * Vector4 class created for EulerAngle class conversion to Quaternion
  21846. */
  21847. class Vector4 {
  21848. /** x value of the vector */
  21849. x: number;
  21850. /** y value of the vector */
  21851. y: number;
  21852. /** z value of the vector */
  21853. z: number;
  21854. /** w value of the vector */
  21855. w: number;
  21856. /**
  21857. * Creates a Vector4 object from the given floats.
  21858. * @param x x value of the vector
  21859. * @param y y value of the vector
  21860. * @param z z value of the vector
  21861. * @param w w value of the vector
  21862. */
  21863. constructor(
  21864. /** x value of the vector */
  21865. x: number,
  21866. /** y value of the vector */
  21867. y: number,
  21868. /** z value of the vector */
  21869. z: number,
  21870. /** w value of the vector */
  21871. w: number);
  21872. /**
  21873. * Returns the string with the Vector4 coordinates.
  21874. * @returns a string containing all the vector values
  21875. */
  21876. toString(): string;
  21877. /**
  21878. * Returns the string "Vector4".
  21879. * @returns "Vector4"
  21880. */
  21881. getClassName(): string;
  21882. /**
  21883. * Returns the Vector4 hash code.
  21884. * @returns a unique hash code
  21885. */
  21886. getHashCode(): number;
  21887. /**
  21888. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  21889. * @returns the resulting array
  21890. */
  21891. asArray(): number[];
  21892. /**
  21893. * Populates the given array from the given index with the Vector4 coordinates.
  21894. * @param array array to populate
  21895. * @param index index of the array to start at (default: 0)
  21896. * @returns the Vector4.
  21897. */
  21898. toArray(array: FloatArray, index?: number): Vector4;
  21899. /**
  21900. * Adds the given vector to the current Vector4.
  21901. * @param otherVector the vector to add
  21902. * @returns the updated Vector4.
  21903. */
  21904. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  21905. /**
  21906. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  21907. * @param otherVector the vector to add
  21908. * @returns the resulting vector
  21909. */
  21910. add(otherVector: DeepImmutable<Vector4>): Vector4;
  21911. /**
  21912. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  21913. * @param otherVector the vector to add
  21914. * @param result the vector to store the result
  21915. * @returns the current Vector4.
  21916. */
  21917. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  21918. /**
  21919. * Subtract in place the given vector from the current Vector4.
  21920. * @param otherVector the vector to subtract
  21921. * @returns the updated Vector4.
  21922. */
  21923. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  21924. /**
  21925. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  21926. * @param otherVector the vector to add
  21927. * @returns the new vector with the result
  21928. */
  21929. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  21930. /**
  21931. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  21932. * @param otherVector the vector to subtract
  21933. * @param result the vector to store the result
  21934. * @returns the current Vector4.
  21935. */
  21936. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  21937. /**
  21938. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21939. */
  21940. /**
  21941. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21942. * @param x value to subtract
  21943. * @param y value to subtract
  21944. * @param z value to subtract
  21945. * @param w value to subtract
  21946. * @returns new vector containing the result
  21947. */
  21948. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21949. /**
  21950. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21951. * @param x value to subtract
  21952. * @param y value to subtract
  21953. * @param z value to subtract
  21954. * @param w value to subtract
  21955. * @param result the vector to store the result in
  21956. * @returns the current Vector4.
  21957. */
  21958. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  21959. /**
  21960. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  21961. * @returns a new vector with the negated values
  21962. */
  21963. negate(): Vector4;
  21964. /**
  21965. * Multiplies the current Vector4 coordinates by scale (float).
  21966. * @param scale the number to scale with
  21967. * @returns the updated Vector4.
  21968. */
  21969. scaleInPlace(scale: number): Vector4;
  21970. /**
  21971. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  21972. * @param scale the number to scale with
  21973. * @returns a new vector with the result
  21974. */
  21975. scale(scale: number): Vector4;
  21976. /**
  21977. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  21978. * @param scale the number to scale with
  21979. * @param result a vector to store the result in
  21980. * @returns the current Vector4.
  21981. */
  21982. scaleToRef(scale: number, result: Vector4): Vector4;
  21983. /**
  21984. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  21985. * @param scale defines the scale factor
  21986. * @param result defines the Vector4 object where to store the result
  21987. * @returns the unmodified current Vector4
  21988. */
  21989. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  21990. /**
  21991. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  21992. * @param otherVector the vector to compare against
  21993. * @returns true if they are equal
  21994. */
  21995. equals(otherVector: DeepImmutable<Vector4>): boolean;
  21996. /**
  21997. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  21998. * @param otherVector vector to compare against
  21999. * @param epsilon (Default: very small number)
  22000. * @returns true if they are equal
  22001. */
  22002. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  22003. /**
  22004. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  22005. * @param x x value to compare against
  22006. * @param y y value to compare against
  22007. * @param z z value to compare against
  22008. * @param w w value to compare against
  22009. * @returns true if equal
  22010. */
  22011. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  22012. /**
  22013. * Multiplies in place the current Vector4 by the given one.
  22014. * @param otherVector vector to multiple with
  22015. * @returns the updated Vector4.
  22016. */
  22017. multiplyInPlace(otherVector: Vector4): Vector4;
  22018. /**
  22019. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  22020. * @param otherVector vector to multiple with
  22021. * @returns resulting new vector
  22022. */
  22023. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  22024. /**
  22025. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  22026. * @param otherVector vector to multiple with
  22027. * @param result vector to store the result
  22028. * @returns the current Vector4.
  22029. */
  22030. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22031. /**
  22032. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  22033. * @param x x value multiply with
  22034. * @param y y value multiply with
  22035. * @param z z value multiply with
  22036. * @param w w value multiply with
  22037. * @returns resulting new vector
  22038. */
  22039. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  22040. /**
  22041. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  22042. * @param otherVector vector to devide with
  22043. * @returns resulting new vector
  22044. */
  22045. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  22046. /**
  22047. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  22048. * @param otherVector vector to devide with
  22049. * @param result vector to store the result
  22050. * @returns the current Vector4.
  22051. */
  22052. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22053. /**
  22054. * Divides the current Vector3 coordinates by the given ones.
  22055. * @param otherVector vector to devide with
  22056. * @returns the updated Vector3.
  22057. */
  22058. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22059. /**
  22060. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  22061. * @param other defines the second operand
  22062. * @returns the current updated Vector4
  22063. */
  22064. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  22065. /**
  22066. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  22067. * @param other defines the second operand
  22068. * @returns the current updated Vector4
  22069. */
  22070. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  22071. /**
  22072. * Gets a new Vector4 from current Vector4 floored values
  22073. * @returns a new Vector4
  22074. */
  22075. floor(): Vector4;
  22076. /**
  22077. * Gets a new Vector4 from current Vector3 floored values
  22078. * @returns a new Vector4
  22079. */
  22080. fract(): Vector4;
  22081. /**
  22082. * Returns the Vector4 length (float).
  22083. * @returns the length
  22084. */
  22085. length(): number;
  22086. /**
  22087. * Returns the Vector4 squared length (float).
  22088. * @returns the length squared
  22089. */
  22090. lengthSquared(): number;
  22091. /**
  22092. * Normalizes in place the Vector4.
  22093. * @returns the updated Vector4.
  22094. */
  22095. normalize(): Vector4;
  22096. /**
  22097. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  22098. * @returns this converted to a new vector3
  22099. */
  22100. toVector3(): Vector3;
  22101. /**
  22102. * Returns a new Vector4 copied from the current one.
  22103. * @returns the new cloned vector
  22104. */
  22105. clone(): Vector4;
  22106. /**
  22107. * Updates the current Vector4 with the given one coordinates.
  22108. * @param source the source vector to copy from
  22109. * @returns the updated Vector4.
  22110. */
  22111. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  22112. /**
  22113. * Updates the current Vector4 coordinates with the given floats.
  22114. * @param x float to copy from
  22115. * @param y float to copy from
  22116. * @param z float to copy from
  22117. * @param w float to copy from
  22118. * @returns the updated Vector4.
  22119. */
  22120. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  22121. /**
  22122. * Updates the current Vector4 coordinates with the given floats.
  22123. * @param x float to set from
  22124. * @param y float to set from
  22125. * @param z float to set from
  22126. * @param w float to set from
  22127. * @returns the updated Vector4.
  22128. */
  22129. set(x: number, y: number, z: number, w: number): Vector4;
  22130. /**
  22131. * Copies the given float to the current Vector3 coordinates
  22132. * @param v defines the x, y, z and w coordinates of the operand
  22133. * @returns the current updated Vector3
  22134. */
  22135. setAll(v: number): Vector4;
  22136. /**
  22137. * Returns a new Vector4 set from the starting index of the given array.
  22138. * @param array the array to pull values from
  22139. * @param offset the offset into the array to start at
  22140. * @returns the new vector
  22141. */
  22142. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  22143. /**
  22144. * Updates the given vector "result" from the starting index of the given array.
  22145. * @param array the array to pull values from
  22146. * @param offset the offset into the array to start at
  22147. * @param result the vector to store the result in
  22148. */
  22149. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  22150. /**
  22151. * Updates the given vector "result" from the starting index of the given Float32Array.
  22152. * @param array the array to pull values from
  22153. * @param offset the offset into the array to start at
  22154. * @param result the vector to store the result in
  22155. */
  22156. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  22157. /**
  22158. * Updates the given vector "result" coordinates from the given floats.
  22159. * @param x float to set from
  22160. * @param y float to set from
  22161. * @param z float to set from
  22162. * @param w float to set from
  22163. * @param result the vector to the floats in
  22164. */
  22165. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  22166. /**
  22167. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  22168. * @returns the new vector
  22169. */
  22170. static Zero(): Vector4;
  22171. /**
  22172. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  22173. * @returns the new vector
  22174. */
  22175. static One(): Vector4;
  22176. /**
  22177. * Returns a new normalized Vector4 from the given one.
  22178. * @param vector the vector to normalize
  22179. * @returns the vector
  22180. */
  22181. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  22182. /**
  22183. * Updates the given vector "result" from the normalization of the given one.
  22184. * @param vector the vector to normalize
  22185. * @param result the vector to store the result in
  22186. */
  22187. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  22188. /**
  22189. * Returns a vector with the minimum values from the left and right vectors
  22190. * @param left left vector to minimize
  22191. * @param right right vector to minimize
  22192. * @returns a new vector with the minimum of the left and right vector values
  22193. */
  22194. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  22195. /**
  22196. * Returns a vector with the maximum values from the left and right vectors
  22197. * @param left left vector to maximize
  22198. * @param right right vector to maximize
  22199. * @returns a new vector with the maximum of the left and right vector values
  22200. */
  22201. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  22202. /**
  22203. * Returns the distance (float) between the vectors "value1" and "value2".
  22204. * @param value1 value to calulate the distance between
  22205. * @param value2 value to calulate the distance between
  22206. * @return the distance between the two vectors
  22207. */
  22208. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  22209. /**
  22210. * Returns the squared distance (float) between the vectors "value1" and "value2".
  22211. * @param value1 value to calulate the distance between
  22212. * @param value2 value to calulate the distance between
  22213. * @return the distance between the two vectors squared
  22214. */
  22215. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  22216. /**
  22217. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  22218. * @param value1 value to calulate the center between
  22219. * @param value2 value to calulate the center between
  22220. * @return the center between the two vectors
  22221. */
  22222. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  22223. /**
  22224. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  22225. * This methods computes transformed normalized direction vectors only.
  22226. * @param vector the vector to transform
  22227. * @param transformation the transformation matrix to apply
  22228. * @returns the new vector
  22229. */
  22230. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  22231. /**
  22232. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  22233. * This methods computes transformed normalized direction vectors only.
  22234. * @param vector the vector to transform
  22235. * @param transformation the transformation matrix to apply
  22236. * @param result the vector to store the result in
  22237. */
  22238. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22239. /**
  22240. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  22241. * This methods computes transformed normalized direction vectors only.
  22242. * @param x value to transform
  22243. * @param y value to transform
  22244. * @param z value to transform
  22245. * @param w value to transform
  22246. * @param transformation the transformation matrix to apply
  22247. * @param result the vector to store the results in
  22248. */
  22249. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22250. }
  22251. /**
  22252. * Interface for the size containing width and height
  22253. */
  22254. interface ISize {
  22255. /**
  22256. * Width
  22257. */
  22258. width: number;
  22259. /**
  22260. * Heighht
  22261. */
  22262. height: number;
  22263. }
  22264. /**
  22265. * Size containing widht and height
  22266. */
  22267. class Size implements ISize {
  22268. /**
  22269. * Width
  22270. */
  22271. width: number;
  22272. /**
  22273. * Height
  22274. */
  22275. height: number;
  22276. /**
  22277. * Creates a Size object from the given width and height (floats).
  22278. * @param width width of the new size
  22279. * @param height height of the new size
  22280. */
  22281. constructor(width: number, height: number);
  22282. /**
  22283. * Returns a string with the Size width and height
  22284. * @returns a string with the Size width and height
  22285. */
  22286. toString(): string;
  22287. /**
  22288. * "Size"
  22289. * @returns the string "Size"
  22290. */
  22291. getClassName(): string;
  22292. /**
  22293. * Returns the Size hash code.
  22294. * @returns a hash code for a unique width and height
  22295. */
  22296. getHashCode(): number;
  22297. /**
  22298. * Updates the current size from the given one.
  22299. * @param src the given size
  22300. */
  22301. copyFrom(src: Size): void;
  22302. /**
  22303. * Updates in place the current Size from the given floats.
  22304. * @param width width of the new size
  22305. * @param height height of the new size
  22306. * @returns the updated Size.
  22307. */
  22308. copyFromFloats(width: number, height: number): Size;
  22309. /**
  22310. * Updates in place the current Size from the given floats.
  22311. * @param width width to set
  22312. * @param height height to set
  22313. * @returns the updated Size.
  22314. */
  22315. set(width: number, height: number): Size;
  22316. /**
  22317. * Multiplies the width and height by numbers
  22318. * @param w factor to multiple the width by
  22319. * @param h factor to multiple the height by
  22320. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  22321. */
  22322. multiplyByFloats(w: number, h: number): Size;
  22323. /**
  22324. * Clones the size
  22325. * @returns a new Size copied from the given one.
  22326. */
  22327. clone(): Size;
  22328. /**
  22329. * True if the current Size and the given one width and height are strictly equal.
  22330. * @param other the other size to compare against
  22331. * @returns True if the current Size and the given one width and height are strictly equal.
  22332. */
  22333. equals(other: Size): boolean;
  22334. /**
  22335. * The surface of the Size : width * height (float).
  22336. */
  22337. readonly surface: number;
  22338. /**
  22339. * Create a new size of zero
  22340. * @returns a new Size set to (0.0, 0.0)
  22341. */
  22342. static Zero(): Size;
  22343. /**
  22344. * Sums the width and height of two sizes
  22345. * @param otherSize size to add to this size
  22346. * @returns a new Size set as the addition result of the current Size and the given one.
  22347. */
  22348. add(otherSize: Size): Size;
  22349. /**
  22350. * Subtracts the width and height of two
  22351. * @param otherSize size to subtract to this size
  22352. * @returns a new Size set as the subtraction result of the given one from the current Size.
  22353. */
  22354. subtract(otherSize: Size): Size;
  22355. /**
  22356. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  22357. * @param start starting size to lerp between
  22358. * @param end end size to lerp between
  22359. * @param amount amount to lerp between the start and end values
  22360. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  22361. */
  22362. static Lerp(start: Size, end: Size, amount: number): Size;
  22363. }
  22364. /**
  22365. * Class used to store quaternion data
  22366. * @see https://en.wikipedia.org/wiki/Quaternion
  22367. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  22368. */
  22369. class Quaternion {
  22370. /** defines the first component (0 by default) */
  22371. x: number;
  22372. /** defines the second component (0 by default) */
  22373. y: number;
  22374. /** defines the third component (0 by default) */
  22375. z: number;
  22376. /** defines the fourth component (1.0 by default) */
  22377. w: number;
  22378. /**
  22379. * Creates a new Quaternion from the given floats
  22380. * @param x defines the first component (0 by default)
  22381. * @param y defines the second component (0 by default)
  22382. * @param z defines the third component (0 by default)
  22383. * @param w defines the fourth component (1.0 by default)
  22384. */
  22385. constructor(
  22386. /** defines the first component (0 by default) */
  22387. x?: number,
  22388. /** defines the second component (0 by default) */
  22389. y?: number,
  22390. /** defines the third component (0 by default) */
  22391. z?: number,
  22392. /** defines the fourth component (1.0 by default) */
  22393. w?: number);
  22394. /**
  22395. * Gets a string representation for the current quaternion
  22396. * @returns a string with the Quaternion coordinates
  22397. */
  22398. toString(): string;
  22399. /**
  22400. * Gets the class name of the quaternion
  22401. * @returns the string "Quaternion"
  22402. */
  22403. getClassName(): string;
  22404. /**
  22405. * Gets a hash code for this quaternion
  22406. * @returns the quaternion hash code
  22407. */
  22408. getHashCode(): number;
  22409. /**
  22410. * Copy the quaternion to an array
  22411. * @returns a new array populated with 4 elements from the quaternion coordinates
  22412. */
  22413. asArray(): number[];
  22414. /**
  22415. * Check if two quaternions are equals
  22416. * @param otherQuaternion defines the second operand
  22417. * @return true if the current quaternion and the given one coordinates are strictly equals
  22418. */
  22419. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  22420. /**
  22421. * Clone the current quaternion
  22422. * @returns a new quaternion copied from the current one
  22423. */
  22424. clone(): Quaternion;
  22425. /**
  22426. * Copy a quaternion to the current one
  22427. * @param other defines the other quaternion
  22428. * @returns the updated current quaternion
  22429. */
  22430. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  22431. /**
  22432. * Updates the current quaternion with the given float coordinates
  22433. * @param x defines the x coordinate
  22434. * @param y defines the y coordinate
  22435. * @param z defines the z coordinate
  22436. * @param w defines the w coordinate
  22437. * @returns the updated current quaternion
  22438. */
  22439. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  22440. /**
  22441. * Updates the current quaternion from the given float coordinates
  22442. * @param x defines the x coordinate
  22443. * @param y defines the y coordinate
  22444. * @param z defines the z coordinate
  22445. * @param w defines the w coordinate
  22446. * @returns the updated current quaternion
  22447. */
  22448. set(x: number, y: number, z: number, w: number): Quaternion;
  22449. /**
  22450. * Adds two quaternions
  22451. * @param other defines the second operand
  22452. * @returns a new quaternion as the addition result of the given one and the current quaternion
  22453. */
  22454. add(other: DeepImmutable<Quaternion>): Quaternion;
  22455. /**
  22456. * Add a quaternion to the current one
  22457. * @param other defines the quaternion to add
  22458. * @returns the current quaternion
  22459. */
  22460. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  22461. /**
  22462. * Subtract two quaternions
  22463. * @param other defines the second operand
  22464. * @returns a new quaternion as the subtraction result of the given one from the current one
  22465. */
  22466. subtract(other: Quaternion): Quaternion;
  22467. /**
  22468. * Multiplies the current quaternion by a scale factor
  22469. * @param value defines the scale factor
  22470. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  22471. */
  22472. scale(value: number): Quaternion;
  22473. /**
  22474. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  22475. * @param scale defines the scale factor
  22476. * @param result defines the Quaternion object where to store the result
  22477. * @returns the unmodified current quaternion
  22478. */
  22479. scaleToRef(scale: number, result: Quaternion): Quaternion;
  22480. /**
  22481. * Multiplies in place the current quaternion by a scale factor
  22482. * @param value defines the scale factor
  22483. * @returns the current modified quaternion
  22484. */
  22485. scaleInPlace(value: number): Quaternion;
  22486. /**
  22487. * Scale the current quaternion values by a factor and add the result to a given quaternion
  22488. * @param scale defines the scale factor
  22489. * @param result defines the Quaternion object where to store the result
  22490. * @returns the unmodified current quaternion
  22491. */
  22492. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  22493. /**
  22494. * Multiplies two quaternions
  22495. * @param q1 defines the second operand
  22496. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  22497. */
  22498. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  22499. /**
  22500. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  22501. * @param q1 defines the second operand
  22502. * @param result defines the target quaternion
  22503. * @returns the current quaternion
  22504. */
  22505. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  22506. /**
  22507. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  22508. * @param q1 defines the second operand
  22509. * @returns the currentupdated quaternion
  22510. */
  22511. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  22512. /**
  22513. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  22514. * @param ref defines the target quaternion
  22515. * @returns the current quaternion
  22516. */
  22517. conjugateToRef(ref: Quaternion): Quaternion;
  22518. /**
  22519. * Conjugates in place (1-q) the current quaternion
  22520. * @returns the current updated quaternion
  22521. */
  22522. conjugateInPlace(): Quaternion;
  22523. /**
  22524. * Conjugates in place (1-q) the current quaternion
  22525. * @returns a new quaternion
  22526. */
  22527. conjugate(): Quaternion;
  22528. /**
  22529. * Gets length of current quaternion
  22530. * @returns the quaternion length (float)
  22531. */
  22532. length(): number;
  22533. /**
  22534. * Normalize in place the current quaternion
  22535. * @returns the current updated quaternion
  22536. */
  22537. normalize(): Quaternion;
  22538. /**
  22539. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  22540. * @param order is a reserved parameter and is ignore for now
  22541. * @returns a new Vector3 containing the Euler angles
  22542. */
  22543. toEulerAngles(order?: string): Vector3;
  22544. /**
  22545. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  22546. * @param result defines the vector which will be filled with the Euler angles
  22547. * @param order is a reserved parameter and is ignore for now
  22548. * @returns the current unchanged quaternion
  22549. */
  22550. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  22551. /**
  22552. * Updates the given rotation matrix with the current quaternion values
  22553. * @param result defines the target matrix
  22554. * @returns the current unchanged quaternion
  22555. */
  22556. toRotationMatrix(result: Matrix): Quaternion;
  22557. /**
  22558. * Updates the current quaternion from the given rotation matrix values
  22559. * @param matrix defines the source matrix
  22560. * @returns the current updated quaternion
  22561. */
  22562. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22563. /**
  22564. * Creates a new quaternion from a rotation matrix
  22565. * @param matrix defines the source matrix
  22566. * @returns a new quaternion created from the given rotation matrix values
  22567. */
  22568. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22569. /**
  22570. * Updates the given quaternion with the given rotation matrix values
  22571. * @param matrix defines the source matrix
  22572. * @param result defines the target quaternion
  22573. */
  22574. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  22575. /**
  22576. * Returns the dot product (float) between the quaternions "left" and "right"
  22577. * @param left defines the left operand
  22578. * @param right defines the right operand
  22579. * @returns the dot product
  22580. */
  22581. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  22582. /**
  22583. * Checks if the two quaternions are close to each other
  22584. * @param quat0 defines the first quaternion to check
  22585. * @param quat1 defines the second quaternion to check
  22586. * @returns true if the two quaternions are close to each other
  22587. */
  22588. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  22589. /**
  22590. * Creates an empty quaternion
  22591. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  22592. */
  22593. static Zero(): Quaternion;
  22594. /**
  22595. * Inverse a given quaternion
  22596. * @param q defines the source quaternion
  22597. * @returns a new quaternion as the inverted current quaternion
  22598. */
  22599. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  22600. /**
  22601. * Inverse a given quaternion
  22602. * @param q defines the source quaternion
  22603. * @param result the quaternion the result will be stored in
  22604. * @returns the result quaternion
  22605. */
  22606. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  22607. /**
  22608. * Creates an identity quaternion
  22609. * @returns the identity quaternion
  22610. */
  22611. static Identity(): Quaternion;
  22612. /**
  22613. * Gets a boolean indicating if the given quaternion is identity
  22614. * @param quaternion defines the quaternion to check
  22615. * @returns true if the quaternion is identity
  22616. */
  22617. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  22618. /**
  22619. * Creates a quaternion from a rotation around an axis
  22620. * @param axis defines the axis to use
  22621. * @param angle defines the angle to use
  22622. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  22623. */
  22624. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  22625. /**
  22626. * Creates a rotation around an axis and stores it into the given quaternion
  22627. * @param axis defines the axis to use
  22628. * @param angle defines the angle to use
  22629. * @param result defines the target quaternion
  22630. * @returns the target quaternion
  22631. */
  22632. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  22633. /**
  22634. * Creates a new quaternion from data stored into an array
  22635. * @param array defines the data source
  22636. * @param offset defines the offset in the source array where the data starts
  22637. * @returns a new quaternion
  22638. */
  22639. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  22640. /**
  22641. * Create a quaternion from Euler rotation angles
  22642. * @param x Pitch
  22643. * @param y Yaw
  22644. * @param z Roll
  22645. * @returns the new Quaternion
  22646. */
  22647. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  22648. /**
  22649. * Updates a quaternion from Euler rotation angles
  22650. * @param x Pitch
  22651. * @param y Yaw
  22652. * @param z Roll
  22653. * @param result the quaternion to store the result
  22654. * @returns the updated quaternion
  22655. */
  22656. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  22657. /**
  22658. * Create a quaternion from Euler rotation vector
  22659. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22660. * @returns the new Quaternion
  22661. */
  22662. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  22663. /**
  22664. * Updates a quaternion from Euler rotation vector
  22665. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22666. * @param result the quaternion to store the result
  22667. * @returns the updated quaternion
  22668. */
  22669. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  22670. /**
  22671. * Creates a new quaternion from the given Euler float angles (y, x, z)
  22672. * @param yaw defines the rotation around Y axis
  22673. * @param pitch defines the rotation around X axis
  22674. * @param roll defines the rotation around Z axis
  22675. * @returns the new quaternion
  22676. */
  22677. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  22678. /**
  22679. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  22680. * @param yaw defines the rotation around Y axis
  22681. * @param pitch defines the rotation around X axis
  22682. * @param roll defines the rotation around Z axis
  22683. * @param result defines the target quaternion
  22684. */
  22685. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  22686. /**
  22687. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  22688. * @param alpha defines the rotation around first axis
  22689. * @param beta defines the rotation around second axis
  22690. * @param gamma defines the rotation around third axis
  22691. * @returns the new quaternion
  22692. */
  22693. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  22694. /**
  22695. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  22696. * @param alpha defines the rotation around first axis
  22697. * @param beta defines the rotation around second axis
  22698. * @param gamma defines the rotation around third axis
  22699. * @param result defines the target quaternion
  22700. */
  22701. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  22702. /**
  22703. * 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)
  22704. * @param axis1 defines the first axis
  22705. * @param axis2 defines the second axis
  22706. * @param axis3 defines the third axis
  22707. * @returns the new quaternion
  22708. */
  22709. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  22710. /**
  22711. * 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
  22712. * @param axis1 defines the first axis
  22713. * @param axis2 defines the second axis
  22714. * @param axis3 defines the third axis
  22715. * @param ref defines the target quaternion
  22716. */
  22717. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  22718. /**
  22719. * Interpolates between two quaternions
  22720. * @param left defines first quaternion
  22721. * @param right defines second quaternion
  22722. * @param amount defines the gradient to use
  22723. * @returns the new interpolated quaternion
  22724. */
  22725. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22726. /**
  22727. * Interpolates between two quaternions and stores it into a target quaternion
  22728. * @param left defines first quaternion
  22729. * @param right defines second quaternion
  22730. * @param amount defines the gradient to use
  22731. * @param result defines the target quaternion
  22732. */
  22733. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  22734. /**
  22735. * Interpolate between two quaternions using Hermite interpolation
  22736. * @param value1 defines first quaternion
  22737. * @param tangent1 defines the incoming tangent
  22738. * @param value2 defines second quaternion
  22739. * @param tangent2 defines the outgoing tangent
  22740. * @param amount defines the target quaternion
  22741. * @returns the new interpolated quaternion
  22742. */
  22743. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22744. }
  22745. /**
  22746. * Class used to store matrix data (4x4)
  22747. */
  22748. class Matrix {
  22749. private static _updateFlagSeed;
  22750. private static _identityReadOnly;
  22751. private _isIdentity;
  22752. private _isIdentityDirty;
  22753. private _isIdentity3x2;
  22754. private _isIdentity3x2Dirty;
  22755. /**
  22756. * Gets the update flag of the matrix which is an unique number for the matrix.
  22757. * It will be incremented every time the matrix data change.
  22758. * You can use it to speed the comparison between two versions of the same matrix.
  22759. */
  22760. updateFlag: number;
  22761. private readonly _m;
  22762. /**
  22763. * Gets the internal data of the matrix
  22764. */
  22765. readonly m: DeepImmutable<Float32Array>;
  22766. /** @hidden */
  22767. _markAsUpdated(): void;
  22768. /** @hidden */
  22769. private _updateIdentityStatus;
  22770. /**
  22771. * Creates an empty matrix (filled with zeros)
  22772. */
  22773. constructor();
  22774. /**
  22775. * Check if the current matrix is identity
  22776. * @returns true is the matrix is the identity matrix
  22777. */
  22778. isIdentity(): boolean;
  22779. /**
  22780. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  22781. * @returns true is the matrix is the identity matrix
  22782. */
  22783. isIdentityAs3x2(): boolean;
  22784. /**
  22785. * Gets the determinant of the matrix
  22786. * @returns the matrix determinant
  22787. */
  22788. determinant(): number;
  22789. /**
  22790. * Returns the matrix as a Float32Array
  22791. * @returns the matrix underlying array
  22792. */
  22793. toArray(): DeepImmutable<Float32Array>;
  22794. /**
  22795. * Returns the matrix as a Float32Array
  22796. * @returns the matrix underlying array.
  22797. */
  22798. asArray(): DeepImmutable<Float32Array>;
  22799. /**
  22800. * Inverts the current matrix in place
  22801. * @returns the current inverted matrix
  22802. */
  22803. invert(): Matrix;
  22804. /**
  22805. * Sets all the matrix elements to zero
  22806. * @returns the current matrix
  22807. */
  22808. reset(): Matrix;
  22809. /**
  22810. * Adds the current matrix with a second one
  22811. * @param other defines the matrix to add
  22812. * @returns a new matrix as the addition of the current matrix and the given one
  22813. */
  22814. add(other: DeepImmutable<Matrix>): Matrix;
  22815. /**
  22816. * Sets the given matrix "result" to the addition of the current matrix and the given one
  22817. * @param other defines the matrix to add
  22818. * @param result defines the target matrix
  22819. * @returns the current matrix
  22820. */
  22821. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  22822. /**
  22823. * Adds in place the given matrix to the current matrix
  22824. * @param other defines the second operand
  22825. * @returns the current updated matrix
  22826. */
  22827. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  22828. /**
  22829. * Sets the given matrix to the current inverted Matrix
  22830. * @param other defines the target matrix
  22831. * @returns the unmodified current matrix
  22832. */
  22833. invertToRef(other: Matrix): Matrix;
  22834. /**
  22835. * add a value at the specified position in the current Matrix
  22836. * @param index the index of the value within the matrix. between 0 and 15.
  22837. * @param value the value to be added
  22838. * @returns the current updated matrix
  22839. */
  22840. addAtIndex(index: number, value: number): Matrix;
  22841. /**
  22842. * mutiply the specified position in the current Matrix by a value
  22843. * @param index the index of the value within the matrix. between 0 and 15.
  22844. * @param value the value to be added
  22845. * @returns the current updated matrix
  22846. */
  22847. multiplyAtIndex(index: number, value: number): Matrix;
  22848. /**
  22849. * Inserts the translation vector (using 3 floats) in the current matrix
  22850. * @param x defines the 1st component of the translation
  22851. * @param y defines the 2nd component of the translation
  22852. * @param z defines the 3rd component of the translation
  22853. * @returns the current updated matrix
  22854. */
  22855. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  22856. /**
  22857. * Inserts the translation vector in the current matrix
  22858. * @param vector3 defines the translation to insert
  22859. * @returns the current updated matrix
  22860. */
  22861. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  22862. /**
  22863. * Gets the translation value of the current matrix
  22864. * @returns a new Vector3 as the extracted translation from the matrix
  22865. */
  22866. getTranslation(): Vector3;
  22867. /**
  22868. * Fill a Vector3 with the extracted translation from the matrix
  22869. * @param result defines the Vector3 where to store the translation
  22870. * @returns the current matrix
  22871. */
  22872. getTranslationToRef(result: Vector3): Matrix;
  22873. /**
  22874. * Remove rotation and scaling part from the matrix
  22875. * @returns the updated matrix
  22876. */
  22877. removeRotationAndScaling(): Matrix;
  22878. /**
  22879. * Multiply two matrices
  22880. * @param other defines the second operand
  22881. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  22882. */
  22883. multiply(other: DeepImmutable<Matrix>): Matrix;
  22884. /**
  22885. * Copy the current matrix from the given one
  22886. * @param other defines the source matrix
  22887. * @returns the current updated matrix
  22888. */
  22889. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  22890. /**
  22891. * Populates the given array from the starting index with the current matrix values
  22892. * @param array defines the target array
  22893. * @param offset defines the offset in the target array where to start storing values
  22894. * @returns the current matrix
  22895. */
  22896. copyToArray(array: Float32Array, offset?: number): Matrix;
  22897. /**
  22898. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  22899. * @param other defines the second operand
  22900. * @param result defines the matrix where to store the multiplication
  22901. * @returns the current matrix
  22902. */
  22903. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  22904. /**
  22905. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  22906. * @param other defines the second operand
  22907. * @param result defines the array where to store the multiplication
  22908. * @param offset defines the offset in the target array where to start storing values
  22909. * @returns the current matrix
  22910. */
  22911. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  22912. /**
  22913. * Check equality between this matrix and a second one
  22914. * @param value defines the second matrix to compare
  22915. * @returns true is the current matrix and the given one values are strictly equal
  22916. */
  22917. equals(value: DeepImmutable<Matrix>): boolean;
  22918. /**
  22919. * Clone the current matrix
  22920. * @returns a new matrix from the current matrix
  22921. */
  22922. clone(): Matrix;
  22923. /**
  22924. * Returns the name of the current matrix class
  22925. * @returns the string "Matrix"
  22926. */
  22927. getClassName(): string;
  22928. /**
  22929. * Gets the hash code of the current matrix
  22930. * @returns the hash code
  22931. */
  22932. getHashCode(): number;
  22933. /**
  22934. * Decomposes the current Matrix into a translation, rotation and scaling components
  22935. * @param scale defines the scale vector3 given as a reference to update
  22936. * @param rotation defines the rotation quaternion given as a reference to update
  22937. * @param translation defines the translation vector3 given as a reference to update
  22938. * @returns true if operation was successful
  22939. */
  22940. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  22941. /**
  22942. * Gets specific row of the matrix
  22943. * @param index defines the number of the row to get
  22944. * @returns the index-th row of the current matrix as a new Vector4
  22945. */
  22946. getRow(index: number): Nullable<Vector4>;
  22947. /**
  22948. * Sets the index-th row of the current matrix to the vector4 values
  22949. * @param index defines the number of the row to set
  22950. * @param row defines the target vector4
  22951. * @returns the updated current matrix
  22952. */
  22953. setRow(index: number, row: Vector4): Matrix;
  22954. /**
  22955. * Compute the transpose of the matrix
  22956. * @returns the new transposed matrix
  22957. */
  22958. transpose(): Matrix;
  22959. /**
  22960. * Compute the transpose of the matrix and store it in a given matrix
  22961. * @param result defines the target matrix
  22962. * @returns the current matrix
  22963. */
  22964. transposeToRef(result: Matrix): Matrix;
  22965. /**
  22966. * Sets the index-th row of the current matrix with the given 4 x float values
  22967. * @param index defines the row index
  22968. * @param x defines the x component to set
  22969. * @param y defines the y component to set
  22970. * @param z defines the z component to set
  22971. * @param w defines the w component to set
  22972. * @returns the updated current matrix
  22973. */
  22974. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  22975. /**
  22976. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  22977. * @param scale defines the scale factor
  22978. * @returns a new matrix
  22979. */
  22980. scale(scale: number): Matrix;
  22981. /**
  22982. * Scale the current matrix values by a factor to a given result matrix
  22983. * @param scale defines the scale factor
  22984. * @param result defines the matrix to store the result
  22985. * @returns the current matrix
  22986. */
  22987. scaleToRef(scale: number, result: Matrix): Matrix;
  22988. /**
  22989. * Scale the current matrix values by a factor and add the result to a given matrix
  22990. * @param scale defines the scale factor
  22991. * @param result defines the Matrix to store the result
  22992. * @returns the current matrix
  22993. */
  22994. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  22995. /**
  22996. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  22997. * @param ref matrix to store the result
  22998. */
  22999. toNormalMatrix(ref: Matrix): void;
  23000. /**
  23001. * Gets only rotation part of the current matrix
  23002. * @returns a new matrix sets to the extracted rotation matrix from the current one
  23003. */
  23004. getRotationMatrix(): Matrix;
  23005. /**
  23006. * Extracts the rotation matrix from the current one and sets it as the given "result"
  23007. * @param result defines the target matrix to store data to
  23008. * @returns the current matrix
  23009. */
  23010. getRotationMatrixToRef(result: Matrix): Matrix;
  23011. /**
  23012. * Toggles model matrix from being right handed to left handed in place and vice versa
  23013. */
  23014. toggleModelMatrixHandInPlace(): void;
  23015. /**
  23016. * Toggles projection matrix from being right handed to left handed in place and vice versa
  23017. */
  23018. toggleProjectionMatrixHandInPlace(): void;
  23019. /**
  23020. * Creates a matrix from an array
  23021. * @param array defines the source array
  23022. * @param offset defines an offset in the source array
  23023. * @returns a new Matrix set from the starting index of the given array
  23024. */
  23025. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  23026. /**
  23027. * Copy the content of an array into a given matrix
  23028. * @param array defines the source array
  23029. * @param offset defines an offset in the source array
  23030. * @param result defines the target matrix
  23031. */
  23032. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  23033. /**
  23034. * Stores an array into a matrix after having multiplied each component by a given factor
  23035. * @param array defines the source array
  23036. * @param offset defines the offset in the source array
  23037. * @param scale defines the scaling factor
  23038. * @param result defines the target matrix
  23039. */
  23040. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  23041. /**
  23042. * Gets an identity matrix that must not be updated
  23043. */
  23044. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  23045. /**
  23046. * Stores a list of values (16) inside a given matrix
  23047. * @param initialM11 defines 1st value of 1st row
  23048. * @param initialM12 defines 2nd value of 1st row
  23049. * @param initialM13 defines 3rd value of 1st row
  23050. * @param initialM14 defines 4th value of 1st row
  23051. * @param initialM21 defines 1st value of 2nd row
  23052. * @param initialM22 defines 2nd value of 2nd row
  23053. * @param initialM23 defines 3rd value of 2nd row
  23054. * @param initialM24 defines 4th value of 2nd row
  23055. * @param initialM31 defines 1st value of 3rd row
  23056. * @param initialM32 defines 2nd value of 3rd row
  23057. * @param initialM33 defines 3rd value of 3rd row
  23058. * @param initialM34 defines 4th value of 3rd row
  23059. * @param initialM41 defines 1st value of 4th row
  23060. * @param initialM42 defines 2nd value of 4th row
  23061. * @param initialM43 defines 3rd value of 4th row
  23062. * @param initialM44 defines 4th value of 4th row
  23063. * @param result defines the target matrix
  23064. */
  23065. 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;
  23066. /**
  23067. * Creates new matrix from a list of values (16)
  23068. * @param initialM11 defines 1st value of 1st row
  23069. * @param initialM12 defines 2nd value of 1st row
  23070. * @param initialM13 defines 3rd value of 1st row
  23071. * @param initialM14 defines 4th value of 1st row
  23072. * @param initialM21 defines 1st value of 2nd row
  23073. * @param initialM22 defines 2nd value of 2nd row
  23074. * @param initialM23 defines 3rd value of 2nd row
  23075. * @param initialM24 defines 4th value of 2nd row
  23076. * @param initialM31 defines 1st value of 3rd row
  23077. * @param initialM32 defines 2nd value of 3rd row
  23078. * @param initialM33 defines 3rd value of 3rd row
  23079. * @param initialM34 defines 4th value of 3rd row
  23080. * @param initialM41 defines 1st value of 4th row
  23081. * @param initialM42 defines 2nd value of 4th row
  23082. * @param initialM43 defines 3rd value of 4th row
  23083. * @param initialM44 defines 4th value of 4th row
  23084. * @returns the new matrix
  23085. */
  23086. 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;
  23087. /**
  23088. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  23089. * @param scale defines the scale vector3
  23090. * @param rotation defines the rotation quaternion
  23091. * @param translation defines the translation vector3
  23092. * @returns a new matrix
  23093. */
  23094. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  23095. /**
  23096. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  23097. * @param scale defines the scale vector3
  23098. * @param rotation defines the rotation quaternion
  23099. * @param translation defines the translation vector3
  23100. * @param result defines the target matrix
  23101. */
  23102. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  23103. /**
  23104. * Creates a new identity matrix
  23105. * @returns a new identity matrix
  23106. */
  23107. static Identity(): Matrix;
  23108. /**
  23109. * Creates a new identity matrix and stores the result in a given matrix
  23110. * @param result defines the target matrix
  23111. */
  23112. static IdentityToRef(result: Matrix): void;
  23113. /**
  23114. * Creates a new zero matrix
  23115. * @returns a new zero matrix
  23116. */
  23117. static Zero(): Matrix;
  23118. /**
  23119. * Creates a new rotation matrix for "angle" radians around the X axis
  23120. * @param angle defines the angle (in radians) to use
  23121. * @return the new matrix
  23122. */
  23123. static RotationX(angle: number): Matrix;
  23124. /**
  23125. * Creates a new matrix as the invert of a given matrix
  23126. * @param source defines the source matrix
  23127. * @returns the new matrix
  23128. */
  23129. static Invert(source: DeepImmutable<Matrix>): Matrix;
  23130. /**
  23131. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  23132. * @param angle defines the angle (in radians) to use
  23133. * @param result defines the target matrix
  23134. */
  23135. static RotationXToRef(angle: number, result: Matrix): void;
  23136. /**
  23137. * Creates a new rotation matrix for "angle" radians around the Y axis
  23138. * @param angle defines the angle (in radians) to use
  23139. * @return the new matrix
  23140. */
  23141. static RotationY(angle: number): Matrix;
  23142. /**
  23143. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  23144. * @param angle defines the angle (in radians) to use
  23145. * @param result defines the target matrix
  23146. */
  23147. static RotationYToRef(angle: number, result: Matrix): void;
  23148. /**
  23149. * Creates a new rotation matrix for "angle" radians around the Z axis
  23150. * @param angle defines the angle (in radians) to use
  23151. * @return the new matrix
  23152. */
  23153. static RotationZ(angle: number): Matrix;
  23154. /**
  23155. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  23156. * @param angle defines the angle (in radians) to use
  23157. * @param result defines the target matrix
  23158. */
  23159. static RotationZToRef(angle: number, result: Matrix): void;
  23160. /**
  23161. * Creates a new rotation matrix for "angle" radians around the given axis
  23162. * @param axis defines the axis to use
  23163. * @param angle defines the angle (in radians) to use
  23164. * @return the new matrix
  23165. */
  23166. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  23167. /**
  23168. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  23169. * @param axis defines the axis to use
  23170. * @param angle defines the angle (in radians) to use
  23171. * @param result defines the target matrix
  23172. */
  23173. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  23174. /**
  23175. * Creates a rotation matrix
  23176. * @param yaw defines the yaw angle in radians (Y axis)
  23177. * @param pitch defines the pitch angle in radians (X axis)
  23178. * @param roll defines the roll angle in radians (X axis)
  23179. * @returns the new rotation matrix
  23180. */
  23181. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  23182. /**
  23183. * Creates a rotation matrix and stores it in a given matrix
  23184. * @param yaw defines the yaw angle in radians (Y axis)
  23185. * @param pitch defines the pitch angle in radians (X axis)
  23186. * @param roll defines the roll angle in radians (X axis)
  23187. * @param result defines the target matrix
  23188. */
  23189. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  23190. /**
  23191. * Creates a scaling matrix
  23192. * @param x defines the scale factor on X axis
  23193. * @param y defines the scale factor on Y axis
  23194. * @param z defines the scale factor on Z axis
  23195. * @returns the new matrix
  23196. */
  23197. static Scaling(x: number, y: number, z: number): Matrix;
  23198. /**
  23199. * Creates a scaling matrix and stores it in a given matrix
  23200. * @param x defines the scale factor on X axis
  23201. * @param y defines the scale factor on Y axis
  23202. * @param z defines the scale factor on Z axis
  23203. * @param result defines the target matrix
  23204. */
  23205. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  23206. /**
  23207. * Creates a translation matrix
  23208. * @param x defines the translation on X axis
  23209. * @param y defines the translation on Y axis
  23210. * @param z defines the translationon Z axis
  23211. * @returns the new matrix
  23212. */
  23213. static Translation(x: number, y: number, z: number): Matrix;
  23214. /**
  23215. * Creates a translation matrix and stores it in a given matrix
  23216. * @param x defines the translation on X axis
  23217. * @param y defines the translation on Y axis
  23218. * @param z defines the translationon Z axis
  23219. * @param result defines the target matrix
  23220. */
  23221. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  23222. /**
  23223. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23224. * @param startValue defines the start value
  23225. * @param endValue defines the end value
  23226. * @param gradient defines the gradient factor
  23227. * @returns the new matrix
  23228. */
  23229. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23230. /**
  23231. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23232. * @param startValue defines the start value
  23233. * @param endValue defines the end value
  23234. * @param gradient defines the gradient factor
  23235. * @param result defines the Matrix object where to store data
  23236. */
  23237. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23238. /**
  23239. * Builds a new matrix whose values are computed by:
  23240. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23241. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23242. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23243. * @param startValue defines the first matrix
  23244. * @param endValue defines the second matrix
  23245. * @param gradient defines the gradient between the two matrices
  23246. * @returns the new matrix
  23247. */
  23248. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23249. /**
  23250. * Update a matrix to values which are computed by:
  23251. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23252. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23253. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23254. * @param startValue defines the first matrix
  23255. * @param endValue defines the second matrix
  23256. * @param gradient defines the gradient between the two matrices
  23257. * @param result defines the target matrix
  23258. */
  23259. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23260. /**
  23261. * 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"
  23262. * This function works in left handed mode
  23263. * @param eye defines the final position of the entity
  23264. * @param target defines where the entity should look at
  23265. * @param up defines the up vector for the entity
  23266. * @returns the new matrix
  23267. */
  23268. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23269. /**
  23270. * 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".
  23271. * This function works in left handed mode
  23272. * @param eye defines the final position of the entity
  23273. * @param target defines where the entity should look at
  23274. * @param up defines the up vector for the entity
  23275. * @param result defines the target matrix
  23276. */
  23277. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23278. /**
  23279. * 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"
  23280. * This function works in right handed mode
  23281. * @param eye defines the final position of the entity
  23282. * @param target defines where the entity should look at
  23283. * @param up defines the up vector for the entity
  23284. * @returns the new matrix
  23285. */
  23286. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23287. /**
  23288. * 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".
  23289. * This function works in right handed mode
  23290. * @param eye defines the final position of the entity
  23291. * @param target defines where the entity should look at
  23292. * @param up defines the up vector for the entity
  23293. * @param result defines the target matrix
  23294. */
  23295. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23296. /**
  23297. * Create a left-handed orthographic projection matrix
  23298. * @param width defines the viewport width
  23299. * @param height defines the viewport height
  23300. * @param znear defines the near clip plane
  23301. * @param zfar defines the far clip plane
  23302. * @returns a new matrix as a left-handed orthographic projection matrix
  23303. */
  23304. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23305. /**
  23306. * Store a left-handed orthographic projection to a given matrix
  23307. * @param width defines the viewport width
  23308. * @param height defines the viewport height
  23309. * @param znear defines the near clip plane
  23310. * @param zfar defines the far clip plane
  23311. * @param result defines the target matrix
  23312. */
  23313. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  23314. /**
  23315. * Create a left-handed orthographic projection matrix
  23316. * @param left defines the viewport left coordinate
  23317. * @param right defines the viewport right coordinate
  23318. * @param bottom defines the viewport bottom coordinate
  23319. * @param top defines the viewport top coordinate
  23320. * @param znear defines the near clip plane
  23321. * @param zfar defines the far clip plane
  23322. * @returns a new matrix as a left-handed orthographic projection matrix
  23323. */
  23324. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23325. /**
  23326. * Stores a left-handed orthographic projection into a given matrix
  23327. * @param left defines the viewport left coordinate
  23328. * @param right defines the viewport right coordinate
  23329. * @param bottom defines the viewport bottom coordinate
  23330. * @param top defines the viewport top coordinate
  23331. * @param znear defines the near clip plane
  23332. * @param zfar defines the far clip plane
  23333. * @param result defines the target matrix
  23334. */
  23335. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23336. /**
  23337. * Creates a right-handed orthographic projection matrix
  23338. * @param left defines the viewport left coordinate
  23339. * @param right defines the viewport right coordinate
  23340. * @param bottom defines the viewport bottom coordinate
  23341. * @param top defines the viewport top coordinate
  23342. * @param znear defines the near clip plane
  23343. * @param zfar defines the far clip plane
  23344. * @returns a new matrix as a right-handed orthographic projection matrix
  23345. */
  23346. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23347. /**
  23348. * Stores a right-handed orthographic projection into a given matrix
  23349. * @param left defines the viewport left coordinate
  23350. * @param right defines the viewport right coordinate
  23351. * @param bottom defines the viewport bottom coordinate
  23352. * @param top defines the viewport top coordinate
  23353. * @param znear defines the near clip plane
  23354. * @param zfar defines the far clip plane
  23355. * @param result defines the target matrix
  23356. */
  23357. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23358. /**
  23359. * Creates a left-handed perspective projection matrix
  23360. * @param width defines the viewport width
  23361. * @param height defines the viewport height
  23362. * @param znear defines the near clip plane
  23363. * @param zfar defines the far clip plane
  23364. * @returns a new matrix as a left-handed perspective projection matrix
  23365. */
  23366. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23367. /**
  23368. * Creates a left-handed perspective projection matrix
  23369. * @param fov defines the horizontal field of view
  23370. * @param aspect defines the aspect ratio
  23371. * @param znear defines the near clip plane
  23372. * @param zfar defines the far clip plane
  23373. * @returns a new matrix as a left-handed perspective projection matrix
  23374. */
  23375. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23376. /**
  23377. * Stores a left-handed perspective projection into a given matrix
  23378. * @param fov defines the horizontal field of view
  23379. * @param aspect defines the aspect ratio
  23380. * @param znear defines the near clip plane
  23381. * @param zfar defines the far clip plane
  23382. * @param result defines the target matrix
  23383. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23384. */
  23385. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23386. /**
  23387. * Creates a right-handed perspective projection matrix
  23388. * @param fov defines the horizontal field of view
  23389. * @param aspect defines the aspect ratio
  23390. * @param znear defines the near clip plane
  23391. * @param zfar defines the far clip plane
  23392. * @returns a new matrix as a right-handed perspective projection matrix
  23393. */
  23394. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23395. /**
  23396. * Stores a right-handed perspective projection into a given matrix
  23397. * @param fov defines the horizontal field of view
  23398. * @param aspect defines the aspect ratio
  23399. * @param znear defines the near clip plane
  23400. * @param zfar defines the far clip plane
  23401. * @param result defines the target matrix
  23402. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23403. */
  23404. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23405. /**
  23406. * Stores a perspective projection for WebVR info a given matrix
  23407. * @param fov defines the field of view
  23408. * @param znear defines the near clip plane
  23409. * @param zfar defines the far clip plane
  23410. * @param result defines the target matrix
  23411. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  23412. */
  23413. static PerspectiveFovWebVRToRef(fov: {
  23414. upDegrees: number;
  23415. downDegrees: number;
  23416. leftDegrees: number;
  23417. rightDegrees: number;
  23418. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  23419. /**
  23420. * Computes a complete transformation matrix
  23421. * @param viewport defines the viewport to use
  23422. * @param world defines the world matrix
  23423. * @param view defines the view matrix
  23424. * @param projection defines the projection matrix
  23425. * @param zmin defines the near clip plane
  23426. * @param zmax defines the far clip plane
  23427. * @returns the transformation matrix
  23428. */
  23429. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  23430. /**
  23431. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  23432. * @param matrix defines the matrix to use
  23433. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  23434. */
  23435. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  23436. /**
  23437. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  23438. * @param matrix defines the matrix to use
  23439. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  23440. */
  23441. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  23442. /**
  23443. * Compute the transpose of a given matrix
  23444. * @param matrix defines the matrix to transpose
  23445. * @returns the new matrix
  23446. */
  23447. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  23448. /**
  23449. * Compute the transpose of a matrix and store it in a target matrix
  23450. * @param matrix defines the matrix to transpose
  23451. * @param result defines the target matrix
  23452. */
  23453. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  23454. /**
  23455. * Computes a reflection matrix from a plane
  23456. * @param plane defines the reflection plane
  23457. * @returns a new matrix
  23458. */
  23459. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  23460. /**
  23461. * Computes a reflection matrix from a plane
  23462. * @param plane defines the reflection plane
  23463. * @param result defines the target matrix
  23464. */
  23465. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  23466. /**
  23467. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  23468. * @param xaxis defines the value of the 1st axis
  23469. * @param yaxis defines the value of the 2nd axis
  23470. * @param zaxis defines the value of the 3rd axis
  23471. * @param result defines the target matrix
  23472. */
  23473. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  23474. /**
  23475. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  23476. * @param quat defines the quaternion to use
  23477. * @param result defines the target matrix
  23478. */
  23479. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  23480. }
  23481. /**
  23482. * Represens a plane by the equation ax + by + cz + d = 0
  23483. */
  23484. class Plane {
  23485. /**
  23486. * Normal of the plane (a,b,c)
  23487. */
  23488. normal: Vector3;
  23489. /**
  23490. * d component of the plane
  23491. */
  23492. d: number;
  23493. /**
  23494. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  23495. * @param a a component of the plane
  23496. * @param b b component of the plane
  23497. * @param c c component of the plane
  23498. * @param d d component of the plane
  23499. */
  23500. constructor(a: number, b: number, c: number, d: number);
  23501. /**
  23502. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  23503. */
  23504. asArray(): number[];
  23505. /**
  23506. * @returns a new plane copied from the current Plane.
  23507. */
  23508. clone(): Plane;
  23509. /**
  23510. * @returns the string "Plane".
  23511. */
  23512. getClassName(): string;
  23513. /**
  23514. * @returns the Plane hash code.
  23515. */
  23516. getHashCode(): number;
  23517. /**
  23518. * Normalize the current Plane in place.
  23519. * @returns the updated Plane.
  23520. */
  23521. normalize(): Plane;
  23522. /**
  23523. * Applies a transformation the plane and returns the result
  23524. * @param transformation the transformation matrix to be applied to the plane
  23525. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  23526. */
  23527. transform(transformation: DeepImmutable<Matrix>): Plane;
  23528. /**
  23529. * Calcualtte the dot product between the point and the plane normal
  23530. * @param point point to calculate the dot product with
  23531. * @returns the dot product (float) of the point coordinates and the plane normal.
  23532. */
  23533. dotCoordinate(point: DeepImmutable<Vector3>): number;
  23534. /**
  23535. * Updates the current Plane from the plane defined by the three given points.
  23536. * @param point1 one of the points used to contruct the plane
  23537. * @param point2 one of the points used to contruct the plane
  23538. * @param point3 one of the points used to contruct the plane
  23539. * @returns the updated Plane.
  23540. */
  23541. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23542. /**
  23543. * Checks if the plane is facing a given direction
  23544. * @param direction the direction to check if the plane is facing
  23545. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  23546. * @returns True is the vector "direction" is the same side than the plane normal.
  23547. */
  23548. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  23549. /**
  23550. * Calculates the distance to a point
  23551. * @param point point to calculate distance to
  23552. * @returns the signed distance (float) from the given point to the Plane.
  23553. */
  23554. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  23555. /**
  23556. * Creates a plane from an array
  23557. * @param array the array to create a plane from
  23558. * @returns a new Plane from the given array.
  23559. */
  23560. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  23561. /**
  23562. * Creates a plane from three points
  23563. * @param point1 point used to create the plane
  23564. * @param point2 point used to create the plane
  23565. * @param point3 point used to create the plane
  23566. * @returns a new Plane defined by the three given points.
  23567. */
  23568. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23569. /**
  23570. * Creates a plane from an origin point and a normal
  23571. * @param origin origin of the plane to be constructed
  23572. * @param normal normal of the plane to be constructed
  23573. * @returns a new Plane the normal vector to this plane at the given origin point.
  23574. * Note : the vector "normal" is updated because normalized.
  23575. */
  23576. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  23577. /**
  23578. * Calculates the distance from a plane and a point
  23579. * @param origin origin of the plane to be constructed
  23580. * @param normal normal of the plane to be constructed
  23581. * @param point point to calculate distance to
  23582. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  23583. */
  23584. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  23585. }
  23586. /**
  23587. * Class used to represent a viewport on screen
  23588. */
  23589. class Viewport {
  23590. /** viewport left coordinate */
  23591. x: number;
  23592. /** viewport top coordinate */
  23593. y: number;
  23594. /**viewport width */
  23595. width: number;
  23596. /** viewport height */
  23597. height: number;
  23598. /**
  23599. * Creates a Viewport object located at (x, y) and sized (width, height)
  23600. * @param x defines viewport left coordinate
  23601. * @param y defines viewport top coordinate
  23602. * @param width defines the viewport width
  23603. * @param height defines the viewport height
  23604. */
  23605. constructor(
  23606. /** viewport left coordinate */
  23607. x: number,
  23608. /** viewport top coordinate */
  23609. y: number,
  23610. /**viewport width */
  23611. width: number,
  23612. /** viewport height */
  23613. height: number);
  23614. /**
  23615. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  23616. * @param renderWidthOrEngine defines either an engine or the rendering width
  23617. * @param renderHeight defines the rendering height
  23618. * @returns a new Viewport
  23619. */
  23620. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  23621. /**
  23622. * Returns a new Viewport copied from the current one
  23623. * @returns a new Viewport
  23624. */
  23625. clone(): Viewport;
  23626. }
  23627. /**
  23628. * Reprasents a camera frustum
  23629. */
  23630. class Frustum {
  23631. /**
  23632. * Gets the planes representing the frustum
  23633. * @param transform matrix to be applied to the returned planes
  23634. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  23635. */
  23636. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  23637. /**
  23638. * Gets the near frustum plane transformed by the transform matrix
  23639. * @param transform transformation matrix to be applied to the resulting frustum plane
  23640. * @param frustumPlane the resuling frustum plane
  23641. */
  23642. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23643. /**
  23644. * Gets the far frustum plane transformed by the transform matrix
  23645. * @param transform transformation matrix to be applied to the resulting frustum plane
  23646. * @param frustumPlane the resuling frustum plane
  23647. */
  23648. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23649. /**
  23650. * Gets the left frustum plane transformed by the transform matrix
  23651. * @param transform transformation matrix to be applied to the resulting frustum plane
  23652. * @param frustumPlane the resuling frustum plane
  23653. */
  23654. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23655. /**
  23656. * Gets the right frustum plane transformed by the transform matrix
  23657. * @param transform transformation matrix to be applied to the resulting frustum plane
  23658. * @param frustumPlane the resuling frustum plane
  23659. */
  23660. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23661. /**
  23662. * Gets the top frustum plane transformed by the transform matrix
  23663. * @param transform transformation matrix to be applied to the resulting frustum plane
  23664. * @param frustumPlane the resuling frustum plane
  23665. */
  23666. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23667. /**
  23668. * Gets the bottom frustum plane transformed by the transform matrix
  23669. * @param transform transformation matrix to be applied to the resulting frustum plane
  23670. * @param frustumPlane the resuling frustum plane
  23671. */
  23672. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23673. /**
  23674. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  23675. * @param transform transformation matrix to be applied to the resulting frustum planes
  23676. * @param frustumPlanes the resuling frustum planes
  23677. */
  23678. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  23679. }
  23680. /** Defines supported spaces */
  23681. enum Space {
  23682. /** Local (object) space */
  23683. LOCAL = 0,
  23684. /** World space */
  23685. WORLD = 1,
  23686. /** Bone space */
  23687. BONE = 2
  23688. }
  23689. /** Defines the 3 main axes */
  23690. class Axis {
  23691. /** X axis */
  23692. static X: Vector3;
  23693. /** Y axis */
  23694. static Y: Vector3;
  23695. /** Z axis */
  23696. static Z: Vector3;
  23697. }
  23698. /** Class used to represent a Bezier curve */
  23699. class BezierCurve {
  23700. /**
  23701. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  23702. * @param t defines the time
  23703. * @param x1 defines the left coordinate on X axis
  23704. * @param y1 defines the left coordinate on Y axis
  23705. * @param x2 defines the right coordinate on X axis
  23706. * @param y2 defines the right coordinate on Y axis
  23707. * @returns the interpolated value
  23708. */
  23709. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  23710. }
  23711. /**
  23712. * Defines potential orientation for back face culling
  23713. */
  23714. enum Orientation {
  23715. /**
  23716. * Clockwise
  23717. */
  23718. CW = 0,
  23719. /** Counter clockwise */
  23720. CCW = 1
  23721. }
  23722. /**
  23723. * Defines angle representation
  23724. */
  23725. class Angle {
  23726. private _radians;
  23727. /**
  23728. * Creates an Angle object of "radians" radians (float).
  23729. */
  23730. constructor(radians: number);
  23731. /**
  23732. * Get value in degrees
  23733. * @returns the Angle value in degrees (float)
  23734. */
  23735. degrees(): number;
  23736. /**
  23737. * Get value in radians
  23738. * @returns the Angle value in radians (float)
  23739. */
  23740. radians(): number;
  23741. /**
  23742. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  23743. * @param a defines first vector
  23744. * @param b defines second vector
  23745. * @returns a new Angle
  23746. */
  23747. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  23748. /**
  23749. * Gets a new Angle object from the given float in radians
  23750. * @param radians defines the angle value in radians
  23751. * @returns a new Angle
  23752. */
  23753. static FromRadians(radians: number): Angle;
  23754. /**
  23755. * Gets a new Angle object from the given float in degrees
  23756. * @param degrees defines the angle value in degrees
  23757. * @returns a new Angle
  23758. */
  23759. static FromDegrees(degrees: number): Angle;
  23760. }
  23761. /**
  23762. * This represents an arc in a 2d space.
  23763. */
  23764. class Arc2 {
  23765. /** Defines the start point of the arc */
  23766. startPoint: Vector2;
  23767. /** Defines the mid point of the arc */
  23768. midPoint: Vector2;
  23769. /** Defines the end point of the arc */
  23770. endPoint: Vector2;
  23771. /**
  23772. * Defines the center point of the arc.
  23773. */
  23774. centerPoint: Vector2;
  23775. /**
  23776. * Defines the radius of the arc.
  23777. */
  23778. radius: number;
  23779. /**
  23780. * Defines the angle of the arc (from mid point to end point).
  23781. */
  23782. angle: Angle;
  23783. /**
  23784. * Defines the start angle of the arc (from start point to middle point).
  23785. */
  23786. startAngle: Angle;
  23787. /**
  23788. * Defines the orientation of the arc (clock wise/counter clock wise).
  23789. */
  23790. orientation: Orientation;
  23791. /**
  23792. * Creates an Arc object from the three given points : start, middle and end.
  23793. * @param startPoint Defines the start point of the arc
  23794. * @param midPoint Defines the midlle point of the arc
  23795. * @param endPoint Defines the end point of the arc
  23796. */
  23797. constructor(
  23798. /** Defines the start point of the arc */
  23799. startPoint: Vector2,
  23800. /** Defines the mid point of the arc */
  23801. midPoint: Vector2,
  23802. /** Defines the end point of the arc */
  23803. endPoint: Vector2);
  23804. }
  23805. /**
  23806. * Represents a 2D path made up of multiple 2D points
  23807. */
  23808. class Path2 {
  23809. private _points;
  23810. private _length;
  23811. /**
  23812. * If the path start and end point are the same
  23813. */
  23814. closed: boolean;
  23815. /**
  23816. * Creates a Path2 object from the starting 2D coordinates x and y.
  23817. * @param x the starting points x value
  23818. * @param y the starting points y value
  23819. */
  23820. constructor(x: number, y: number);
  23821. /**
  23822. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  23823. * @param x the added points x value
  23824. * @param y the added points y value
  23825. * @returns the updated Path2.
  23826. */
  23827. addLineTo(x: number, y: number): Path2;
  23828. /**
  23829. * 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.
  23830. * @param midX middle point x value
  23831. * @param midY middle point y value
  23832. * @param endX end point x value
  23833. * @param endY end point y value
  23834. * @param numberOfSegments (default: 36)
  23835. * @returns the updated Path2.
  23836. */
  23837. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  23838. /**
  23839. * Closes the Path2.
  23840. * @returns the Path2.
  23841. */
  23842. close(): Path2;
  23843. /**
  23844. * Gets the sum of the distance between each sequential point in the path
  23845. * @returns the Path2 total length (float).
  23846. */
  23847. length(): number;
  23848. /**
  23849. * Gets the points which construct the path
  23850. * @returns the Path2 internal array of points.
  23851. */
  23852. getPoints(): Vector2[];
  23853. /**
  23854. * Retreives the point at the distance aways from the starting point
  23855. * @param normalizedLengthPosition the length along the path to retreive the point from
  23856. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  23857. */
  23858. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  23859. /**
  23860. * Creates a new path starting from an x and y position
  23861. * @param x starting x value
  23862. * @param y starting y value
  23863. * @returns a new Path2 starting at the coordinates (x, y).
  23864. */
  23865. static StartingAt(x: number, y: number): Path2;
  23866. }
  23867. /**
  23868. * Represents a 3D path made up of multiple 3D points
  23869. */
  23870. class Path3D {
  23871. /**
  23872. * an array of Vector3, the curve axis of the Path3D
  23873. */
  23874. path: Vector3[];
  23875. private _curve;
  23876. private _distances;
  23877. private _tangents;
  23878. private _normals;
  23879. private _binormals;
  23880. private _raw;
  23881. /**
  23882. * new Path3D(path, normal, raw)
  23883. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  23884. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  23885. * @param path an array of Vector3, the curve axis of the Path3D
  23886. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  23887. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  23888. */
  23889. constructor(
  23890. /**
  23891. * an array of Vector3, the curve axis of the Path3D
  23892. */
  23893. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  23894. /**
  23895. * Returns the Path3D array of successive Vector3 designing its curve.
  23896. * @returns the Path3D array of successive Vector3 designing its curve.
  23897. */
  23898. getCurve(): Vector3[];
  23899. /**
  23900. * Returns an array populated with tangent vectors on each Path3D curve point.
  23901. * @returns an array populated with tangent vectors on each Path3D curve point.
  23902. */
  23903. getTangents(): Vector3[];
  23904. /**
  23905. * Returns an array populated with normal vectors on each Path3D curve point.
  23906. * @returns an array populated with normal vectors on each Path3D curve point.
  23907. */
  23908. getNormals(): Vector3[];
  23909. /**
  23910. * Returns an array populated with binormal vectors on each Path3D curve point.
  23911. * @returns an array populated with binormal vectors on each Path3D curve point.
  23912. */
  23913. getBinormals(): Vector3[];
  23914. /**
  23915. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  23916. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  23917. */
  23918. getDistances(): number[];
  23919. /**
  23920. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  23921. * @param path path which all values are copied into the curves points
  23922. * @param firstNormal which should be projected onto the curve
  23923. * @returns the same object updated.
  23924. */
  23925. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  23926. private _compute;
  23927. private _getFirstNonNullVector;
  23928. private _getLastNonNullVector;
  23929. private _normalVector;
  23930. }
  23931. /**
  23932. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23933. * A Curve3 is designed from a series of successive Vector3.
  23934. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  23935. */
  23936. class Curve3 {
  23937. private _points;
  23938. private _length;
  23939. /**
  23940. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  23941. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  23942. * @param v1 (Vector3) the control point
  23943. * @param v2 (Vector3) the end point of the Quadratic Bezier
  23944. * @param nbPoints (integer) the wanted number of points in the curve
  23945. * @returns the created Curve3
  23946. */
  23947. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  23948. /**
  23949. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  23950. * @param v0 (Vector3) the origin point of the Cubic Bezier
  23951. * @param v1 (Vector3) the first control point
  23952. * @param v2 (Vector3) the second control point
  23953. * @param v3 (Vector3) the end point of the Cubic Bezier
  23954. * @param nbPoints (integer) the wanted number of points in the curve
  23955. * @returns the created Curve3
  23956. */
  23957. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  23958. /**
  23959. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  23960. * @param p1 (Vector3) the origin point of the Hermite Spline
  23961. * @param t1 (Vector3) the tangent vector at the origin point
  23962. * @param p2 (Vector3) the end point of the Hermite Spline
  23963. * @param t2 (Vector3) the tangent vector at the end point
  23964. * @param nbPoints (integer) the wanted number of points in the curve
  23965. * @returns the created Curve3
  23966. */
  23967. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  23968. /**
  23969. * Returns a Curve3 object along a CatmullRom Spline curve :
  23970. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  23971. * @param nbPoints (integer) the wanted number of points between each curve control points
  23972. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  23973. * @returns the created Curve3
  23974. */
  23975. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  23976. /**
  23977. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23978. * A Curve3 is designed from a series of successive Vector3.
  23979. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  23980. * @param points points which make up the curve
  23981. */
  23982. constructor(points: Vector3[]);
  23983. /**
  23984. * @returns the Curve3 stored array of successive Vector3
  23985. */
  23986. getPoints(): Vector3[];
  23987. /**
  23988. * @returns the computed length (float) of the curve.
  23989. */
  23990. length(): number;
  23991. /**
  23992. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  23993. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  23994. * curveA and curveB keep unchanged.
  23995. * @param curve the curve to continue from this curve
  23996. * @returns the newly constructed curve
  23997. */
  23998. continue(curve: DeepImmutable<Curve3>): Curve3;
  23999. private _computeLength;
  24000. }
  24001. /**
  24002. * Contains position and normal vectors for a vertex
  24003. */
  24004. class PositionNormalVertex {
  24005. /** the position of the vertex (defaut: 0,0,0) */
  24006. position: Vector3;
  24007. /** the normal of the vertex (defaut: 0,1,0) */
  24008. normal: Vector3;
  24009. /**
  24010. * Creates a PositionNormalVertex
  24011. * @param position the position of the vertex (defaut: 0,0,0)
  24012. * @param normal the normal of the vertex (defaut: 0,1,0)
  24013. */
  24014. constructor(
  24015. /** the position of the vertex (defaut: 0,0,0) */
  24016. position?: Vector3,
  24017. /** the normal of the vertex (defaut: 0,1,0) */
  24018. normal?: Vector3);
  24019. /**
  24020. * Clones the PositionNormalVertex
  24021. * @returns the cloned PositionNormalVertex
  24022. */
  24023. clone(): PositionNormalVertex;
  24024. }
  24025. /**
  24026. * Contains position, normal and uv vectors for a vertex
  24027. */
  24028. class PositionNormalTextureVertex {
  24029. /** the position of the vertex (defaut: 0,0,0) */
  24030. position: Vector3;
  24031. /** the normal of the vertex (defaut: 0,1,0) */
  24032. normal: Vector3;
  24033. /** the uv of the vertex (default: 0,0) */
  24034. uv: Vector2;
  24035. /**
  24036. * Creates a PositionNormalTextureVertex
  24037. * @param position the position of the vertex (defaut: 0,0,0)
  24038. * @param normal the normal of the vertex (defaut: 0,1,0)
  24039. * @param uv the uv of the vertex (default: 0,0)
  24040. */
  24041. constructor(
  24042. /** the position of the vertex (defaut: 0,0,0) */
  24043. position?: Vector3,
  24044. /** the normal of the vertex (defaut: 0,1,0) */
  24045. normal?: Vector3,
  24046. /** the uv of the vertex (default: 0,0) */
  24047. uv?: Vector2);
  24048. /**
  24049. * Clones the PositionNormalTextureVertex
  24050. * @returns the cloned PositionNormalTextureVertex
  24051. */
  24052. clone(): PositionNormalTextureVertex;
  24053. }
  24054. /**
  24055. * @hidden
  24056. */
  24057. class Tmp {
  24058. static Color3: Color3[];
  24059. static Color4: Color4[];
  24060. static Vector2: Vector2[];
  24061. static Vector3: Vector3[];
  24062. static Vector4: Vector4[];
  24063. static Quaternion: Quaternion[];
  24064. static Matrix: Matrix[];
  24065. }
  24066. }
  24067. declare module BABYLON {
  24068. /**
  24069. * Class representing spherical polynomial coefficients to the 3rd degree
  24070. */
  24071. class SphericalPolynomial {
  24072. /**
  24073. * The x coefficients of the spherical polynomial
  24074. */
  24075. x: Vector3;
  24076. /**
  24077. * The y coefficients of the spherical polynomial
  24078. */
  24079. y: Vector3;
  24080. /**
  24081. * The z coefficients of the spherical polynomial
  24082. */
  24083. z: Vector3;
  24084. /**
  24085. * The xx coefficients of the spherical polynomial
  24086. */
  24087. xx: Vector3;
  24088. /**
  24089. * The yy coefficients of the spherical polynomial
  24090. */
  24091. yy: Vector3;
  24092. /**
  24093. * The zz coefficients of the spherical polynomial
  24094. */
  24095. zz: Vector3;
  24096. /**
  24097. * The xy coefficients of the spherical polynomial
  24098. */
  24099. xy: Vector3;
  24100. /**
  24101. * The yz coefficients of the spherical polynomial
  24102. */
  24103. yz: Vector3;
  24104. /**
  24105. * The zx coefficients of the spherical polynomial
  24106. */
  24107. zx: Vector3;
  24108. /**
  24109. * Adds an ambient color to the spherical polynomial
  24110. * @param color the color to add
  24111. */
  24112. addAmbient(color: Color3): void;
  24113. /**
  24114. * Scales the spherical polynomial by the given amount
  24115. * @param scale the amount to scale
  24116. */
  24117. scale(scale: number): void;
  24118. /**
  24119. * Gets the spherical polynomial from harmonics
  24120. * @param harmonics the spherical harmonics
  24121. * @returns the spherical polynomial
  24122. */
  24123. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  24124. /**
  24125. * Constructs a spherical polynomial from an array.
  24126. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  24127. * @returns the spherical polynomial
  24128. */
  24129. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  24130. }
  24131. /**
  24132. * Class representing spherical harmonics coefficients to the 3rd degree
  24133. */
  24134. class SphericalHarmonics {
  24135. /**
  24136. * The l0,0 coefficients of the spherical harmonics
  24137. */
  24138. l00: Vector3;
  24139. /**
  24140. * The l1,-1 coefficients of the spherical harmonics
  24141. */
  24142. l1_1: Vector3;
  24143. /**
  24144. * The l1,0 coefficients of the spherical harmonics
  24145. */
  24146. l10: Vector3;
  24147. /**
  24148. * The l1,1 coefficients of the spherical harmonics
  24149. */
  24150. l11: Vector3;
  24151. /**
  24152. * The l2,-2 coefficients of the spherical harmonics
  24153. */
  24154. l2_2: Vector3;
  24155. /**
  24156. * The l2,-1 coefficients of the spherical harmonics
  24157. */
  24158. l2_1: Vector3;
  24159. /**
  24160. * The l2,0 coefficients of the spherical harmonics
  24161. */
  24162. l20: Vector3;
  24163. /**
  24164. * The l2,1 coefficients of the spherical harmonics
  24165. */
  24166. l21: Vector3;
  24167. /**
  24168. * The l2,2 coefficients of the spherical harmonics
  24169. */
  24170. lL22: Vector3;
  24171. /**
  24172. * Adds a light to the spherical harmonics
  24173. * @param direction the direction of the light
  24174. * @param color the color of the light
  24175. * @param deltaSolidAngle the delta solid angle of the light
  24176. */
  24177. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  24178. /**
  24179. * Scales the spherical harmonics by the given amount
  24180. * @param scale the amount to scale
  24181. */
  24182. scale(scale: number): void;
  24183. /**
  24184. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  24185. *
  24186. * ```
  24187. * E_lm = A_l * L_lm
  24188. * ```
  24189. *
  24190. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  24191. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  24192. * the scaling factors are given in equation 9.
  24193. */
  24194. convertIncidentRadianceToIrradiance(): void;
  24195. /**
  24196. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  24197. *
  24198. * ```
  24199. * L = (1/pi) * E * rho
  24200. * ```
  24201. *
  24202. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  24203. */
  24204. convertIrradianceToLambertianRadiance(): void;
  24205. /**
  24206. * Gets the spherical harmonics from polynomial
  24207. * @param polynomial the spherical polynomial
  24208. * @returns the spherical harmonics
  24209. */
  24210. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  24211. /**
  24212. * Constructs a spherical harmonics from an array.
  24213. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  24214. * @returns the spherical harmonics
  24215. */
  24216. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  24217. }
  24218. }
  24219. declare module BABYLON {
  24220. /**
  24221. * Class used to store all common mesh properties
  24222. */
  24223. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24224. /** No occlusion */
  24225. static OCCLUSION_TYPE_NONE: number;
  24226. /** Occlusion set to optimisitic */
  24227. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24228. /** Occlusion set to strict */
  24229. static OCCLUSION_TYPE_STRICT: number;
  24230. /** Use an accurante occlusion algorithm */
  24231. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24232. /** Use a conservative occlusion algorithm */
  24233. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24234. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  24235. static readonly CULLINGSTRATEGY_STANDARD: number;
  24236. /** Culling strategy with bounding sphere only and then frustum culling */
  24237. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24238. /**
  24239. * No billboard
  24240. */
  24241. static readonly BILLBOARDMODE_NONE: number;
  24242. /** Billboard on X axis */
  24243. static readonly BILLBOARDMODE_X: number;
  24244. /** Billboard on Y axis */
  24245. static readonly BILLBOARDMODE_Y: number;
  24246. /** Billboard on Z axis */
  24247. static readonly BILLBOARDMODE_Z: number;
  24248. /** Billboard on all axes */
  24249. static readonly BILLBOARDMODE_ALL: number;
  24250. private _facetData;
  24251. /** Gets ot sets the culling strategy to use to find visible meshes */
  24252. cullingStrategy: number;
  24253. /**
  24254. * Gets the number of facets in the mesh
  24255. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24256. */
  24257. readonly facetNb: number;
  24258. /**
  24259. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24260. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24261. */
  24262. partitioningSubdivisions: number;
  24263. /**
  24264. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24265. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24266. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24267. */
  24268. partitioningBBoxRatio: number;
  24269. /**
  24270. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24271. * Works only for updatable meshes.
  24272. * Doesn't work with multi-materials
  24273. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24274. */
  24275. mustDepthSortFacets: boolean;
  24276. /**
  24277. * The location (Vector3) where the facet depth sort must be computed from.
  24278. * By default, the active camera position.
  24279. * Used only when facet depth sort is enabled
  24280. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24281. */
  24282. facetDepthSortFrom: Vector3;
  24283. /**
  24284. * gets a boolean indicating if facetData is enabled
  24285. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24286. */
  24287. readonly isFacetDataEnabled: boolean;
  24288. /** @hidden */
  24289. _updateNonUniformScalingState(value: boolean): boolean;
  24290. /**
  24291. * An event triggered when this mesh collides with another one
  24292. */
  24293. onCollideObservable: Observable<AbstractMesh>;
  24294. private _onCollideObserver;
  24295. /** Set a function to call when this mesh collides with another one */
  24296. onCollide: () => void;
  24297. /**
  24298. * An event triggered when the collision's position changes
  24299. */
  24300. onCollisionPositionChangeObservable: Observable<Vector3>;
  24301. private _onCollisionPositionChangeObserver;
  24302. /** Set a function to call when the collision's position changes */
  24303. onCollisionPositionChange: () => void;
  24304. /**
  24305. * An event triggered when material is changed
  24306. */
  24307. onMaterialChangedObservable: Observable<AbstractMesh>;
  24308. /**
  24309. * Gets or sets the orientation for POV movement & rotation
  24310. */
  24311. definedFacingForward: boolean;
  24312. /** @hidden */
  24313. _occlusionQuery: Nullable<WebGLQuery>;
  24314. private _visibility;
  24315. /**
  24316. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24317. */
  24318. /**
  24319. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24320. */
  24321. visibility: number;
  24322. /** Gets or sets the alpha index used to sort transparent meshes
  24323. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24324. */
  24325. alphaIndex: number;
  24326. /**
  24327. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24328. */
  24329. isVisible: boolean;
  24330. /**
  24331. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24332. */
  24333. isPickable: boolean;
  24334. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24335. showSubMeshesBoundingBox: boolean;
  24336. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24337. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24338. */
  24339. isBlocker: boolean;
  24340. /**
  24341. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24342. */
  24343. enablePointerMoveEvents: boolean;
  24344. /**
  24345. * Specifies the rendering group id for this mesh (0 by default)
  24346. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24347. */
  24348. renderingGroupId: number;
  24349. private _material;
  24350. /** Gets or sets current material */
  24351. material: Nullable<Material>;
  24352. private _receiveShadows;
  24353. /**
  24354. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24355. * @see http://doc.babylonjs.com/babylon101/shadows
  24356. */
  24357. receiveShadows: boolean;
  24358. /** Defines color to use when rendering outline */
  24359. outlineColor: Color3;
  24360. /** Define width to use when rendering outline */
  24361. outlineWidth: number;
  24362. /** Defines color to use when rendering overlay */
  24363. overlayColor: Color3;
  24364. /** Defines alpha to use when rendering overlay */
  24365. overlayAlpha: number;
  24366. private _hasVertexAlpha;
  24367. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24368. hasVertexAlpha: boolean;
  24369. private _useVertexColors;
  24370. /** 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) */
  24371. useVertexColors: boolean;
  24372. private _computeBonesUsingShaders;
  24373. /**
  24374. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24375. */
  24376. computeBonesUsingShaders: boolean;
  24377. private _numBoneInfluencers;
  24378. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24379. numBoneInfluencers: number;
  24380. private _applyFog;
  24381. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24382. applyFog: boolean;
  24383. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24384. useOctreeForRenderingSelection: boolean;
  24385. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24386. useOctreeForPicking: boolean;
  24387. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24388. useOctreeForCollisions: boolean;
  24389. private _layerMask;
  24390. /**
  24391. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24392. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24393. */
  24394. layerMask: number;
  24395. /**
  24396. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24397. */
  24398. alwaysSelectAsActiveMesh: boolean;
  24399. /**
  24400. * Gets or sets the current action manager
  24401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24402. */
  24403. actionManager: Nullable<ActionManager>;
  24404. private _checkCollisions;
  24405. private _collisionMask;
  24406. private _collisionGroup;
  24407. /**
  24408. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24409. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24410. */
  24411. ellipsoid: Vector3;
  24412. /**
  24413. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24414. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24415. */
  24416. ellipsoidOffset: Vector3;
  24417. private _collider;
  24418. private _oldPositionForCollisions;
  24419. private _diffPositionForCollisions;
  24420. /**
  24421. * Gets or sets a collision mask used to mask collisions (default is -1).
  24422. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24423. */
  24424. collisionMask: number;
  24425. /**
  24426. * Gets or sets the current collision group mask (-1 by default).
  24427. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24428. */
  24429. collisionGroup: number;
  24430. /**
  24431. * Defines edge width used when edgesRenderer is enabled
  24432. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24433. */
  24434. edgesWidth: number;
  24435. /**
  24436. * Defines edge color used when edgesRenderer is enabled
  24437. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24438. */
  24439. edgesColor: Color4;
  24440. /** @hidden */
  24441. _edgesRenderer: Nullable<IEdgesRenderer>;
  24442. /** @hidden */
  24443. _masterMesh: Nullable<AbstractMesh>;
  24444. /** @hidden */
  24445. _boundingInfo: Nullable<BoundingInfo>;
  24446. /** @hidden */
  24447. _renderId: number;
  24448. /**
  24449. * Gets or sets the list of subMeshes
  24450. * @see http://doc.babylonjs.com/how_to/multi_materials
  24451. */
  24452. subMeshes: SubMesh[];
  24453. /** @hidden */
  24454. _intersectionsInProgress: AbstractMesh[];
  24455. /** @hidden */
  24456. _unIndexed: boolean;
  24457. /** @hidden */
  24458. _lightSources: Light[];
  24459. /** @hidden */
  24460. readonly _positions: Nullable<Vector3[]>;
  24461. /** @hidden */
  24462. _waitingActions: any;
  24463. /** @hidden */
  24464. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24465. private _skeleton;
  24466. /** @hidden */
  24467. _bonesTransformMatrices: Nullable<Float32Array>;
  24468. /**
  24469. * Gets or sets a skeleton to apply skining transformations
  24470. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24471. */
  24472. skeleton: Nullable<Skeleton>;
  24473. /**
  24474. * An event triggered when the mesh is rebuilt.
  24475. */
  24476. onRebuildObservable: Observable<AbstractMesh>;
  24477. /**
  24478. * Creates a new AbstractMesh
  24479. * @param name defines the name of the mesh
  24480. * @param scene defines the hosting scene
  24481. */
  24482. constructor(name: string, scene?: Nullable<Scene>);
  24483. /**
  24484. * Returns the string "AbstractMesh"
  24485. * @returns "AbstractMesh"
  24486. */
  24487. getClassName(): string;
  24488. /**
  24489. * Gets a string representation of the current mesh
  24490. * @param fullDetails defines a boolean indicating if full details must be included
  24491. * @returns a string representation of the current mesh
  24492. */
  24493. toString(fullDetails?: boolean): string;
  24494. /** @hidden */
  24495. _rebuild(): void;
  24496. /** @hidden */
  24497. _resyncLightSources(): void;
  24498. /** @hidden */
  24499. _resyncLighSource(light: Light): void;
  24500. /** @hidden */
  24501. _unBindEffect(): void;
  24502. /** @hidden */
  24503. _removeLightSource(light: Light): void;
  24504. private _markSubMeshesAsDirty;
  24505. /** @hidden */
  24506. _markSubMeshesAsLightDirty(): void;
  24507. /** @hidden */
  24508. _markSubMeshesAsAttributesDirty(): void;
  24509. /** @hidden */
  24510. _markSubMeshesAsMiscDirty(): void;
  24511. /**
  24512. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24513. */
  24514. scaling: Vector3;
  24515. /**
  24516. * Returns true if the mesh is blocked. Implemented by child classes
  24517. */
  24518. readonly isBlocked: boolean;
  24519. /**
  24520. * Returns the mesh itself by default. Implemented by child classes
  24521. * @param camera defines the camera to use to pick the right LOD level
  24522. * @returns the currentAbstractMesh
  24523. */
  24524. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24525. /**
  24526. * Returns 0 by default. Implemented by child classes
  24527. * @returns an integer
  24528. */
  24529. getTotalVertices(): number;
  24530. /**
  24531. * Returns a positive integer : the total number of indices in this mesh geometry.
  24532. * @returns the numner of indices or zero if the mesh has no geometry.
  24533. */
  24534. getTotalIndices(): number;
  24535. /**
  24536. * Returns null by default. Implemented by child classes
  24537. * @returns null
  24538. */
  24539. getIndices(): Nullable<IndicesArray>;
  24540. /**
  24541. * Returns the array of the requested vertex data kind. Implemented by child classes
  24542. * @param kind defines the vertex data kind to use
  24543. * @returns null
  24544. */
  24545. getVerticesData(kind: string): Nullable<FloatArray>;
  24546. /**
  24547. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24548. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24549. * Note that a new underlying VertexBuffer object is created each call.
  24550. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24551. * @param kind defines vertex data kind:
  24552. * * BABYLON.VertexBuffer.PositionKind
  24553. * * BABYLON.VertexBuffer.UVKind
  24554. * * BABYLON.VertexBuffer.UV2Kind
  24555. * * BABYLON.VertexBuffer.UV3Kind
  24556. * * BABYLON.VertexBuffer.UV4Kind
  24557. * * BABYLON.VertexBuffer.UV5Kind
  24558. * * BABYLON.VertexBuffer.UV6Kind
  24559. * * BABYLON.VertexBuffer.ColorKind
  24560. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24561. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24562. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24563. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24564. * @param data defines the data source
  24565. * @param updatable defines if the data must be flagged as updatable (or static)
  24566. * @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
  24567. * @returns the current mesh
  24568. */
  24569. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24570. /**
  24571. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24572. * If the mesh has no geometry, it is simply returned as it is.
  24573. * @param kind defines vertex data kind:
  24574. * * BABYLON.VertexBuffer.PositionKind
  24575. * * BABYLON.VertexBuffer.UVKind
  24576. * * BABYLON.VertexBuffer.UV2Kind
  24577. * * BABYLON.VertexBuffer.UV3Kind
  24578. * * BABYLON.VertexBuffer.UV4Kind
  24579. * * BABYLON.VertexBuffer.UV5Kind
  24580. * * BABYLON.VertexBuffer.UV6Kind
  24581. * * BABYLON.VertexBuffer.ColorKind
  24582. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24583. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24584. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24585. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24586. * @param data defines the data source
  24587. * @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
  24588. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24589. * @returns the current mesh
  24590. */
  24591. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24592. /**
  24593. * Sets the mesh indices,
  24594. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24595. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24596. * @param totalVertices Defines the total number of vertices
  24597. * @returns the current mesh
  24598. */
  24599. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24600. /**
  24601. * Gets a boolean indicating if specific vertex data is present
  24602. * @param kind defines the vertex data kind to use
  24603. * @returns true is data kind is present
  24604. */
  24605. isVerticesDataPresent(kind: string): boolean;
  24606. /**
  24607. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24608. * @returns a BoundingInfo
  24609. */
  24610. getBoundingInfo(): BoundingInfo;
  24611. /**
  24612. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24613. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24614. * @returns the current mesh
  24615. */
  24616. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24617. /**
  24618. * Overwrite the current bounding info
  24619. * @param boundingInfo defines the new bounding info
  24620. * @returns the current mesh
  24621. */
  24622. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24623. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24624. readonly useBones: boolean;
  24625. /** @hidden */
  24626. _preActivate(): void;
  24627. /** @hidden */
  24628. _preActivateForIntermediateRendering(renderId: number): void;
  24629. /** @hidden */
  24630. _activate(renderId: number): void;
  24631. /**
  24632. * Gets the current world matrix
  24633. * @returns a Matrix
  24634. */
  24635. getWorldMatrix(): Matrix;
  24636. /** @hidden */
  24637. _getWorldMatrixDeterminant(): number;
  24638. /**
  24639. * Perform relative position change from the point of view of behind the front of the mesh.
  24640. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24641. * Supports definition of mesh facing forward or backward
  24642. * @param amountRight defines the distance on the right axis
  24643. * @param amountUp defines the distance on the up axis
  24644. * @param amountForward defines the distance on the forward axis
  24645. * @returns the current mesh
  24646. */
  24647. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24648. /**
  24649. * Calculate relative position change from the point of view of behind the front of the mesh.
  24650. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24651. * Supports definition of mesh facing forward or backward
  24652. * @param amountRight defines the distance on the right axis
  24653. * @param amountUp defines the distance on the up axis
  24654. * @param amountForward defines the distance on the forward axis
  24655. * @returns the new displacement vector
  24656. */
  24657. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24658. /**
  24659. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24660. * Supports definition of mesh facing forward or backward
  24661. * @param flipBack defines the flip
  24662. * @param twirlClockwise defines the twirl
  24663. * @param tiltRight defines the tilt
  24664. * @returns the current mesh
  24665. */
  24666. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24667. /**
  24668. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24669. * Supports definition of mesh facing forward or backward.
  24670. * @param flipBack defines the flip
  24671. * @param twirlClockwise defines the twirl
  24672. * @param tiltRight defines the tilt
  24673. * @returns the new rotation vector
  24674. */
  24675. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24676. /**
  24677. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24678. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24679. * @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
  24680. * @returns the new bounding vectors
  24681. */
  24682. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24683. min: Vector3;
  24684. max: Vector3;
  24685. };
  24686. /**
  24687. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24688. * This means the mesh underlying bounding box and sphere are recomputed.
  24689. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24690. * @returns the current mesh
  24691. */
  24692. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24693. /** @hidden */
  24694. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24695. /** @hidden */
  24696. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24697. /** @hidden */
  24698. _updateBoundingInfo(): AbstractMesh;
  24699. /** @hidden */
  24700. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  24701. /** @hidden */
  24702. protected _afterComputeWorldMatrix(): void;
  24703. /**
  24704. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24705. * A mesh is in the frustum if its bounding box intersects the frustum
  24706. * @param frustumPlanes defines the frustum to test
  24707. * @returns true if the mesh is in the frustum planes
  24708. */
  24709. isInFrustum(frustumPlanes: Plane[]): boolean;
  24710. /**
  24711. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24712. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24713. * @param frustumPlanes defines the frustum to test
  24714. * @returns true if the mesh is completely in the frustum planes
  24715. */
  24716. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24717. /**
  24718. * True if the mesh intersects another mesh or a SolidParticle object
  24719. * @param mesh defines a target mesh or SolidParticle to test
  24720. * @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)
  24721. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24722. * @returns true if there is an intersection
  24723. */
  24724. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24725. /**
  24726. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24727. * @param point defines the point to test
  24728. * @returns true if there is an intersection
  24729. */
  24730. intersectsPoint(point: Vector3): boolean;
  24731. /**
  24732. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24733. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24734. */
  24735. checkCollisions: boolean;
  24736. /**
  24737. * Gets Collider object used to compute collisions (not physics)
  24738. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24739. */
  24740. readonly collider: Collider;
  24741. /**
  24742. * Move the mesh using collision engine
  24743. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24744. * @param displacement defines the requested displacement vector
  24745. * @returns the current mesh
  24746. */
  24747. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24748. private _onCollisionPositionChange;
  24749. /** @hidden */
  24750. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24751. /** @hidden */
  24752. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24753. /** @hidden */
  24754. _checkCollision(collider: Collider): AbstractMesh;
  24755. /** @hidden */
  24756. _generatePointsArray(): boolean;
  24757. /**
  24758. * Checks if the passed Ray intersects with the mesh
  24759. * @param ray defines the ray to use
  24760. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24761. * @returns the picking info
  24762. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24763. */
  24764. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24765. /**
  24766. * Clones the current mesh
  24767. * @param name defines the mesh name
  24768. * @param newParent defines the new mesh parent
  24769. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24770. * @returns the new mesh
  24771. */
  24772. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24773. /**
  24774. * Disposes all the submeshes of the current meshnp
  24775. * @returns the current mesh
  24776. */
  24777. releaseSubMeshes(): AbstractMesh;
  24778. /**
  24779. * Releases resources associated with this abstract mesh.
  24780. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24781. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24782. */
  24783. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24784. /**
  24785. * Adds the passed mesh as a child to the current mesh
  24786. * @param mesh defines the child mesh
  24787. * @returns the current mesh
  24788. */
  24789. addChild(mesh: AbstractMesh): AbstractMesh;
  24790. /**
  24791. * Removes the passed mesh from the current mesh children list
  24792. * @param mesh defines the child mesh
  24793. * @returns the current mesh
  24794. */
  24795. removeChild(mesh: AbstractMesh): AbstractMesh;
  24796. /** @hidden */
  24797. private _initFacetData;
  24798. /**
  24799. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24800. * This method can be called within the render loop.
  24801. * 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
  24802. * @returns the current mesh
  24803. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24804. */
  24805. updateFacetData(): AbstractMesh;
  24806. /**
  24807. * Returns the facetLocalNormals array.
  24808. * The normals are expressed in the mesh local spac
  24809. * @returns an array of Vector3
  24810. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24811. */
  24812. getFacetLocalNormals(): Vector3[];
  24813. /**
  24814. * Returns the facetLocalPositions array.
  24815. * The facet positions are expressed in the mesh local space
  24816. * @returns an array of Vector3
  24817. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24818. */
  24819. getFacetLocalPositions(): Vector3[];
  24820. /**
  24821. * Returns the facetLocalPartioning array
  24822. * @returns an array of array of numbers
  24823. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24824. */
  24825. getFacetLocalPartitioning(): number[][];
  24826. /**
  24827. * Returns the i-th facet position in the world system.
  24828. * This method allocates a new Vector3 per call
  24829. * @param i defines the facet index
  24830. * @returns a new Vector3
  24831. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24832. */
  24833. getFacetPosition(i: number): Vector3;
  24834. /**
  24835. * Sets the reference Vector3 with the i-th facet position in the world system
  24836. * @param i defines the facet index
  24837. * @param ref defines the target vector
  24838. * @returns the current mesh
  24839. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24840. */
  24841. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24842. /**
  24843. * Returns the i-th facet normal in the world system.
  24844. * This method allocates a new Vector3 per call
  24845. * @param i defines the facet index
  24846. * @returns a new Vector3
  24847. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24848. */
  24849. getFacetNormal(i: number): Vector3;
  24850. /**
  24851. * Sets the reference Vector3 with the i-th facet normal in the world system
  24852. * @param i defines the facet index
  24853. * @param ref defines the target vector
  24854. * @returns the current mesh
  24855. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24856. */
  24857. getFacetNormalToRef(i: number, ref: Vector3): this;
  24858. /**
  24859. * 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)
  24860. * @param x defines x coordinate
  24861. * @param y defines y coordinate
  24862. * @param z defines z coordinate
  24863. * @returns the array of facet indexes
  24864. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24865. */
  24866. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24867. /**
  24868. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24869. * @param projected sets as the (x,y,z) world projection on the facet
  24870. * @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
  24871. * @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
  24872. * @param x defines x coordinate
  24873. * @param y defines y coordinate
  24874. * @param z defines z coordinate
  24875. * @returns the face index if found (or null instead)
  24876. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24877. */
  24878. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24879. /**
  24880. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24881. * @param projected sets as the (x,y,z) local projection on the facet
  24882. * @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
  24883. * @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
  24884. * @param x defines x coordinate
  24885. * @param y defines y coordinate
  24886. * @param z defines z coordinate
  24887. * @returns the face index if found (or null instead)
  24888. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24889. */
  24890. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24891. /**
  24892. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24893. * @returns the parameters
  24894. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24895. */
  24896. getFacetDataParameters(): any;
  24897. /**
  24898. * Disables the feature FacetData and frees the related memory
  24899. * @returns the current mesh
  24900. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24901. */
  24902. disableFacetData(): AbstractMesh;
  24903. /**
  24904. * Updates the AbstractMesh indices array
  24905. * @param indices defines the data source
  24906. * @returns the current mesh
  24907. */
  24908. updateIndices(indices: IndicesArray): AbstractMesh;
  24909. /**
  24910. * Creates new normals data for the mesh
  24911. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24912. * @returns the current mesh
  24913. */
  24914. createNormals(updatable: boolean): AbstractMesh;
  24915. /**
  24916. * Align the mesh with a normal
  24917. * @param normal defines the normal to use
  24918. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24919. * @returns the current mesh
  24920. */
  24921. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24922. /** @hidden */
  24923. _checkOcclusionQuery(): boolean;
  24924. }
  24925. }
  24926. declare module BABYLON {
  24927. /**
  24928. * Class used to store data that will be store in GPU memory
  24929. */
  24930. class Buffer {
  24931. private _engine;
  24932. private _buffer;
  24933. /** @hidden */
  24934. _data: Nullable<DataArray>;
  24935. private _updatable;
  24936. private _instanced;
  24937. /**
  24938. * Gets the byte stride.
  24939. */
  24940. readonly byteStride: number;
  24941. /**
  24942. * Constructor
  24943. * @param engine the engine
  24944. * @param data the data to use for this buffer
  24945. * @param updatable whether the data is updatable
  24946. * @param stride the stride (optional)
  24947. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24948. * @param instanced whether the buffer is instanced (optional)
  24949. * @param useBytes set to true if the stride in in bytes (optional)
  24950. */
  24951. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  24952. /**
  24953. * Create a new VertexBuffer based on the current buffer
  24954. * @param kind defines the vertex buffer kind (position, normal, etc.)
  24955. * @param offset defines offset in the buffer (0 by default)
  24956. * @param size defines the size in floats of attributes (position is 3 for instance)
  24957. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  24958. * @param instanced defines if the vertex buffer contains indexed data
  24959. * @param useBytes defines if the offset and stride are in bytes
  24960. * @returns the new vertex buffer
  24961. */
  24962. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  24963. /**
  24964. * Gets a boolean indicating if the Buffer is updatable?
  24965. * @returns true if the buffer is updatable
  24966. */
  24967. isUpdatable(): boolean;
  24968. /**
  24969. * Gets current buffer's data
  24970. * @returns a DataArray or null
  24971. */
  24972. getData(): Nullable<DataArray>;
  24973. /**
  24974. * Gets underlying native buffer
  24975. * @returns underlying native buffer
  24976. */
  24977. getBuffer(): Nullable<WebGLBuffer>;
  24978. /**
  24979. * Gets the stride in float32 units (i.e. byte stride / 4).
  24980. * May not be an integer if the byte stride is not divisible by 4.
  24981. * DEPRECATED. Use byteStride instead.
  24982. * @returns the stride in float32 units
  24983. */
  24984. getStrideSize(): number;
  24985. /**
  24986. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  24987. * @param data defines the data to store
  24988. */
  24989. create(data?: Nullable<DataArray>): void;
  24990. /** @hidden */
  24991. _rebuild(): void;
  24992. /**
  24993. * Update current buffer data
  24994. * @param data defines the data to store
  24995. */
  24996. update(data: DataArray): void;
  24997. /**
  24998. * Updates the data directly.
  24999. * @param data the new data
  25000. * @param offset the new offset
  25001. * @param vertexCount the vertex count (optional)
  25002. * @param useBytes set to true if the offset is in bytes
  25003. */
  25004. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  25005. /**
  25006. * Release all resources
  25007. */
  25008. dispose(): void;
  25009. }
  25010. }
  25011. declare module BABYLON {
  25012. /**
  25013. * Class for building Constructive Solid Geometry
  25014. */
  25015. class CSG {
  25016. private polygons;
  25017. /**
  25018. * The world matrix
  25019. */
  25020. matrix: Matrix;
  25021. /**
  25022. * Stores the position
  25023. */
  25024. position: Vector3;
  25025. /**
  25026. * Stores the rotation
  25027. */
  25028. rotation: Vector3;
  25029. /**
  25030. * Stores the rotation quaternion
  25031. */
  25032. rotationQuaternion: Nullable<Quaternion>;
  25033. /**
  25034. * Stores the scaling vector
  25035. */
  25036. scaling: Vector3;
  25037. /**
  25038. * Convert the BABYLON.Mesh to BABYLON.CSG
  25039. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  25040. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  25041. */
  25042. static FromMesh(mesh: Mesh): CSG;
  25043. /**
  25044. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  25045. * @param polygons Polygons used to construct a BABYLON.CSG solid
  25046. */
  25047. private static FromPolygons;
  25048. /**
  25049. * Clones, or makes a deep copy, of the BABYLON.CSG
  25050. * @returns A new BABYLON.CSG
  25051. */
  25052. clone(): CSG;
  25053. /**
  25054. * Unions this CSG with another CSG
  25055. * @param csg The CSG to union against this CSG
  25056. * @returns The unioned CSG
  25057. */
  25058. union(csg: CSG): CSG;
  25059. /**
  25060. * Unions this CSG with another CSG in place
  25061. * @param csg The CSG to union against this CSG
  25062. */
  25063. unionInPlace(csg: CSG): void;
  25064. /**
  25065. * Subtracts this CSG with another CSG
  25066. * @param csg The CSG to subtract against this CSG
  25067. * @returns A new BABYLON.CSG
  25068. */
  25069. subtract(csg: CSG): CSG;
  25070. /**
  25071. * Subtracts this CSG with another CSG in place
  25072. * @param csg The CSG to subtact against this CSG
  25073. */
  25074. subtractInPlace(csg: CSG): void;
  25075. /**
  25076. * Intersect this CSG with another CSG
  25077. * @param csg The CSG to intersect against this CSG
  25078. * @returns A new BABYLON.CSG
  25079. */
  25080. intersect(csg: CSG): CSG;
  25081. /**
  25082. * Intersects this CSG with another CSG in place
  25083. * @param csg The CSG to intersect against this CSG
  25084. */
  25085. intersectInPlace(csg: CSG): void;
  25086. /**
  25087. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  25088. * not modified.
  25089. * @returns A new BABYLON.CSG solid with solid and empty space switched
  25090. */
  25091. inverse(): CSG;
  25092. /**
  25093. * Inverses the BABYLON.CSG in place
  25094. */
  25095. inverseInPlace(): void;
  25096. /**
  25097. * This is used to keep meshes transformations so they can be restored
  25098. * when we build back a Babylon Mesh
  25099. * NB : All CSG operations are performed in world coordinates
  25100. * @param csg The BABYLON.CSG to copy the transform attributes from
  25101. * @returns This BABYLON.CSG
  25102. */
  25103. copyTransformAttributes(csg: CSG): CSG;
  25104. /**
  25105. * Build Raw mesh from CSG
  25106. * Coordinates here are in world space
  25107. * @param name The name of the mesh geometry
  25108. * @param scene The BABYLON.Scene
  25109. * @param keepSubMeshes Specifies if the submeshes should be kept
  25110. * @returns A new BABYLON.Mesh
  25111. */
  25112. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  25113. /**
  25114. * Build Mesh from CSG taking material and transforms into account
  25115. * @param name The name of the BABYLON.Mesh
  25116. * @param material The material of the BABYLON.Mesh
  25117. * @param scene The BABYLON.Scene
  25118. * @param keepSubMeshes Specifies if submeshes should be kept
  25119. * @returns The new BABYLON.Mesh
  25120. */
  25121. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  25122. }
  25123. }
  25124. declare module BABYLON {
  25125. /**
  25126. * Class used to store geometry data (vertex buffers + index buffer)
  25127. */
  25128. class Geometry implements IGetSetVerticesData {
  25129. /**
  25130. * Gets or sets the ID of the geometry
  25131. */
  25132. id: string;
  25133. /**
  25134. * Gets or sets the unique ID of the geometry
  25135. */
  25136. uniqueId: number;
  25137. /**
  25138. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25139. */
  25140. delayLoadState: number;
  25141. /**
  25142. * Gets the file containing the data to load when running in delay load state
  25143. */
  25144. delayLoadingFile: Nullable<string>;
  25145. /**
  25146. * Callback called when the geometry is updated
  25147. */
  25148. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25149. private _scene;
  25150. private _engine;
  25151. private _meshes;
  25152. private _totalVertices;
  25153. /** @hidden */
  25154. _indices: IndicesArray;
  25155. /** @hidden */
  25156. _vertexBuffers: {
  25157. [key: string]: VertexBuffer;
  25158. };
  25159. private _isDisposed;
  25160. private _extend;
  25161. private _boundingBias;
  25162. /** @hidden */
  25163. _delayInfo: Array<string>;
  25164. private _indexBuffer;
  25165. private _indexBufferIsUpdatable;
  25166. /** @hidden */
  25167. _boundingInfo: Nullable<BoundingInfo>;
  25168. /** @hidden */
  25169. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25170. /** @hidden */
  25171. _softwareSkinningFrameId: number;
  25172. private _vertexArrayObjects;
  25173. private _updatable;
  25174. /** @hidden */
  25175. _positions: Nullable<Vector3[]>;
  25176. /**
  25177. * 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
  25178. */
  25179. /**
  25180. * 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
  25181. */
  25182. boundingBias: Vector2;
  25183. /**
  25184. * Static function used to attach a new empty geometry to a mesh
  25185. * @param mesh defines the mesh to attach the geometry to
  25186. * @returns the new Geometry
  25187. */
  25188. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25189. /**
  25190. * Creates a new geometry
  25191. * @param id defines the unique ID
  25192. * @param scene defines the hosting scene
  25193. * @param vertexData defines the VertexData used to get geometry data
  25194. * @param updatable defines if geometry must be updatable (false by default)
  25195. * @param mesh defines the mesh that will be associated with the geometry
  25196. */
  25197. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25198. /**
  25199. * Gets the current extend of the geometry
  25200. */
  25201. readonly extend: {
  25202. minimum: Vector3;
  25203. maximum: Vector3;
  25204. };
  25205. /**
  25206. * Gets the hosting scene
  25207. * @returns the hosting Scene
  25208. */
  25209. getScene(): Scene;
  25210. /**
  25211. * Gets the hosting engine
  25212. * @returns the hosting Engine
  25213. */
  25214. getEngine(): Engine;
  25215. /**
  25216. * Defines if the geometry is ready to use
  25217. * @returns true if the geometry is ready to be used
  25218. */
  25219. isReady(): boolean;
  25220. /**
  25221. * Gets a value indicating that the geometry should not be serialized
  25222. */
  25223. readonly doNotSerialize: boolean;
  25224. /** @hidden */
  25225. _rebuild(): void;
  25226. /**
  25227. * Affects all geometry data in one call
  25228. * @param vertexData defines the geometry data
  25229. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25230. */
  25231. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25232. /**
  25233. * Set specific vertex data
  25234. * @param kind defines the data kind (Position, normal, etc...)
  25235. * @param data defines the vertex data to use
  25236. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25237. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25238. */
  25239. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25240. /**
  25241. * Removes a specific vertex data
  25242. * @param kind defines the data kind (Position, normal, etc...)
  25243. */
  25244. removeVerticesData(kind: string): void;
  25245. /**
  25246. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25247. * @param buffer defines the vertex buffer to use
  25248. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25249. */
  25250. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25251. /**
  25252. * Update a specific vertex buffer
  25253. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25254. * It will do nothing if the buffer is not updatable
  25255. * @param kind defines the data kind (Position, normal, etc...)
  25256. * @param data defines the data to use
  25257. * @param offset defines the offset in the target buffer where to store the data
  25258. * @param useBytes set to true if the offset is in bytes
  25259. */
  25260. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25261. /**
  25262. * Update a specific vertex buffer
  25263. * This function will create a new buffer if the current one is not updatable
  25264. * @param kind defines the data kind (Position, normal, etc...)
  25265. * @param data defines the data to use
  25266. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25267. */
  25268. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25269. private _updateBoundingInfo;
  25270. /** @hidden */
  25271. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25272. /**
  25273. * Gets total number of vertices
  25274. * @returns the total number of vertices
  25275. */
  25276. getTotalVertices(): number;
  25277. /**
  25278. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25279. * @param kind defines the data kind (Position, normal, etc...)
  25280. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25281. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25282. * @returns a float array containing vertex data
  25283. */
  25284. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25285. /**
  25286. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25287. * @param kind defines the data kind (Position, normal, etc...)
  25288. * @returns true if the vertex buffer with the specified kind is updatable
  25289. */
  25290. isVertexBufferUpdatable(kind: string): boolean;
  25291. /**
  25292. * Gets a specific vertex buffer
  25293. * @param kind defines the data kind (Position, normal, etc...)
  25294. * @returns a VertexBuffer
  25295. */
  25296. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25297. /**
  25298. * Returns all vertex buffers
  25299. * @return an object holding all vertex buffers indexed by kind
  25300. */
  25301. getVertexBuffers(): Nullable<{
  25302. [key: string]: VertexBuffer;
  25303. }>;
  25304. /**
  25305. * Gets a boolean indicating if specific vertex buffer is present
  25306. * @param kind defines the data kind (Position, normal, etc...)
  25307. * @returns true if data is present
  25308. */
  25309. isVerticesDataPresent(kind: string): boolean;
  25310. /**
  25311. * Gets a list of all attached data kinds (Position, normal, etc...)
  25312. * @returns a list of string containing all kinds
  25313. */
  25314. getVerticesDataKinds(): string[];
  25315. /**
  25316. * Update index buffer
  25317. * @param indices defines the indices to store in the index buffer
  25318. * @param offset defines the offset in the target buffer where to store the data
  25319. */
  25320. updateIndices(indices: IndicesArray, offset?: number): void;
  25321. /**
  25322. * Creates a new index buffer
  25323. * @param indices defines the indices to store in the index buffer
  25324. * @param totalVertices defines the total number of vertices (could be null)
  25325. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25326. */
  25327. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25328. /**
  25329. * Return the total number of indices
  25330. * @returns the total number of indices
  25331. */
  25332. getTotalIndices(): number;
  25333. /**
  25334. * Gets the index buffer array
  25335. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25336. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25337. * @returns the index buffer array
  25338. */
  25339. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25340. /**
  25341. * Gets the index buffer
  25342. * @return the index buffer
  25343. */
  25344. getIndexBuffer(): Nullable<WebGLBuffer>;
  25345. /** @hidden */
  25346. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25347. /**
  25348. * Release the associated resources for a specific mesh
  25349. * @param mesh defines the source mesh
  25350. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25351. */
  25352. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25353. /**
  25354. * Apply current geometry to a given mesh
  25355. * @param mesh defines the mesh to apply geometry to
  25356. */
  25357. applyToMesh(mesh: Mesh): void;
  25358. private _updateExtend;
  25359. private _applyToMesh;
  25360. private notifyUpdate;
  25361. /**
  25362. * Load the geometry if it was flagged as delay loaded
  25363. * @param scene defines the hosting scene
  25364. * @param onLoaded defines a callback called when the geometry is loaded
  25365. */
  25366. load(scene: Scene, onLoaded?: () => void): void;
  25367. private _queueLoad;
  25368. /**
  25369. * Invert the geometry to move from a right handed system to a left handed one.
  25370. */
  25371. toLeftHanded(): void;
  25372. /** @hidden */
  25373. _resetPointsArrayCache(): void;
  25374. /** @hidden */
  25375. _generatePointsArray(): boolean;
  25376. /**
  25377. * Gets a value indicating if the geometry is disposed
  25378. * @returns true if the geometry was disposed
  25379. */
  25380. isDisposed(): boolean;
  25381. private _disposeVertexArrayObjects;
  25382. /**
  25383. * Free all associated resources
  25384. */
  25385. dispose(): void;
  25386. /**
  25387. * Clone the current geometry into a new geometry
  25388. * @param id defines the unique ID of the new geometry
  25389. * @returns a new geometry object
  25390. */
  25391. copy(id: string): Geometry;
  25392. /**
  25393. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25394. * @return a JSON representation of the current geometry data (without the vertices data)
  25395. */
  25396. serialize(): any;
  25397. private toNumberArray;
  25398. /**
  25399. * Serialize all vertices data into a JSON oject
  25400. * @returns a JSON representation of the current geometry data
  25401. */
  25402. serializeVerticeData(): any;
  25403. /**
  25404. * Extracts a clone of a mesh geometry
  25405. * @param mesh defines the source mesh
  25406. * @param id defines the unique ID of the new geometry object
  25407. * @returns the new geometry object
  25408. */
  25409. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25410. /**
  25411. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25412. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25413. * Be aware Math.random() could cause collisions, but:
  25414. * "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"
  25415. * @returns a string containing a new GUID
  25416. */
  25417. static RandomId(): string;
  25418. /** @hidden */
  25419. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25420. private static _CleanMatricesWeights;
  25421. /**
  25422. * Create a new geometry from persisted data (Using .babylon file format)
  25423. * @param parsedVertexData defines the persisted data
  25424. * @param scene defines the hosting scene
  25425. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25426. * @returns the new geometry object
  25427. */
  25428. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25429. }
  25430. /**
  25431. * Abstract class used to provide common services for all typed geometries
  25432. * @hidden
  25433. */
  25434. class _PrimitiveGeometry extends Geometry {
  25435. private _canBeRegenerated;
  25436. private _beingRegenerated;
  25437. /**
  25438. * Creates a new typed geometry
  25439. * @param id defines the unique ID of the geometry
  25440. * @param scene defines the hosting scene
  25441. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25442. * @param mesh defines the hosting mesh (can be null)
  25443. */
  25444. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25445. /**
  25446. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25447. * @returns true if the geometry can be regenerated
  25448. */
  25449. canBeRegenerated(): boolean;
  25450. /**
  25451. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25452. */
  25453. regenerate(): void;
  25454. /**
  25455. * Clone the geometry
  25456. * @param id defines the unique ID of the new geometry
  25457. * @returns the new geometry
  25458. */
  25459. asNewGeometry(id: string): Geometry;
  25460. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25461. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25462. /** @hidden */
  25463. _regenerateVertexData(): VertexData;
  25464. copy(id: string): Geometry;
  25465. serialize(): any;
  25466. }
  25467. /**
  25468. * Creates a ribbon geometry
  25469. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25470. */
  25471. class RibbonGeometry extends _PrimitiveGeometry {
  25472. /**
  25473. * Defines the array of paths to use
  25474. */
  25475. pathArray: Vector3[][];
  25476. /**
  25477. * Defines if the last and first points of each path in your pathArray must be joined
  25478. */
  25479. closeArray: boolean;
  25480. /**
  25481. * Defines if the last and first points of each path in your pathArray must be joined
  25482. */
  25483. closePath: boolean;
  25484. /**
  25485. * Defines the offset between points
  25486. */
  25487. offset: number;
  25488. /**
  25489. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25490. */
  25491. side: number;
  25492. /**
  25493. * Creates a ribbon geometry
  25494. * @param id defines the unique ID of the geometry
  25495. * @param scene defines the hosting scene
  25496. * @param pathArray defines the array of paths to use
  25497. * @param closeArray defines if the last path and the first path must be joined
  25498. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25499. * @param offset defines the offset between points
  25500. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25501. * @param mesh defines the hosting mesh (can be null)
  25502. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25503. */
  25504. constructor(id: string, scene: Scene,
  25505. /**
  25506. * Defines the array of paths to use
  25507. */
  25508. pathArray: Vector3[][],
  25509. /**
  25510. * Defines if the last and first points of each path in your pathArray must be joined
  25511. */
  25512. closeArray: boolean,
  25513. /**
  25514. * Defines if the last and first points of each path in your pathArray must be joined
  25515. */
  25516. closePath: boolean,
  25517. /**
  25518. * Defines the offset between points
  25519. */
  25520. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25521. /**
  25522. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25523. */
  25524. side?: number);
  25525. /** @hidden */
  25526. _regenerateVertexData(): VertexData;
  25527. copy(id: string): Geometry;
  25528. }
  25529. /**
  25530. * Creates a box geometry
  25531. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25532. */
  25533. class BoxGeometry extends _PrimitiveGeometry {
  25534. /**
  25535. * Defines the zise of the box (width, height and depth are the same)
  25536. */
  25537. size: number;
  25538. /**
  25539. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25540. */
  25541. side: number;
  25542. /**
  25543. * Creates a box geometry
  25544. * @param id defines the unique ID of the geometry
  25545. * @param scene defines the hosting scene
  25546. * @param size defines the zise of the box (width, height and depth are the same)
  25547. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25548. * @param mesh defines the hosting mesh (can be null)
  25549. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25550. */
  25551. constructor(id: string, scene: Scene,
  25552. /**
  25553. * Defines the zise of the box (width, height and depth are the same)
  25554. */
  25555. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25556. /**
  25557. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25558. */
  25559. side?: number);
  25560. /** @hidden */
  25561. _regenerateVertexData(): VertexData;
  25562. copy(id: string): Geometry;
  25563. serialize(): any;
  25564. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25565. }
  25566. /**
  25567. * Creates a sphere geometry
  25568. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25569. */
  25570. class SphereGeometry extends _PrimitiveGeometry {
  25571. /**
  25572. * Defines the number of segments to use to create the sphere
  25573. */
  25574. segments: number;
  25575. /**
  25576. * Defines the diameter of the sphere
  25577. */
  25578. diameter: number;
  25579. /**
  25580. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25581. */
  25582. side: number;
  25583. /**
  25584. * Create a new sphere geometry
  25585. * @param id defines the unique ID of the geometry
  25586. * @param scene defines the hosting scene
  25587. * @param segments defines the number of segments to use to create the sphere
  25588. * @param diameter defines the diameter of the sphere
  25589. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25590. * @param mesh defines the hosting mesh (can be null)
  25591. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25592. */
  25593. constructor(id: string, scene: Scene,
  25594. /**
  25595. * Defines the number of segments to use to create the sphere
  25596. */
  25597. segments: number,
  25598. /**
  25599. * Defines the diameter of the sphere
  25600. */
  25601. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25602. /**
  25603. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25604. */
  25605. side?: number);
  25606. /** @hidden */
  25607. _regenerateVertexData(): VertexData;
  25608. copy(id: string): Geometry;
  25609. serialize(): any;
  25610. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  25611. }
  25612. /**
  25613. * Creates a disc geometry
  25614. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25615. */
  25616. class DiscGeometry extends _PrimitiveGeometry {
  25617. /**
  25618. * Defines the radius of the disc
  25619. */
  25620. radius: number;
  25621. /**
  25622. * Defines the tesselation factor to apply to the disc
  25623. */
  25624. tessellation: number;
  25625. /**
  25626. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25627. */
  25628. side: number;
  25629. /**
  25630. * Creates a new disc geometry
  25631. * @param id defines the unique ID of the geometry
  25632. * @param scene defines the hosting scene
  25633. * @param radius defines the radius of the disc
  25634. * @param tessellation defines the tesselation factor to apply to the disc
  25635. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25636. * @param mesh defines the hosting mesh (can be null)
  25637. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25638. */
  25639. constructor(id: string, scene: Scene,
  25640. /**
  25641. * Defines the radius of the disc
  25642. */
  25643. radius: number,
  25644. /**
  25645. * Defines the tesselation factor to apply to the disc
  25646. */
  25647. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25648. /**
  25649. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25650. */
  25651. side?: number);
  25652. /** @hidden */
  25653. _regenerateVertexData(): VertexData;
  25654. copy(id: string): Geometry;
  25655. }
  25656. /**
  25657. * Creates a new cylinder geometry
  25658. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  25659. */
  25660. class CylinderGeometry extends _PrimitiveGeometry {
  25661. /**
  25662. * Defines the height of the cylinder
  25663. */
  25664. height: number;
  25665. /**
  25666. * Defines the diameter of the cylinder's top cap
  25667. */
  25668. diameterTop: number;
  25669. /**
  25670. * Defines the diameter of the cylinder's bottom cap
  25671. */
  25672. diameterBottom: number;
  25673. /**
  25674. * Defines the tessellation factor to apply to the cylinder
  25675. */
  25676. tessellation: number;
  25677. /**
  25678. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25679. */
  25680. subdivisions: number;
  25681. /**
  25682. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25683. */
  25684. side: number;
  25685. /**
  25686. * Creates a new cylinder geometry
  25687. * @param id defines the unique ID of the geometry
  25688. * @param scene defines the hosting scene
  25689. * @param height defines the height of the cylinder
  25690. * @param diameterTop defines the diameter of the cylinder's top cap
  25691. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  25692. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  25693. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  25694. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25695. * @param mesh defines the hosting mesh (can be null)
  25696. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25697. */
  25698. constructor(id: string, scene: Scene,
  25699. /**
  25700. * Defines the height of the cylinder
  25701. */
  25702. height: number,
  25703. /**
  25704. * Defines the diameter of the cylinder's top cap
  25705. */
  25706. diameterTop: number,
  25707. /**
  25708. * Defines the diameter of the cylinder's bottom cap
  25709. */
  25710. diameterBottom: number,
  25711. /**
  25712. * Defines the tessellation factor to apply to the cylinder
  25713. */
  25714. tessellation: number,
  25715. /**
  25716. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25717. */
  25718. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25719. /**
  25720. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25721. */
  25722. side?: number);
  25723. /** @hidden */
  25724. _regenerateVertexData(): VertexData;
  25725. copy(id: string): Geometry;
  25726. serialize(): any;
  25727. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25728. }
  25729. /**
  25730. * Creates a new torus geometry
  25731. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25732. */
  25733. class TorusGeometry extends _PrimitiveGeometry {
  25734. /**
  25735. * Defines the diameter of the torus
  25736. */
  25737. diameter: number;
  25738. /**
  25739. * Defines the thickness of the torus (ie. internal diameter)
  25740. */
  25741. thickness: number;
  25742. /**
  25743. * Defines the tesselation factor to apply to the torus
  25744. */
  25745. tessellation: number;
  25746. /**
  25747. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25748. */
  25749. side: number;
  25750. /**
  25751. * Creates a new torus geometry
  25752. * @param id defines the unique ID of the geometry
  25753. * @param scene defines the hosting scene
  25754. * @param diameter defines the diameter of the torus
  25755. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25756. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25757. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25758. * @param mesh defines the hosting mesh (can be null)
  25759. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25760. */
  25761. constructor(id: string, scene: Scene,
  25762. /**
  25763. * Defines the diameter of the torus
  25764. */
  25765. diameter: number,
  25766. /**
  25767. * Defines the thickness of the torus (ie. internal diameter)
  25768. */
  25769. thickness: number,
  25770. /**
  25771. * Defines the tesselation factor to apply to the torus
  25772. */
  25773. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25774. /**
  25775. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25776. */
  25777. side?: number);
  25778. /** @hidden */
  25779. _regenerateVertexData(): VertexData;
  25780. copy(id: string): Geometry;
  25781. serialize(): any;
  25782. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25783. }
  25784. /**
  25785. * Creates a new ground geometry
  25786. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25787. */
  25788. class GroundGeometry extends _PrimitiveGeometry {
  25789. /**
  25790. * Defines the width of the ground
  25791. */
  25792. width: number;
  25793. /**
  25794. * Defines the height of the ground
  25795. */
  25796. height: number;
  25797. /**
  25798. * Defines the subdivisions to apply to the ground
  25799. */
  25800. subdivisions: number;
  25801. /**
  25802. * Creates a new ground geometry
  25803. * @param id defines the unique ID of the geometry
  25804. * @param scene defines the hosting scene
  25805. * @param width defines the width of the ground
  25806. * @param height defines the height of the ground
  25807. * @param subdivisions defines the subdivisions to apply to the ground
  25808. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25809. * @param mesh defines the hosting mesh (can be null)
  25810. */
  25811. constructor(id: string, scene: Scene,
  25812. /**
  25813. * Defines the width of the ground
  25814. */
  25815. width: number,
  25816. /**
  25817. * Defines the height of the ground
  25818. */
  25819. height: number,
  25820. /**
  25821. * Defines the subdivisions to apply to the ground
  25822. */
  25823. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25824. /** @hidden */
  25825. _regenerateVertexData(): VertexData;
  25826. copy(id: string): Geometry;
  25827. serialize(): any;
  25828. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  25829. }
  25830. /**
  25831. * Creates a tiled ground geometry
  25832. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  25833. */
  25834. class TiledGroundGeometry extends _PrimitiveGeometry {
  25835. /**
  25836. * Defines the minimum value on X axis
  25837. */
  25838. xmin: number;
  25839. /**
  25840. * Defines the minimum value on Z axis
  25841. */
  25842. zmin: number;
  25843. /**
  25844. * Defines the maximum value on X axis
  25845. */
  25846. xmax: number;
  25847. /**
  25848. * Defines the maximum value on Z axis
  25849. */
  25850. zmax: number;
  25851. /**
  25852. * Defines the subdivisions to apply to the ground
  25853. */
  25854. subdivisions: {
  25855. w: number;
  25856. h: number;
  25857. };
  25858. /**
  25859. * Defines the precision to use when computing the tiles
  25860. */
  25861. precision: {
  25862. w: number;
  25863. h: number;
  25864. };
  25865. /**
  25866. * Creates a tiled ground geometry
  25867. * @param id defines the unique ID of the geometry
  25868. * @param scene defines the hosting scene
  25869. * @param xmin defines the minimum value on X axis
  25870. * @param zmin defines the minimum value on Z axis
  25871. * @param xmax defines the maximum value on X axis
  25872. * @param zmax defines the maximum value on Z axis
  25873. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  25874. * @param precision defines the precision to use when computing the tiles
  25875. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25876. * @param mesh defines the hosting mesh (can be null)
  25877. */
  25878. constructor(id: string, scene: Scene,
  25879. /**
  25880. * Defines the minimum value on X axis
  25881. */
  25882. xmin: number,
  25883. /**
  25884. * Defines the minimum value on Z axis
  25885. */
  25886. zmin: number,
  25887. /**
  25888. * Defines the maximum value on X axis
  25889. */
  25890. xmax: number,
  25891. /**
  25892. * Defines the maximum value on Z axis
  25893. */
  25894. zmax: number,
  25895. /**
  25896. * Defines the subdivisions to apply to the ground
  25897. */
  25898. subdivisions: {
  25899. w: number;
  25900. h: number;
  25901. },
  25902. /**
  25903. * Defines the precision to use when computing the tiles
  25904. */
  25905. precision: {
  25906. w: number;
  25907. h: number;
  25908. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25909. /** @hidden */
  25910. _regenerateVertexData(): VertexData;
  25911. copy(id: string): Geometry;
  25912. }
  25913. /**
  25914. * Creates a plane geometry
  25915. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  25916. */
  25917. class PlaneGeometry extends _PrimitiveGeometry {
  25918. /**
  25919. * Defines the size of the plane (width === height)
  25920. */
  25921. size: number;
  25922. /**
  25923. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25924. */
  25925. side: number;
  25926. /**
  25927. * Creates a plane geometry
  25928. * @param id defines the unique ID of the geometry
  25929. * @param scene defines the hosting scene
  25930. * @param size defines the size of the plane (width === height)
  25931. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25932. * @param mesh defines the hosting mesh (can be null)
  25933. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25934. */
  25935. constructor(id: string, scene: Scene,
  25936. /**
  25937. * Defines the size of the plane (width === height)
  25938. */
  25939. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25940. /**
  25941. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25942. */
  25943. side?: number);
  25944. /** @hidden */
  25945. _regenerateVertexData(): VertexData;
  25946. copy(id: string): Geometry;
  25947. serialize(): any;
  25948. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  25949. }
  25950. /**
  25951. * Creates a torus knot geometry
  25952. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  25953. */
  25954. class TorusKnotGeometry extends _PrimitiveGeometry {
  25955. /**
  25956. * Defines the radius of the torus knot
  25957. */
  25958. radius: number;
  25959. /**
  25960. * Defines the thickness of the torus knot tube
  25961. */
  25962. tube: number;
  25963. /**
  25964. * Defines the number of radial segments
  25965. */
  25966. radialSegments: number;
  25967. /**
  25968. * Defines the number of tubular segments
  25969. */
  25970. tubularSegments: number;
  25971. /**
  25972. * Defines the first number of windings
  25973. */
  25974. p: number;
  25975. /**
  25976. * Defines the second number of windings
  25977. */
  25978. q: number;
  25979. /**
  25980. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25981. */
  25982. side: number;
  25983. /**
  25984. * Creates a torus knot geometry
  25985. * @param id defines the unique ID of the geometry
  25986. * @param scene defines the hosting scene
  25987. * @param radius defines the radius of the torus knot
  25988. * @param tube defines the thickness of the torus knot tube
  25989. * @param radialSegments defines the number of radial segments
  25990. * @param tubularSegments defines the number of tubular segments
  25991. * @param p defines the first number of windings
  25992. * @param q defines the second number of windings
  25993. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25994. * @param mesh defines the hosting mesh (can be null)
  25995. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25996. */
  25997. constructor(id: string, scene: Scene,
  25998. /**
  25999. * Defines the radius of the torus knot
  26000. */
  26001. radius: number,
  26002. /**
  26003. * Defines the thickness of the torus knot tube
  26004. */
  26005. tube: number,
  26006. /**
  26007. * Defines the number of radial segments
  26008. */
  26009. radialSegments: number,
  26010. /**
  26011. * Defines the number of tubular segments
  26012. */
  26013. tubularSegments: number,
  26014. /**
  26015. * Defines the first number of windings
  26016. */
  26017. p: number,
  26018. /**
  26019. * Defines the second number of windings
  26020. */
  26021. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26022. /**
  26023. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26024. */
  26025. side?: number);
  26026. /** @hidden */
  26027. _regenerateVertexData(): VertexData;
  26028. copy(id: string): Geometry;
  26029. serialize(): any;
  26030. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  26031. }
  26032. }
  26033. declare module BABYLON {
  26034. /**
  26035. * Mesh representing the gorund
  26036. */
  26037. class GroundMesh extends Mesh {
  26038. /** If octree should be generated */
  26039. generateOctree: boolean;
  26040. private _heightQuads;
  26041. /** @hidden */
  26042. _subdivisionsX: number;
  26043. /** @hidden */
  26044. _subdivisionsY: number;
  26045. /** @hidden */
  26046. _width: number;
  26047. /** @hidden */
  26048. _height: number;
  26049. /** @hidden */
  26050. _minX: number;
  26051. /** @hidden */
  26052. _maxX: number;
  26053. /** @hidden */
  26054. _minZ: number;
  26055. /** @hidden */
  26056. _maxZ: number;
  26057. constructor(name: string, scene: Scene);
  26058. /**
  26059. * "GroundMesh"
  26060. * @returns "GroundMesh"
  26061. */
  26062. getClassName(): string;
  26063. /**
  26064. * The minimum of x and y subdivisions
  26065. */
  26066. readonly subdivisions: number;
  26067. /**
  26068. * X subdivisions
  26069. */
  26070. readonly subdivisionsX: number;
  26071. /**
  26072. * Y subdivisions
  26073. */
  26074. readonly subdivisionsY: number;
  26075. /**
  26076. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26077. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26078. * @param chunksCount the number of subdivisions for x and y
  26079. * @param octreeBlocksSize (Default: 32)
  26080. */
  26081. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26082. /**
  26083. * Returns a height (y) value in the Worl system :
  26084. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26085. * @param x x coordinate
  26086. * @param z z coordinate
  26087. * @returns the ground y position if (x, z) are outside the ground surface.
  26088. */
  26089. getHeightAtCoordinates(x: number, z: number): number;
  26090. /**
  26091. * Returns a normalized vector (Vector3) orthogonal to the ground
  26092. * at the ground coordinates (x, z) expressed in the World system.
  26093. * @param x x coordinate
  26094. * @param z z coordinate
  26095. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26096. */
  26097. getNormalAtCoordinates(x: number, z: number): Vector3;
  26098. /**
  26099. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26100. * at the ground coordinates (x, z) expressed in the World system.
  26101. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26102. * @param x x coordinate
  26103. * @param z z coordinate
  26104. * @param ref vector to store the result
  26105. * @returns the GroundMesh.
  26106. */
  26107. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26108. /**
  26109. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26110. * if the ground has been updated.
  26111. * This can be used in the render loop.
  26112. * @returns the GroundMesh.
  26113. */
  26114. updateCoordinateHeights(): GroundMesh;
  26115. private _getFacetAt;
  26116. private _initHeightQuads;
  26117. private _computeHeightQuads;
  26118. /**
  26119. * Serializes this ground mesh
  26120. * @param serializationObject object to write serialization to
  26121. */
  26122. serialize(serializationObject: any): void;
  26123. /**
  26124. * Parses a serialized ground mesh
  26125. * @param parsedMesh the serialized mesh
  26126. * @param scene the scene to create the ground mesh in
  26127. * @returns the created ground mesh
  26128. */
  26129. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26130. }
  26131. }
  26132. declare module BABYLON {
  26133. /**
  26134. * Creates an instance based on a source mesh.
  26135. */
  26136. class InstancedMesh extends AbstractMesh {
  26137. private _sourceMesh;
  26138. private _currentLOD;
  26139. /** @hidden */
  26140. _indexInSourceMeshInstanceArray: number;
  26141. constructor(name: string, source: Mesh);
  26142. /**
  26143. * Returns the string "InstancedMesh".
  26144. */
  26145. getClassName(): string;
  26146. /**
  26147. * If the source mesh receives shadows
  26148. */
  26149. readonly receiveShadows: boolean;
  26150. /**
  26151. * The material of the source mesh
  26152. */
  26153. readonly material: Nullable<Material>;
  26154. /**
  26155. * Visibility of the source mesh
  26156. */
  26157. readonly visibility: number;
  26158. /**
  26159. * Skeleton of the source mesh
  26160. */
  26161. readonly skeleton: Nullable<Skeleton>;
  26162. /**
  26163. * Rendering ground id of the source mesh
  26164. */
  26165. renderingGroupId: number;
  26166. /**
  26167. * Returns the total number of vertices (integer).
  26168. */
  26169. getTotalVertices(): number;
  26170. /**
  26171. * Returns a positive integer : the total number of indices in this mesh geometry.
  26172. * @returns the numner of indices or zero if the mesh has no geometry.
  26173. */
  26174. getTotalIndices(): number;
  26175. /**
  26176. * The source mesh of the instance
  26177. */
  26178. readonly sourceMesh: Mesh;
  26179. /**
  26180. * Is this node ready to be used/rendered
  26181. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26182. * @return {boolean} is it ready
  26183. */
  26184. isReady(completeCheck?: boolean): boolean;
  26185. /**
  26186. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26187. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  26188. * @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.
  26189. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  26190. */
  26191. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  26192. /**
  26193. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26194. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26195. * The `data` are either a numeric array either a Float32Array.
  26196. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  26197. * 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).
  26198. * Note that a new underlying VertexBuffer object is created each call.
  26199. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26200. *
  26201. * Possible `kind` values :
  26202. * - BABYLON.VertexBuffer.PositionKind
  26203. * - BABYLON.VertexBuffer.UVKind
  26204. * - BABYLON.VertexBuffer.UV2Kind
  26205. * - BABYLON.VertexBuffer.UV3Kind
  26206. * - BABYLON.VertexBuffer.UV4Kind
  26207. * - BABYLON.VertexBuffer.UV5Kind
  26208. * - BABYLON.VertexBuffer.UV6Kind
  26209. * - BABYLON.VertexBuffer.ColorKind
  26210. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26211. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26212. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26213. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26214. *
  26215. * Returns the Mesh.
  26216. */
  26217. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26218. /**
  26219. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26220. * If the mesh has no geometry, it is simply returned as it is.
  26221. * The `data` are either a numeric array either a Float32Array.
  26222. * No new underlying VertexBuffer object is created.
  26223. * 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.
  26224. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  26225. *
  26226. * Possible `kind` values :
  26227. * - BABYLON.VertexBuffer.PositionKind
  26228. * - BABYLON.VertexBuffer.UVKind
  26229. * - BABYLON.VertexBuffer.UV2Kind
  26230. * - BABYLON.VertexBuffer.UV3Kind
  26231. * - BABYLON.VertexBuffer.UV4Kind
  26232. * - BABYLON.VertexBuffer.UV5Kind
  26233. * - BABYLON.VertexBuffer.UV6Kind
  26234. * - BABYLON.VertexBuffer.ColorKind
  26235. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26236. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26237. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26238. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26239. *
  26240. * Returns the Mesh.
  26241. */
  26242. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26243. /**
  26244. * Sets the mesh indices.
  26245. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26246. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26247. * This method creates a new index buffer each call.
  26248. * Returns the Mesh.
  26249. */
  26250. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26251. /**
  26252. * Boolean : True if the mesh owns the requested kind of data.
  26253. */
  26254. isVerticesDataPresent(kind: string): boolean;
  26255. /**
  26256. * Returns an array of indices (IndicesArray).
  26257. */
  26258. getIndices(): Nullable<IndicesArray>;
  26259. readonly _positions: Nullable<Vector3[]>;
  26260. /**
  26261. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26262. * This means the mesh underlying bounding box and sphere are recomputed.
  26263. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26264. * @returns the current mesh
  26265. */
  26266. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  26267. /** @hidden */
  26268. _preActivate(): InstancedMesh;
  26269. /** @hidden */
  26270. _activate(renderId: number): InstancedMesh;
  26271. /**
  26272. * Returns the current associated LOD AbstractMesh.
  26273. */
  26274. getLOD(camera: Camera): AbstractMesh;
  26275. /** @hidden */
  26276. _syncSubMeshes(): InstancedMesh;
  26277. /** @hidden */
  26278. _generatePointsArray(): boolean;
  26279. /**
  26280. * Creates a new InstancedMesh from the current mesh.
  26281. * - name (string) : the cloned mesh name
  26282. * - newParent (optional Node) : the optional Node to parent the clone to.
  26283. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26284. *
  26285. * Returns the clone.
  26286. */
  26287. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26288. /**
  26289. * Disposes the InstancedMesh.
  26290. * Returns nothing.
  26291. */
  26292. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26293. }
  26294. }
  26295. declare module BABYLON {
  26296. /**
  26297. * Line mesh
  26298. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26299. */
  26300. class LinesMesh extends Mesh {
  26301. /**
  26302. * If vertex color should be applied to the mesh
  26303. */
  26304. useVertexColor?: boolean | undefined;
  26305. /**
  26306. * If vertex alpha should be applied to the mesh
  26307. */
  26308. useVertexAlpha?: boolean | undefined;
  26309. /**
  26310. * Color of the line (Default: White)
  26311. */
  26312. color: Color3;
  26313. /**
  26314. * Alpha of the line (Default: 1)
  26315. */
  26316. alpha: number;
  26317. /**
  26318. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26319. * This margin is expressed in world space coordinates, so its value may vary.
  26320. * Default value is 0.1
  26321. */
  26322. intersectionThreshold: number;
  26323. private _colorShader;
  26324. /**
  26325. * Creates a new LinesMesh
  26326. * @param name defines the name
  26327. * @param scene defines the hosting scene
  26328. * @param parent defines the parent mesh if any
  26329. * @param source defines the optional source LinesMesh used to clone data from
  26330. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26331. * When false, achieved by calling a clone(), also passing False.
  26332. * This will make creation of children, recursive.
  26333. * @param useVertexColor defines if this LinesMesh supports vertex color
  26334. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26335. */
  26336. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26337. /**
  26338. * If vertex color should be applied to the mesh
  26339. */
  26340. useVertexColor?: boolean | undefined,
  26341. /**
  26342. * If vertex alpha should be applied to the mesh
  26343. */
  26344. useVertexAlpha?: boolean | undefined);
  26345. /**
  26346. * Returns the string "LineMesh"
  26347. */
  26348. getClassName(): string;
  26349. /**
  26350. * @hidden
  26351. */
  26352. /**
  26353. * @hidden
  26354. */
  26355. material: Material;
  26356. /**
  26357. * @hidden
  26358. */
  26359. readonly checkCollisions: boolean;
  26360. /** @hidden */
  26361. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26362. /** @hidden */
  26363. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26364. /**
  26365. * Disposes of the line mesh
  26366. * @param doNotRecurse If children should be disposed
  26367. */
  26368. dispose(doNotRecurse?: boolean): void;
  26369. /**
  26370. * Returns a new LineMesh object cloned from the current one.
  26371. */
  26372. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26373. /**
  26374. * Creates a new InstancedLinesMesh object from the mesh model.
  26375. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26376. * @param name defines the name of the new instance
  26377. * @returns a new InstancedLinesMesh
  26378. */
  26379. createInstance(name: string): InstancedLinesMesh;
  26380. }
  26381. /**
  26382. * Creates an instance based on a source LinesMesh
  26383. */
  26384. class InstancedLinesMesh extends InstancedMesh {
  26385. /**
  26386. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26387. * This margin is expressed in world space coordinates, so its value may vary.
  26388. * Initilized with the intersectionThreshold value of the source LinesMesh
  26389. */
  26390. intersectionThreshold: number;
  26391. constructor(name: string, source: LinesMesh);
  26392. /**
  26393. * Returns the string "InstancedLinesMesh".
  26394. */
  26395. getClassName(): string;
  26396. }
  26397. }
  26398. declare module BABYLON {
  26399. /**
  26400. * @hidden
  26401. **/
  26402. class _CreationDataStorage {
  26403. closePath?: boolean;
  26404. closeArray?: boolean;
  26405. idx: number[];
  26406. dashSize: number;
  26407. gapSize: number;
  26408. path3D: Path3D;
  26409. pathArray: Vector3[][];
  26410. arc: number;
  26411. radius: number;
  26412. cap: number;
  26413. tessellation: number;
  26414. }
  26415. /**
  26416. * @hidden
  26417. **/
  26418. class _InstanceDataStorage {
  26419. visibleInstances: any;
  26420. renderIdForInstances: number[];
  26421. batchCache: _InstancesBatch;
  26422. instancesBufferSize: number;
  26423. instancesBuffer: Nullable<Buffer>;
  26424. instancesData: Float32Array;
  26425. overridenInstanceCount: number;
  26426. }
  26427. /**
  26428. * @hidden
  26429. **/
  26430. class _InstancesBatch {
  26431. mustReturn: boolean;
  26432. visibleInstances: Nullable<InstancedMesh[]>[];
  26433. renderSelf: boolean[];
  26434. }
  26435. /**
  26436. * Class used to represent renderable models
  26437. */
  26438. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26439. /**
  26440. * Mesh side orientation : usually the external or front surface
  26441. */
  26442. static readonly FRONTSIDE: number;
  26443. /**
  26444. * Mesh side orientation : usually the internal or back surface
  26445. */
  26446. static readonly BACKSIDE: number;
  26447. /**
  26448. * Mesh side orientation : both internal and external or front and back surfaces
  26449. */
  26450. static readonly DOUBLESIDE: number;
  26451. /**
  26452. * Mesh side orientation : by default, `FRONTSIDE`
  26453. */
  26454. static readonly DEFAULTSIDE: number;
  26455. /**
  26456. * Mesh cap setting : no cap
  26457. */
  26458. static readonly NO_CAP: number;
  26459. /**
  26460. * Mesh cap setting : one cap at the beginning of the mesh
  26461. */
  26462. static readonly CAP_START: number;
  26463. /**
  26464. * Mesh cap setting : one cap at the end of the mesh
  26465. */
  26466. static readonly CAP_END: number;
  26467. /**
  26468. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26469. */
  26470. static readonly CAP_ALL: number;
  26471. private _onBeforeRenderObservable;
  26472. private _onAfterRenderObservable;
  26473. private _onBeforeDrawObservable;
  26474. /**
  26475. * An event triggered before rendering the mesh
  26476. */
  26477. readonly onBeforeRenderObservable: Observable<Mesh>;
  26478. /**
  26479. * An event triggered after rendering the mesh
  26480. */
  26481. readonly onAfterRenderObservable: Observable<Mesh>;
  26482. /**
  26483. * An event triggered before drawing the mesh
  26484. */
  26485. readonly onBeforeDrawObservable: Observable<Mesh>;
  26486. private _onBeforeDrawObserver;
  26487. /**
  26488. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26489. */
  26490. onBeforeDraw: () => void;
  26491. /**
  26492. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26493. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26494. */
  26495. delayLoadState: number;
  26496. /**
  26497. * Gets the list of instances created from this mesh
  26498. * it is not supposed to be modified manually.
  26499. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26500. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26501. */
  26502. instances: InstancedMesh[];
  26503. /**
  26504. * Gets the file containing delay loading data for this mesh
  26505. */
  26506. delayLoadingFile: string;
  26507. /** @hidden */
  26508. _binaryInfo: any;
  26509. private _LODLevels;
  26510. /**
  26511. * User defined function used to change how LOD level selection is done
  26512. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26513. */
  26514. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26515. private _morphTargetManager;
  26516. /**
  26517. * Gets or sets the morph target manager
  26518. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26519. */
  26520. morphTargetManager: Nullable<MorphTargetManager>;
  26521. /** @hidden */
  26522. _creationDataStorage: Nullable<_CreationDataStorage>;
  26523. /** @hidden */
  26524. _geometry: Nullable<Geometry>;
  26525. /** @hidden */
  26526. _delayInfo: Array<string>;
  26527. /** @hidden */
  26528. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26529. /** @hidden */
  26530. _instanceDataStorage: _InstanceDataStorage;
  26531. private _effectiveMaterial;
  26532. /** @hidden */
  26533. _shouldGenerateFlatShading: boolean;
  26534. private _preActivateId;
  26535. /** @hidden */
  26536. _originalBuilderSideOrientation: number;
  26537. /**
  26538. * Use this property to change the original side orientation defined at construction time
  26539. */
  26540. overrideMaterialSideOrientation: Nullable<number>;
  26541. private _areNormalsFrozen;
  26542. private _sourcePositions;
  26543. private _sourceNormals;
  26544. private _source;
  26545. private meshMap;
  26546. /**
  26547. * Gets the source mesh (the one used to clone this one from)
  26548. */
  26549. readonly source: Nullable<Mesh>;
  26550. /**
  26551. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26552. */
  26553. isUnIndexed: boolean;
  26554. /**
  26555. * @constructor
  26556. * @param name The value used by scene.getMeshByName() to do a lookup.
  26557. * @param scene The scene to add this mesh to.
  26558. * @param parent The parent of this mesh, if it has one
  26559. * @param source An optional Mesh from which geometry is shared, cloned.
  26560. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26561. * When false, achieved by calling a clone(), also passing False.
  26562. * This will make creation of children, recursive.
  26563. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26564. */
  26565. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26566. /**
  26567. * Gets the class name
  26568. * @returns the string "Mesh".
  26569. */
  26570. getClassName(): string;
  26571. /**
  26572. * Returns a description of this mesh
  26573. * @param fullDetails define if full details about this mesh must be used
  26574. * @returns a descriptive string representing this mesh
  26575. */
  26576. toString(fullDetails?: boolean): string;
  26577. /** @hidden */
  26578. _unBindEffect(): void;
  26579. /**
  26580. * Gets a boolean indicating if this mesh has LOD
  26581. */
  26582. readonly hasLODLevels: boolean;
  26583. /**
  26584. * Gets the list of MeshLODLevel associated with the current mesh
  26585. * @returns an array of MeshLODLevel
  26586. */
  26587. getLODLevels(): MeshLODLevel[];
  26588. private _sortLODLevels;
  26589. /**
  26590. * Add a mesh as LOD level triggered at the given distance.
  26591. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26592. * @param distance The distance from the center of the object to show this level
  26593. * @param mesh The mesh to be added as LOD level (can be null)
  26594. * @return This mesh (for chaining)
  26595. */
  26596. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26597. /**
  26598. * Returns the LOD level mesh at the passed distance or null if not found.
  26599. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26600. * @param distance The distance from the center of the object to show this level
  26601. * @returns a Mesh or `null`
  26602. */
  26603. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  26604. /**
  26605. * Remove a mesh from the LOD array
  26606. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26607. * @param mesh defines the mesh to be removed
  26608. * @return This mesh (for chaining)
  26609. */
  26610. removeLODLevel(mesh: Mesh): Mesh;
  26611. /**
  26612. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  26613. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26614. * @param camera defines the camera to use to compute distance
  26615. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  26616. * @return This mesh (for chaining)
  26617. */
  26618. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  26619. /**
  26620. * Gets the mesh internal Geometry object
  26621. */
  26622. readonly geometry: Nullable<Geometry>;
  26623. /**
  26624. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  26625. * @returns the total number of vertices
  26626. */
  26627. getTotalVertices(): number;
  26628. /**
  26629. * Returns the content of an associated vertex buffer
  26630. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26631. * - BABYLON.VertexBuffer.PositionKind
  26632. * - BABYLON.VertexBuffer.UVKind
  26633. * - BABYLON.VertexBuffer.UV2Kind
  26634. * - BABYLON.VertexBuffer.UV3Kind
  26635. * - BABYLON.VertexBuffer.UV4Kind
  26636. * - BABYLON.VertexBuffer.UV5Kind
  26637. * - BABYLON.VertexBuffer.UV6Kind
  26638. * - BABYLON.VertexBuffer.ColorKind
  26639. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26640. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26641. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26642. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26643. * @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
  26644. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  26645. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  26646. */
  26647. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26648. /**
  26649. * Returns the mesh VertexBuffer object from the requested `kind`
  26650. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26651. * - BABYLON.VertexBuffer.PositionKind
  26652. * - BABYLON.VertexBuffer.UVKind
  26653. * - BABYLON.VertexBuffer.UV2Kind
  26654. * - BABYLON.VertexBuffer.UV3Kind
  26655. * - BABYLON.VertexBuffer.UV4Kind
  26656. * - BABYLON.VertexBuffer.UV5Kind
  26657. * - BABYLON.VertexBuffer.UV6Kind
  26658. * - BABYLON.VertexBuffer.ColorKind
  26659. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26660. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26661. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26662. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26663. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  26664. */
  26665. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26666. /**
  26667. * Tests if a specific vertex buffer is associated with this mesh
  26668. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26669. * - BABYLON.VertexBuffer.PositionKind
  26670. * - BABYLON.VertexBuffer.UVKind
  26671. * - BABYLON.VertexBuffer.UV2Kind
  26672. * - BABYLON.VertexBuffer.UV3Kind
  26673. * - BABYLON.VertexBuffer.UV4Kind
  26674. * - BABYLON.VertexBuffer.UV5Kind
  26675. * - BABYLON.VertexBuffer.UV6Kind
  26676. * - BABYLON.VertexBuffer.ColorKind
  26677. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26678. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26679. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26680. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26681. * @returns a boolean
  26682. */
  26683. isVerticesDataPresent(kind: string): boolean;
  26684. /**
  26685. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  26686. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26687. * - BABYLON.VertexBuffer.PositionKind
  26688. * - BABYLON.VertexBuffer.UVKind
  26689. * - BABYLON.VertexBuffer.UV2Kind
  26690. * - BABYLON.VertexBuffer.UV3Kind
  26691. * - BABYLON.VertexBuffer.UV4Kind
  26692. * - BABYLON.VertexBuffer.UV5Kind
  26693. * - BABYLON.VertexBuffer.UV6Kind
  26694. * - BABYLON.VertexBuffer.ColorKind
  26695. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26696. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26697. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26698. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26699. * @returns a boolean
  26700. */
  26701. isVertexBufferUpdatable(kind: string): boolean;
  26702. /**
  26703. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26704. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26705. * - BABYLON.VertexBuffer.PositionKind
  26706. * - BABYLON.VertexBuffer.UVKind
  26707. * - BABYLON.VertexBuffer.UV2Kind
  26708. * - BABYLON.VertexBuffer.UV3Kind
  26709. * - BABYLON.VertexBuffer.UV4Kind
  26710. * - BABYLON.VertexBuffer.UV5Kind
  26711. * - BABYLON.VertexBuffer.UV6Kind
  26712. * - BABYLON.VertexBuffer.ColorKind
  26713. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26714. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26715. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26716. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26717. * @returns an array of strings
  26718. */
  26719. getVerticesDataKinds(): string[];
  26720. /**
  26721. * Returns a positive integer : the total number of indices in this mesh geometry.
  26722. * @returns the numner of indices or zero if the mesh has no geometry.
  26723. */
  26724. getTotalIndices(): number;
  26725. /**
  26726. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26727. * @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.
  26728. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26729. * @returns the indices array or an empty array if the mesh has no geometry
  26730. */
  26731. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26732. readonly isBlocked: boolean;
  26733. /**
  26734. * Determine if the current mesh is ready to be rendered
  26735. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26736. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26737. * @returns true if all associated assets are ready (material, textures, shaders)
  26738. */
  26739. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26740. /**
  26741. * 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.
  26742. */
  26743. readonly areNormalsFrozen: boolean;
  26744. /**
  26745. * 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.
  26746. * @returns the current mesh
  26747. */
  26748. freezeNormals(): Mesh;
  26749. /**
  26750. * 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
  26751. * @returns the current mesh
  26752. */
  26753. unfreezeNormals(): Mesh;
  26754. /**
  26755. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26756. */
  26757. overridenInstanceCount: number;
  26758. /** @hidden */
  26759. _preActivate(): Mesh;
  26760. /** @hidden */
  26761. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26762. /** @hidden */
  26763. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26764. /**
  26765. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26766. * This means the mesh underlying bounding box and sphere are recomputed.
  26767. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26768. * @returns the current mesh
  26769. */
  26770. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  26771. /** @hidden */
  26772. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26773. /**
  26774. * This function will subdivide the mesh into multiple submeshes
  26775. * @param count defines the expected number of submeshes
  26776. */
  26777. subdivide(count: number): void;
  26778. /**
  26779. * Copy a FloatArray into a specific associated vertex buffer
  26780. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26781. * - BABYLON.VertexBuffer.PositionKind
  26782. * - BABYLON.VertexBuffer.UVKind
  26783. * - BABYLON.VertexBuffer.UV2Kind
  26784. * - BABYLON.VertexBuffer.UV3Kind
  26785. * - BABYLON.VertexBuffer.UV4Kind
  26786. * - BABYLON.VertexBuffer.UV5Kind
  26787. * - BABYLON.VertexBuffer.UV6Kind
  26788. * - BABYLON.VertexBuffer.ColorKind
  26789. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26790. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26791. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26792. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26793. * @param data defines the data source
  26794. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26795. * @param stride defines the data stride size (can be null)
  26796. * @returns the current mesh
  26797. */
  26798. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26799. /**
  26800. * Flags an associated vertex buffer as updatable
  26801. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  26802. * - BABYLON.VertexBuffer.PositionKind
  26803. * - BABYLON.VertexBuffer.UVKind
  26804. * - BABYLON.VertexBuffer.UV2Kind
  26805. * - BABYLON.VertexBuffer.UV3Kind
  26806. * - BABYLON.VertexBuffer.UV4Kind
  26807. * - BABYLON.VertexBuffer.UV5Kind
  26808. * - BABYLON.VertexBuffer.UV6Kind
  26809. * - BABYLON.VertexBuffer.ColorKind
  26810. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26811. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26812. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26813. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26814. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26815. */
  26816. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  26817. /**
  26818. * Sets the mesh global Vertex Buffer
  26819. * @param buffer defines the buffer to use
  26820. * @returns the current mesh
  26821. */
  26822. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  26823. /**
  26824. * Update a specific associated vertex buffer
  26825. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26826. * - BABYLON.VertexBuffer.PositionKind
  26827. * - BABYLON.VertexBuffer.UVKind
  26828. * - BABYLON.VertexBuffer.UV2Kind
  26829. * - BABYLON.VertexBuffer.UV3Kind
  26830. * - BABYLON.VertexBuffer.UV4Kind
  26831. * - BABYLON.VertexBuffer.UV5Kind
  26832. * - BABYLON.VertexBuffer.UV6Kind
  26833. * - BABYLON.VertexBuffer.ColorKind
  26834. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26835. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26836. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26837. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26838. * @param data defines the data source
  26839. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26840. * @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)
  26841. * @returns the current mesh
  26842. */
  26843. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26844. /**
  26845. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  26846. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  26847. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  26848. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  26849. * @returns the current mesh
  26850. */
  26851. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  26852. /**
  26853. * Creates a un-shared specific occurence of the geometry for the mesh.
  26854. * @returns the current mesh
  26855. */
  26856. makeGeometryUnique(): Mesh;
  26857. /**
  26858. * Set the index buffer of this mesh
  26859. * @param indices defines the source data
  26860. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  26861. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  26862. * @returns the current mesh
  26863. */
  26864. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  26865. /**
  26866. * Update the current index buffer
  26867. * @param indices defines the source data
  26868. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26869. * @returns the current mesh
  26870. */
  26871. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  26872. /**
  26873. * Invert the geometry to move from a right handed system to a left handed one.
  26874. * @returns the current mesh
  26875. */
  26876. toLeftHanded(): Mesh;
  26877. /** @hidden */
  26878. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  26879. /** @hidden */
  26880. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  26881. /**
  26882. * Registers for this mesh a javascript function called just before the rendering process
  26883. * @param func defines the function to call before rendering this mesh
  26884. * @returns the current mesh
  26885. */
  26886. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26887. /**
  26888. * Disposes a previously registered javascript function called before the rendering
  26889. * @param func defines the function to remove
  26890. * @returns the current mesh
  26891. */
  26892. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26893. /**
  26894. * Registers for this mesh a javascript function called just after the rendering is complete
  26895. * @param func defines the function to call after rendering this mesh
  26896. * @returns the current mesh
  26897. */
  26898. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26899. /**
  26900. * Disposes a previously registered javascript function called after the rendering.
  26901. * @param func defines the function to remove
  26902. * @returns the current mesh
  26903. */
  26904. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26905. /** @hidden */
  26906. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  26907. /** @hidden */
  26908. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  26909. /** @hidden */
  26910. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  26911. /**
  26912. * 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
  26913. * @param subMesh defines the subMesh to render
  26914. * @param enableAlphaMode defines if alpha mode can be changed
  26915. * @returns the current mesh
  26916. */
  26917. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  26918. private _onBeforeDraw;
  26919. /**
  26920. * Renormalize the mesh and patch it up if there are no weights
  26921. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  26922. * However in the case of zero weights then we set just a single influence to 1.
  26923. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  26924. */
  26925. cleanMatrixWeights(): void;
  26926. private normalizeSkinFourWeights;
  26927. private normalizeSkinWeightsAndExtra;
  26928. /**
  26929. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  26930. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  26931. * the user know there was an issue with importing the mesh
  26932. * @returns a validation object with skinned, valid and report string
  26933. */
  26934. validateSkinning(): {
  26935. skinned: boolean;
  26936. valid: boolean;
  26937. report: string;
  26938. };
  26939. /** @hidden */
  26940. _checkDelayState(): Mesh;
  26941. private _queueLoad;
  26942. /**
  26943. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26944. * A mesh is in the frustum if its bounding box intersects the frustum
  26945. * @param frustumPlanes defines the frustum to test
  26946. * @returns true if the mesh is in the frustum planes
  26947. */
  26948. isInFrustum(frustumPlanes: Plane[]): boolean;
  26949. /**
  26950. * Sets the mesh material by the material or multiMaterial `id` property
  26951. * @param id is a string identifying the material or the multiMaterial
  26952. * @returns the current mesh
  26953. */
  26954. setMaterialByID(id: string): Mesh;
  26955. /**
  26956. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  26957. * @returns an array of IAnimatable
  26958. */
  26959. getAnimatables(): IAnimatable[];
  26960. /**
  26961. * Modifies the mesh geometry according to the passed transformation matrix.
  26962. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26963. * The mesh normals are modified using the same transformation.
  26964. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26965. * @param transform defines the transform matrix to use
  26966. * @see http://doc.babylonjs.com/resources/baking_transformations
  26967. * @returns the current mesh
  26968. */
  26969. bakeTransformIntoVertices(transform: Matrix): Mesh;
  26970. /**
  26971. * Modifies the mesh geometry according to its own current World Matrix.
  26972. * The mesh World Matrix is then reset.
  26973. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  26974. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26975. * @see http://doc.babylonjs.com/resources/baking_transformations
  26976. * @returns the current mesh
  26977. */
  26978. bakeCurrentTransformIntoVertices(): Mesh;
  26979. /** @hidden */
  26980. readonly _positions: Nullable<Vector3[]>;
  26981. /** @hidden */
  26982. _resetPointsArrayCache(): Mesh;
  26983. /** @hidden */
  26984. _generatePointsArray(): boolean;
  26985. /**
  26986. * Returns a new Mesh object generated from the current mesh properties.
  26987. * This method must not get confused with createInstance()
  26988. * @param name is a string, the name given to the new mesh
  26989. * @param newParent can be any Node object (default `null`)
  26990. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  26991. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  26992. * @returns a new mesh
  26993. */
  26994. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  26995. /**
  26996. * Releases resources associated with this mesh.
  26997. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26998. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26999. */
  27000. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27001. /**
  27002. * Modifies the mesh geometry according to a displacement map.
  27003. * 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.
  27004. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27005. * @param url is a string, the URL from the image file is to be downloaded.
  27006. * @param minHeight is the lower limit of the displacement.
  27007. * @param maxHeight is the upper limit of the displacement.
  27008. * @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.
  27009. * @param uvOffset is an optional vector2 used to offset UV.
  27010. * @param uvScale is an optional vector2 used to scale UV.
  27011. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  27012. * @returns the Mesh.
  27013. */
  27014. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27015. /**
  27016. * Modifies the mesh geometry according to a displacementMap buffer.
  27017. * 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.
  27018. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27019. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27020. * @param heightMapWidth is the width of the buffer image.
  27021. * @param heightMapHeight is the height of the buffer image.
  27022. * @param minHeight is the lower limit of the displacement.
  27023. * @param maxHeight is the upper limit of the displacement.
  27024. * @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.
  27025. * @param uvOffset is an optional vector2 used to offset UV.
  27026. * @param uvScale is an optional vector2 used to scale UV.
  27027. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  27028. * @returns the Mesh.
  27029. */
  27030. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27031. /**
  27032. * Modify the mesh to get a flat shading rendering.
  27033. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27034. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27035. * @returns current mesh
  27036. */
  27037. convertToFlatShadedMesh(): Mesh;
  27038. /**
  27039. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27040. * In other words, more vertices, no more indices and a single bigger VBO.
  27041. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27042. * @returns current mesh
  27043. */
  27044. convertToUnIndexedMesh(): Mesh;
  27045. /**
  27046. * Inverses facet orientations.
  27047. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27048. * @param flipNormals will also inverts the normals
  27049. * @returns current mesh
  27050. */
  27051. flipFaces(flipNormals?: boolean): Mesh;
  27052. /**
  27053. * Creates a new InstancedMesh object from the mesh model.
  27054. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27055. * @param name defines the name of the new instance
  27056. * @returns a new InstancedMesh
  27057. */
  27058. createInstance(name: string): InstancedMesh;
  27059. /**
  27060. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27061. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27062. * @returns the current mesh
  27063. */
  27064. synchronizeInstances(): Mesh;
  27065. /**
  27066. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27067. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27068. * This should be used together with the simplification to avoid disappearing triangles.
  27069. * @param successCallback an optional success callback to be called after the optimization finished.
  27070. * @returns the current mesh
  27071. */
  27072. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27073. /**
  27074. * Serialize current mesh
  27075. * @param serializationObject defines the object which will receive the serialization data
  27076. */
  27077. serialize(serializationObject: any): void;
  27078. /** @hidden */
  27079. _syncGeometryWithMorphTargetManager(): void;
  27080. /**
  27081. * Returns a new Mesh object parsed from the source provided.
  27082. * @param parsedMesh is the source
  27083. * @param scene defines the hosting scene
  27084. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27085. * @returns a new Mesh
  27086. */
  27087. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27088. /**
  27089. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27090. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27091. * @param name defines the name of the mesh to create
  27092. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27093. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27094. * @param closePath creates a seam between the first and the last points of each path of the path array
  27095. * @param offset is taken in account only if the `pathArray` is containing a single path
  27096. * @param scene defines the hosting scene
  27097. * @param updatable defines if the mesh must be flagged as updatable
  27098. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27099. * @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)
  27100. * @returns a new Mesh
  27101. */
  27102. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27103. /**
  27104. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27105. * @param name defines the name of the mesh to create
  27106. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27107. * @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
  27108. * @param scene defines the hosting scene
  27109. * @param updatable defines if the mesh must be flagged as updatable
  27110. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27111. * @returns a new Mesh
  27112. */
  27113. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27114. /**
  27115. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27116. * @param name defines the name of the mesh to create
  27117. * @param size sets the size (float) of each box side (default 1)
  27118. * @param scene defines the hosting scene
  27119. * @param updatable defines if the mesh must be flagged as updatable
  27120. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27121. * @returns a new Mesh
  27122. */
  27123. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27124. /**
  27125. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27126. * @param name defines the name of the mesh to create
  27127. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27128. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27129. * @param scene defines the hosting scene
  27130. * @param updatable defines if the mesh must be flagged as updatable
  27131. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27132. * @returns a new Mesh
  27133. */
  27134. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27135. /**
  27136. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27137. * @param name defines the name of the mesh to create
  27138. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27139. * @param diameterTop set the top cap diameter (floats, default 1)
  27140. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27141. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27142. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27143. * @param scene defines the hosting scene
  27144. * @param updatable defines if the mesh must be flagged as updatable
  27145. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27146. * @returns a new Mesh
  27147. */
  27148. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27149. /**
  27150. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27151. * @param name defines the name of the mesh to create
  27152. * @param diameter sets the diameter size (float) of the torus (default 1)
  27153. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27154. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27155. * @param scene defines the hosting scene
  27156. * @param updatable defines if the mesh must be flagged as updatable
  27157. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27158. * @returns a new Mesh
  27159. */
  27160. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27161. /**
  27162. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27163. * @param name defines the name of the mesh to create
  27164. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27165. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  27166. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  27167. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  27168. * @param p the number of windings on X axis (positive integers, default 2)
  27169. * @param q the number of windings on Y axis (positive integers, default 3)
  27170. * @param scene defines the hosting scene
  27171. * @param updatable defines if the mesh must be flagged as updatable
  27172. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27173. * @returns a new Mesh
  27174. */
  27175. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27176. /**
  27177. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  27178. * @param name defines the name of the mesh to create
  27179. * @param points is an array successive Vector3
  27180. * @param scene defines the hosting scene
  27181. * @param updatable defines if the mesh must be flagged as updatable
  27182. * @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).
  27183. * @returns a new Mesh
  27184. */
  27185. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  27186. /**
  27187. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  27188. * @param name defines the name of the mesh to create
  27189. * @param points is an array successive Vector3
  27190. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27191. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27192. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27193. * @param scene defines the hosting scene
  27194. * @param updatable defines if the mesh must be flagged as updatable
  27195. * @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)
  27196. * @returns a new Mesh
  27197. */
  27198. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27199. /**
  27200. * Creates a polygon mesh.
  27201. * Please consider using the same method from the MeshBuilder class instead.
  27202. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27203. * 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.
  27204. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27205. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27206. * Remember you can only change the shape positions, not their number when updating a polygon.
  27207. */
  27208. /**
  27209. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27210. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27211. * @param name defines the name of the mesh to create
  27212. * @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
  27213. * @param scene defines the hosting scene
  27214. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27215. * @param updatable defines if the mesh must be flagged as updatable
  27216. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27217. * @returns a new Mesh
  27218. */
  27219. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27220. /**
  27221. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  27222. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  27223. * @param name defines the name of the mesh to create
  27224. * @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
  27225. * @param depth defines the height of extrusion
  27226. * @param scene defines the hosting scene
  27227. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27228. * @param updatable defines if the mesh must be flagged as updatable
  27229. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27230. * @returns a new Mesh
  27231. */
  27232. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27233. /**
  27234. * Creates an extruded shape mesh.
  27235. * 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
  27236. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27237. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27238. * @param name defines the name of the mesh to create
  27239. * @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
  27240. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27241. * @param scale is the value to scale the shape
  27242. * @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
  27243. * @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
  27244. * @param scene defines the hosting scene
  27245. * @param updatable defines if the mesh must be flagged as updatable
  27246. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27247. * @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)
  27248. * @returns a new Mesh
  27249. */
  27250. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27251. /**
  27252. * Creates an custom extruded shape mesh.
  27253. * The custom extrusion is a parametric shape.
  27254. * It has no predefined shape. Its final shape will depend on the input parameters.
  27255. * Please consider using the same method from the MeshBuilder class instead
  27256. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27257. * @param name defines the name of the mesh to create
  27258. * @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
  27259. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27260. * @param scaleFunction is a custom Javascript function called on each path point
  27261. * @param rotationFunction is a custom Javascript function called on each path point
  27262. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27263. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27264. * @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
  27265. * @param scene defines the hosting scene
  27266. * @param updatable defines if the mesh must be flagged as updatable
  27267. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27268. * @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)
  27269. * @returns a new Mesh
  27270. */
  27271. 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;
  27272. /**
  27273. * Creates lathe mesh.
  27274. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27275. * Please consider using the same method from the MeshBuilder class instead
  27276. * @param name defines the name of the mesh to create
  27277. * @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
  27278. * @param radius is the radius value of the lathe
  27279. * @param tessellation is the side number of the lathe.
  27280. * @param scene defines the hosting scene
  27281. * @param updatable defines if the mesh must be flagged as updatable
  27282. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27283. * @returns a new Mesh
  27284. */
  27285. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27286. /**
  27287. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27288. * @param name defines the name of the mesh to create
  27289. * @param size sets the size (float) of both sides of the plane at once (default 1)
  27290. * @param scene defines the hosting scene
  27291. * @param updatable defines if the mesh must be flagged as updatable
  27292. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27293. * @returns a new Mesh
  27294. */
  27295. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27296. /**
  27297. * Creates a ground mesh.
  27298. * Please consider using the same method from the MeshBuilder class instead
  27299. * @param name defines the name of the mesh to create
  27300. * @param width set the width of the ground
  27301. * @param height set the height of the ground
  27302. * @param subdivisions sets the number of subdivisions per side
  27303. * @param scene defines the hosting scene
  27304. * @param updatable defines if the mesh must be flagged as updatable
  27305. * @returns a new Mesh
  27306. */
  27307. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27308. /**
  27309. * Creates a tiled ground mesh.
  27310. * Please consider using the same method from the MeshBuilder class instead
  27311. * @param name defines the name of the mesh to create
  27312. * @param xmin set the ground minimum X coordinate
  27313. * @param zmin set the ground minimum Y coordinate
  27314. * @param xmax set the ground maximum X coordinate
  27315. * @param zmax set the ground maximum Z coordinate
  27316. * @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
  27317. * @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
  27318. * @param scene defines the hosting scene
  27319. * @param updatable defines if the mesh must be flagged as updatable
  27320. * @returns a new Mesh
  27321. */
  27322. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27323. w: number;
  27324. h: number;
  27325. }, precision: {
  27326. w: number;
  27327. h: number;
  27328. }, scene: Scene, updatable?: boolean): Mesh;
  27329. /**
  27330. * Creates a ground mesh from a height map.
  27331. * Please consider using the same method from the MeshBuilder class instead
  27332. * @see http://doc.babylonjs.com/babylon101/height_map
  27333. * @param name defines the name of the mesh to create
  27334. * @param url sets the URL of the height map image resource
  27335. * @param width set the ground width size
  27336. * @param height set the ground height size
  27337. * @param subdivisions sets the number of subdivision per side
  27338. * @param minHeight is the minimum altitude on the ground
  27339. * @param maxHeight is the maximum altitude on the ground
  27340. * @param scene defines the hosting scene
  27341. * @param updatable defines if the mesh must be flagged as updatable
  27342. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27343. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27344. * @returns a new Mesh
  27345. */
  27346. 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;
  27347. /**
  27348. * Creates a tube mesh.
  27349. * The tube is a parametric shape.
  27350. * It has no predefined shape. Its final shape will depend on the input parameters.
  27351. * Please consider using the same method from the MeshBuilder class instead
  27352. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27353. * @param name defines the name of the mesh to create
  27354. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27355. * @param radius sets the tube radius size
  27356. * @param tessellation is the number of sides on the tubular surface
  27357. * @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
  27358. * @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
  27359. * @param scene defines the hosting scene
  27360. * @param updatable defines if the mesh must be flagged as updatable
  27361. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27362. * @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)
  27363. * @returns a new Mesh
  27364. */
  27365. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27366. (i: number, distance: number): number;
  27367. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27368. /**
  27369. * Creates a polyhedron mesh.
  27370. * Please consider using the same method from the MeshBuilder class instead.
  27371. * * 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
  27372. * * The parameter `size` (positive float, default 1) sets the polygon size
  27373. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27374. * * 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`
  27375. * * 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
  27376. * * 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)`)
  27377. * * 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
  27378. * * 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
  27379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27380. * * 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
  27381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27382. * @param name defines the name of the mesh to create
  27383. * @param options defines the options used to create the mesh
  27384. * @param scene defines the hosting scene
  27385. * @returns a new Mesh
  27386. */
  27387. static CreatePolyhedron(name: string, options: {
  27388. type?: number;
  27389. size?: number;
  27390. sizeX?: number;
  27391. sizeY?: number;
  27392. sizeZ?: number;
  27393. custom?: any;
  27394. faceUV?: Vector4[];
  27395. faceColors?: Color4[];
  27396. updatable?: boolean;
  27397. sideOrientation?: number;
  27398. }, scene: Scene): Mesh;
  27399. /**
  27400. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27401. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27402. * * 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`)
  27403. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27404. * * 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
  27405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27406. * * 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
  27407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27408. * @param name defines the name of the mesh
  27409. * @param options defines the options used to create the mesh
  27410. * @param scene defines the hosting scene
  27411. * @returns a new Mesh
  27412. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27413. */
  27414. static CreateIcoSphere(name: string, options: {
  27415. radius?: number;
  27416. flat?: boolean;
  27417. subdivisions?: number;
  27418. sideOrientation?: number;
  27419. updatable?: boolean;
  27420. }, scene: Scene): Mesh;
  27421. /**
  27422. * Creates a decal mesh.
  27423. * Please consider using the same method from the MeshBuilder class instead.
  27424. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27425. * @param name defines the name of the mesh
  27426. * @param sourceMesh defines the mesh receiving the decal
  27427. * @param position sets the position of the decal in world coordinates
  27428. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27429. * @param size sets the decal scaling
  27430. * @param angle sets the angle to rotate the decal
  27431. * @returns a new Mesh
  27432. */
  27433. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27434. /**
  27435. * Prepare internal position array for software CPU skinning
  27436. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27437. */
  27438. setPositionsForCPUSkinning(): Float32Array;
  27439. /**
  27440. * Prepare internal normal array for software CPU skinning
  27441. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27442. */
  27443. setNormalsForCPUSkinning(): Float32Array;
  27444. /**
  27445. * Updates the vertex buffer by applying transformation from the bones
  27446. * @param skeleton defines the skeleton to apply to current mesh
  27447. * @returns the current mesh
  27448. */
  27449. applySkeleton(skeleton: Skeleton): Mesh;
  27450. /**
  27451. * 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
  27452. * @param meshes defines the list of meshes to scan
  27453. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27454. */
  27455. static MinMax(meshes: AbstractMesh[]): {
  27456. min: Vector3;
  27457. max: Vector3;
  27458. };
  27459. /**
  27460. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27461. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27462. * @returns a vector3
  27463. */
  27464. static Center(meshesOrMinMaxVector: {
  27465. min: Vector3;
  27466. max: Vector3;
  27467. } | AbstractMesh[]): Vector3;
  27468. /**
  27469. * Merge the array of meshes into a single mesh for performance reasons.
  27470. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27471. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27472. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27473. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27474. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27475. * @returns a new mesh
  27476. */
  27477. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27478. /** @hidden */
  27479. addInstance(instance: InstancedMesh): void;
  27480. /** @hidden */
  27481. removeInstance(instance: InstancedMesh): void;
  27482. }
  27483. }
  27484. declare module BABYLON {
  27485. /**
  27486. * Define an interface for all classes that will get and set the data on vertices
  27487. */
  27488. interface IGetSetVerticesData {
  27489. /**
  27490. * Gets a boolean indicating if specific vertex data is present
  27491. * @param kind defines the vertex data kind to use
  27492. * @returns true is data kind is present
  27493. */
  27494. isVerticesDataPresent(kind: string): boolean;
  27495. /**
  27496. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27497. * @param kind defines the data kind (Position, normal, etc...)
  27498. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27499. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27500. * @returns a float array containing vertex data
  27501. */
  27502. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27503. /**
  27504. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27505. * @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.
  27506. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27507. * @returns the indices array or an empty array if the mesh has no geometry
  27508. */
  27509. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27510. /**
  27511. * Set specific vertex data
  27512. * @param kind defines the data kind (Position, normal, etc...)
  27513. * @param data defines the vertex data to use
  27514. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27515. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27516. */
  27517. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27518. /**
  27519. * Update a specific associated vertex buffer
  27520. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27521. * - BABYLON.VertexBuffer.PositionKind
  27522. * - BABYLON.VertexBuffer.UVKind
  27523. * - BABYLON.VertexBuffer.UV2Kind
  27524. * - BABYLON.VertexBuffer.UV3Kind
  27525. * - BABYLON.VertexBuffer.UV4Kind
  27526. * - BABYLON.VertexBuffer.UV5Kind
  27527. * - BABYLON.VertexBuffer.UV6Kind
  27528. * - BABYLON.VertexBuffer.ColorKind
  27529. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27530. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27531. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27532. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27533. * @param data defines the data source
  27534. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27535. * @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)
  27536. */
  27537. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27538. /**
  27539. * Creates a new index buffer
  27540. * @param indices defines the indices to store in the index buffer
  27541. * @param totalVertices defines the total number of vertices (could be null)
  27542. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27543. */
  27544. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27545. }
  27546. /**
  27547. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27548. */
  27549. class VertexData {
  27550. /**
  27551. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27552. */
  27553. positions: Nullable<FloatArray>;
  27554. /**
  27555. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27556. */
  27557. normals: Nullable<FloatArray>;
  27558. /**
  27559. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27560. */
  27561. tangents: Nullable<FloatArray>;
  27562. /**
  27563. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27564. */
  27565. uvs: Nullable<FloatArray>;
  27566. /**
  27567. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27568. */
  27569. uvs2: Nullable<FloatArray>;
  27570. /**
  27571. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27572. */
  27573. uvs3: Nullable<FloatArray>;
  27574. /**
  27575. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27576. */
  27577. uvs4: Nullable<FloatArray>;
  27578. /**
  27579. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27580. */
  27581. uvs5: Nullable<FloatArray>;
  27582. /**
  27583. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27584. */
  27585. uvs6: Nullable<FloatArray>;
  27586. /**
  27587. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27588. */
  27589. colors: Nullable<FloatArray>;
  27590. /**
  27591. * 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).
  27592. */
  27593. matricesIndices: Nullable<FloatArray>;
  27594. /**
  27595. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27596. */
  27597. matricesWeights: Nullable<FloatArray>;
  27598. /**
  27599. * An array extending the number of possible indices
  27600. */
  27601. matricesIndicesExtra: Nullable<FloatArray>;
  27602. /**
  27603. * An array extending the number of possible weights when the number of indices is extended
  27604. */
  27605. matricesWeightsExtra: Nullable<FloatArray>;
  27606. /**
  27607. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27608. */
  27609. indices: Nullable<IndicesArray>;
  27610. /**
  27611. * Uses the passed data array to set the set the values for the specified kind of data
  27612. * @param data a linear array of floating numbers
  27613. * @param kind the type of data that is being set, eg positions, colors etc
  27614. */
  27615. set(data: FloatArray, kind: string): void;
  27616. /**
  27617. * Associates the vertexData to the passed Mesh.
  27618. * Sets it as updatable or not (default `false`)
  27619. * @param mesh the mesh the vertexData is applied to
  27620. * @param updatable when used and having the value true allows new data to update the vertexData
  27621. * @returns the VertexData
  27622. */
  27623. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27624. /**
  27625. * Associates the vertexData to the passed Geometry.
  27626. * Sets it as updatable or not (default `false`)
  27627. * @param geometry the geometry the vertexData is applied to
  27628. * @param updatable when used and having the value true allows new data to update the vertexData
  27629. * @returns VertexData
  27630. */
  27631. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27632. /**
  27633. * Updates the associated mesh
  27634. * @param mesh the mesh to be updated
  27635. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27636. * @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
  27637. * @returns VertexData
  27638. */
  27639. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27640. /**
  27641. * Updates the associated geometry
  27642. * @param geometry the geometry to be updated
  27643. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27644. * @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
  27645. * @returns VertexData.
  27646. */
  27647. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27648. private _applyTo;
  27649. private _update;
  27650. /**
  27651. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27652. * @param matrix the transforming matrix
  27653. * @returns the VertexData
  27654. */
  27655. transform(matrix: Matrix): VertexData;
  27656. /**
  27657. * Merges the passed VertexData into the current one
  27658. * @param other the VertexData to be merged into the current one
  27659. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27660. * @returns the modified VertexData
  27661. */
  27662. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27663. private _mergeElement;
  27664. private _validate;
  27665. /**
  27666. * Serializes the VertexData
  27667. * @returns a serialized object
  27668. */
  27669. serialize(): any;
  27670. /**
  27671. * Extracts the vertexData from a mesh
  27672. * @param mesh the mesh from which to extract the VertexData
  27673. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27674. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27675. * @returns the object VertexData associated to the passed mesh
  27676. */
  27677. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27678. /**
  27679. * Extracts the vertexData from the geometry
  27680. * @param geometry the geometry from which to extract the VertexData
  27681. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27682. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27683. * @returns the object VertexData associated to the passed mesh
  27684. */
  27685. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27686. private static _ExtractFrom;
  27687. /**
  27688. * Creates the VertexData for a Ribbon
  27689. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27690. * * pathArray array of paths, each of which an array of successive Vector3
  27691. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27692. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27693. * * 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
  27694. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27695. * * 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)
  27696. * * 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)
  27697. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27698. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27699. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27700. * @returns the VertexData of the ribbon
  27701. */
  27702. static CreateRibbon(options: {
  27703. pathArray: Vector3[][];
  27704. closeArray?: boolean;
  27705. closePath?: boolean;
  27706. offset?: number;
  27707. sideOrientation?: number;
  27708. frontUVs?: Vector4;
  27709. backUVs?: Vector4;
  27710. invertUV?: boolean;
  27711. uvs?: Vector2[];
  27712. colors?: Color4[];
  27713. }): VertexData;
  27714. /**
  27715. * Creates the VertexData for a box
  27716. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27717. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27718. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27719. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27720. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27721. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27722. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27723. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27724. * * 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)
  27725. * * 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)
  27726. * @returns the VertexData of the box
  27727. */
  27728. static CreateBox(options: {
  27729. size?: number;
  27730. width?: number;
  27731. height?: number;
  27732. depth?: number;
  27733. faceUV?: Vector4[];
  27734. faceColors?: Color4[];
  27735. sideOrientation?: number;
  27736. frontUVs?: Vector4;
  27737. backUVs?: Vector4;
  27738. }): VertexData;
  27739. /**
  27740. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27741. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27742. * * segments sets the number of horizontal strips optional, default 32
  27743. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27744. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27745. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27746. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27747. * * 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
  27748. * * 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
  27749. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27750. * * 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)
  27751. * * 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)
  27752. * @returns the VertexData of the ellipsoid
  27753. */
  27754. static CreateSphere(options: {
  27755. segments?: number;
  27756. diameter?: number;
  27757. diameterX?: number;
  27758. diameterY?: number;
  27759. diameterZ?: number;
  27760. arc?: number;
  27761. slice?: number;
  27762. sideOrientation?: number;
  27763. frontUVs?: Vector4;
  27764. backUVs?: Vector4;
  27765. }): VertexData;
  27766. /**
  27767. * Creates the VertexData for a cylinder, cone or prism
  27768. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27769. * * height sets the height (y direction) of the cylinder, optional, default 2
  27770. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27771. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27772. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27773. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27774. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27775. * * 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
  27776. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27777. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27778. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27779. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27780. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27781. * * 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)
  27782. * * 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)
  27783. * @returns the VertexData of the cylinder, cone or prism
  27784. */
  27785. static CreateCylinder(options: {
  27786. height?: number;
  27787. diameterTop?: number;
  27788. diameterBottom?: number;
  27789. diameter?: number;
  27790. tessellation?: number;
  27791. subdivisions?: number;
  27792. arc?: number;
  27793. faceColors?: Color4[];
  27794. faceUV?: Vector4[];
  27795. hasRings?: boolean;
  27796. enclose?: boolean;
  27797. sideOrientation?: number;
  27798. frontUVs?: Vector4;
  27799. backUVs?: Vector4;
  27800. }): VertexData;
  27801. /**
  27802. * Creates the VertexData for a torus
  27803. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27804. * * diameter the diameter of the torus, optional default 1
  27805. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27806. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27807. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27808. * * 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)
  27809. * * 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)
  27810. * @returns the VertexData of the torus
  27811. */
  27812. static CreateTorus(options: {
  27813. diameter?: number;
  27814. thickness?: number;
  27815. tessellation?: number;
  27816. sideOrientation?: number;
  27817. frontUVs?: Vector4;
  27818. backUVs?: Vector4;
  27819. }): VertexData;
  27820. /**
  27821. * Creates the VertexData of the LineSystem
  27822. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27823. * - lines an array of lines, each line being an array of successive Vector3
  27824. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27825. * @returns the VertexData of the LineSystem
  27826. */
  27827. static CreateLineSystem(options: {
  27828. lines: Vector3[][];
  27829. colors?: Nullable<Color4[][]>;
  27830. }): VertexData;
  27831. /**
  27832. * Create the VertexData for a DashedLines
  27833. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27834. * - points an array successive Vector3
  27835. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27836. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27837. * - dashNb the intended total number of dashes, optional, default 200
  27838. * @returns the VertexData for the DashedLines
  27839. */
  27840. static CreateDashedLines(options: {
  27841. points: Vector3[];
  27842. dashSize?: number;
  27843. gapSize?: number;
  27844. dashNb?: number;
  27845. }): VertexData;
  27846. /**
  27847. * Creates the VertexData for a Ground
  27848. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27849. * - width the width (x direction) of the ground, optional, default 1
  27850. * - height the height (z direction) of the ground, optional, default 1
  27851. * - subdivisions the number of subdivisions per side, optional, default 1
  27852. * @returns the VertexData of the Ground
  27853. */
  27854. static CreateGround(options: {
  27855. width?: number;
  27856. height?: number;
  27857. subdivisions?: number;
  27858. subdivisionsX?: number;
  27859. subdivisionsY?: number;
  27860. }): VertexData;
  27861. /**
  27862. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27863. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27864. * * xmin the ground minimum X coordinate, optional, default -1
  27865. * * zmin the ground minimum Z coordinate, optional, default -1
  27866. * * xmax the ground maximum X coordinate, optional, default 1
  27867. * * zmax the ground maximum Z coordinate, optional, default 1
  27868. * * 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}
  27869. * * 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}
  27870. * @returns the VertexData of the TiledGround
  27871. */
  27872. static CreateTiledGround(options: {
  27873. xmin: number;
  27874. zmin: number;
  27875. xmax: number;
  27876. zmax: number;
  27877. subdivisions?: {
  27878. w: number;
  27879. h: number;
  27880. };
  27881. precision?: {
  27882. w: number;
  27883. h: number;
  27884. };
  27885. }): VertexData;
  27886. /**
  27887. * Creates the VertexData of the Ground designed from a heightmap
  27888. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27889. * * width the width (x direction) of the ground
  27890. * * height the height (z direction) of the ground
  27891. * * subdivisions the number of subdivisions per side
  27892. * * minHeight the minimum altitude on the ground, optional, default 0
  27893. * * maxHeight the maximum altitude on the ground, optional default 1
  27894. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27895. * * buffer the array holding the image color data
  27896. * * bufferWidth the width of image
  27897. * * bufferHeight the height of image
  27898. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27899. * @returns the VertexData of the Ground designed from a heightmap
  27900. */
  27901. static CreateGroundFromHeightMap(options: {
  27902. width: number;
  27903. height: number;
  27904. subdivisions: number;
  27905. minHeight: number;
  27906. maxHeight: number;
  27907. colorFilter: Color3;
  27908. buffer: Uint8Array;
  27909. bufferWidth: number;
  27910. bufferHeight: number;
  27911. alphaFilter: number;
  27912. }): VertexData;
  27913. /**
  27914. * Creates the VertexData for a Plane
  27915. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27916. * * size sets the width and height of the plane to the value of size, optional default 1
  27917. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27918. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27919. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27920. * * 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)
  27921. * * 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)
  27922. * @returns the VertexData of the box
  27923. */
  27924. static CreatePlane(options: {
  27925. size?: number;
  27926. width?: number;
  27927. height?: number;
  27928. sideOrientation?: number;
  27929. frontUVs?: Vector4;
  27930. backUVs?: Vector4;
  27931. }): VertexData;
  27932. /**
  27933. * Creates the VertexData of the Disc or regular Polygon
  27934. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27935. * * radius the radius of the disc, optional default 0.5
  27936. * * tessellation the number of polygon sides, optional, default 64
  27937. * * 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
  27938. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27939. * * 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)
  27940. * * 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)
  27941. * @returns the VertexData of the box
  27942. */
  27943. static CreateDisc(options: {
  27944. radius?: number;
  27945. tessellation?: number;
  27946. arc?: number;
  27947. sideOrientation?: number;
  27948. frontUVs?: Vector4;
  27949. backUVs?: Vector4;
  27950. }): VertexData;
  27951. /**
  27952. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27953. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27954. * @param polygon a mesh built from polygonTriangulation.build()
  27955. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27956. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27957. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27958. * @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)
  27959. * @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)
  27960. * @returns the VertexData of the Polygon
  27961. */
  27962. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  27963. /**
  27964. * Creates the VertexData of the IcoSphere
  27965. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27966. * * radius the radius of the IcoSphere, optional default 1
  27967. * * radiusX allows stretching in the x direction, optional, default radius
  27968. * * radiusY allows stretching in the y direction, optional, default radius
  27969. * * radiusZ allows stretching in the z direction, optional, default radius
  27970. * * flat when true creates a flat shaded mesh, optional, default true
  27971. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27972. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27973. * * 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)
  27974. * * 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)
  27975. * @returns the VertexData of the IcoSphere
  27976. */
  27977. static CreateIcoSphere(options: {
  27978. radius?: number;
  27979. radiusX?: number;
  27980. radiusY?: number;
  27981. radiusZ?: number;
  27982. flat?: boolean;
  27983. subdivisions?: number;
  27984. sideOrientation?: number;
  27985. frontUVs?: Vector4;
  27986. backUVs?: Vector4;
  27987. }): VertexData;
  27988. /**
  27989. * Creates the VertexData for a Polyhedron
  27990. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27991. * * type provided types are:
  27992. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27993. * * 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)
  27994. * * size the size of the IcoSphere, optional default 1
  27995. * * sizeX allows stretching in the x direction, optional, default size
  27996. * * sizeY allows stretching in the y direction, optional, default size
  27997. * * sizeZ allows stretching in the z direction, optional, default size
  27998. * * 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
  27999. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28000. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28001. * * flat when true creates a flat shaded mesh, optional, default true
  28002. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28003. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28004. * * 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)
  28005. * * 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)
  28006. * @returns the VertexData of the Polyhedron
  28007. */
  28008. static CreatePolyhedron(options: {
  28009. type?: number;
  28010. size?: number;
  28011. sizeX?: number;
  28012. sizeY?: number;
  28013. sizeZ?: number;
  28014. custom?: any;
  28015. faceUV?: Vector4[];
  28016. faceColors?: Color4[];
  28017. flat?: boolean;
  28018. sideOrientation?: number;
  28019. frontUVs?: Vector4;
  28020. backUVs?: Vector4;
  28021. }): VertexData;
  28022. /**
  28023. * Creates the VertexData for a TorusKnot
  28024. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  28025. * * radius the radius of the torus knot, optional, default 2
  28026. * * tube the thickness of the tube, optional, default 0.5
  28027. * * radialSegments the number of sides on each tube segments, optional, default 32
  28028. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  28029. * * p the number of windings around the z axis, optional, default 2
  28030. * * q the number of windings around the x axis, optional, default 3
  28031. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28032. * * 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)
  28033. * * 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)
  28034. * @returns the VertexData of the Torus Knot
  28035. */
  28036. static CreateTorusKnot(options: {
  28037. radius?: number;
  28038. tube?: number;
  28039. radialSegments?: number;
  28040. tubularSegments?: number;
  28041. p?: number;
  28042. q?: number;
  28043. sideOrientation?: number;
  28044. frontUVs?: Vector4;
  28045. backUVs?: Vector4;
  28046. }): VertexData;
  28047. /**
  28048. * Compute normals for given positions and indices
  28049. * @param positions an array of vertex positions, [...., x, y, z, ......]
  28050. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  28051. * @param normals an array of vertex normals, [...., x, y, z, ......]
  28052. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  28053. * * facetNormals : optional array of facet normals (vector3)
  28054. * * facetPositions : optional array of facet positions (vector3)
  28055. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  28056. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  28057. * * bInfo : optional bounding info, required for facetPartitioning computation
  28058. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  28059. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  28060. * * useRightHandedSystem: optional boolean to for right handed system computation
  28061. * * depthSort : optional boolean to enable the facet depth sort computation
  28062. * * distanceTo : optional Vector3 to compute the facet depth from this location
  28063. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  28064. */
  28065. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  28066. facetNormals?: any;
  28067. facetPositions?: any;
  28068. facetPartitioning?: any;
  28069. ratio?: number;
  28070. bInfo?: any;
  28071. bbSize?: Vector3;
  28072. subDiv?: any;
  28073. useRightHandedSystem?: boolean;
  28074. depthSort?: boolean;
  28075. distanceTo?: Vector3;
  28076. depthSortedFacets?: any;
  28077. }): void;
  28078. private static _ComputeSides;
  28079. /**
  28080. * Applies VertexData created from the imported parameters to the geometry
  28081. * @param parsedVertexData the parsed data from an imported file
  28082. * @param geometry the geometry to apply the VertexData to
  28083. */
  28084. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  28085. }
  28086. }
  28087. declare module BABYLON {
  28088. /**
  28089. * Class containing static functions to help procedurally build meshes
  28090. */
  28091. class MeshBuilder {
  28092. private static updateSideOrientation;
  28093. /**
  28094. * Creates a box mesh
  28095. * * The parameter `size` sets the size (float) of each box side (default 1)
  28096. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  28097. * * 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)
  28098. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28100. * * 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
  28101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28102. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  28103. * @param name defines the name of the mesh
  28104. * @param options defines the options used to create the mesh
  28105. * @param scene defines the hosting scene
  28106. * @returns the box mesh
  28107. */
  28108. static CreateBox(name: string, options: {
  28109. size?: number;
  28110. width?: number;
  28111. height?: number;
  28112. depth?: number;
  28113. faceUV?: Vector4[];
  28114. faceColors?: Color4[];
  28115. sideOrientation?: number;
  28116. frontUVs?: Vector4;
  28117. backUVs?: Vector4;
  28118. updatable?: boolean;
  28119. }, scene?: Nullable<Scene>): Mesh;
  28120. /**
  28121. * Creates a sphere mesh
  28122. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  28123. * * 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`)
  28124. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  28125. * * 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
  28126. * * 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)
  28127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28128. * * 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
  28129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28130. * @param name defines the name of the mesh
  28131. * @param options defines the options used to create the mesh
  28132. * @param scene defines the hosting scene
  28133. * @returns the sphere mesh
  28134. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  28135. */
  28136. static CreateSphere(name: string, options: {
  28137. segments?: number;
  28138. diameter?: number;
  28139. diameterX?: number;
  28140. diameterY?: number;
  28141. diameterZ?: number;
  28142. arc?: number;
  28143. slice?: number;
  28144. sideOrientation?: number;
  28145. frontUVs?: Vector4;
  28146. backUVs?: Vector4;
  28147. updatable?: boolean;
  28148. }, scene: any): Mesh;
  28149. /**
  28150. * Creates a plane polygonal mesh. By default, this is a disc
  28151. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28152. * * 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
  28153. * * 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
  28154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28155. * * 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
  28156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28157. * @param name defines the name of the mesh
  28158. * @param options defines the options used to create the mesh
  28159. * @param scene defines the hosting scene
  28160. * @returns the plane polygonal mesh
  28161. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28162. */
  28163. static CreateDisc(name: string, options: {
  28164. radius?: number;
  28165. tessellation?: number;
  28166. arc?: number;
  28167. updatable?: boolean;
  28168. sideOrientation?: number;
  28169. frontUVs?: Vector4;
  28170. backUVs?: Vector4;
  28171. }, scene?: Nullable<Scene>): Mesh;
  28172. /**
  28173. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28174. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28175. * * 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`)
  28176. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28177. * * 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
  28178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28179. * * 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
  28180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28181. * @param name defines the name of the mesh
  28182. * @param options defines the options used to create the mesh
  28183. * @param scene defines the hosting scene
  28184. * @returns the icosahedron mesh
  28185. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28186. */
  28187. static CreateIcoSphere(name: string, options: {
  28188. radius?: number;
  28189. radiusX?: number;
  28190. radiusY?: number;
  28191. radiusZ?: number;
  28192. flat?: boolean;
  28193. subdivisions?: number;
  28194. sideOrientation?: number;
  28195. frontUVs?: Vector4;
  28196. backUVs?: Vector4;
  28197. updatable?: boolean;
  28198. }, scene: Scene): Mesh;
  28199. /**
  28200. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28201. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  28202. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  28203. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  28204. * * 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
  28205. * * 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
  28206. * * 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
  28207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28208. * * 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
  28209. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28210. * * 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
  28211. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  28212. * * 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
  28213. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  28214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28215. * @param name defines the name of the mesh
  28216. * @param options defines the options used to create the mesh
  28217. * @param scene defines the hosting scene
  28218. * @returns the ribbon mesh
  28219. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  28220. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28221. */
  28222. static CreateRibbon(name: string, options: {
  28223. pathArray: Vector3[][];
  28224. closeArray?: boolean;
  28225. closePath?: boolean;
  28226. offset?: number;
  28227. updatable?: boolean;
  28228. sideOrientation?: number;
  28229. frontUVs?: Vector4;
  28230. backUVs?: Vector4;
  28231. instance?: Mesh;
  28232. invertUV?: boolean;
  28233. uvs?: Vector2[];
  28234. colors?: Color4[];
  28235. }, scene?: Nullable<Scene>): Mesh;
  28236. /**
  28237. * Creates a cylinder or a cone mesh
  28238. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  28239. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  28240. * * 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.
  28241. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  28242. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  28243. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  28244. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  28245. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  28246. * * 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).
  28247. * * 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
  28248. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  28249. * * 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
  28250. * * 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.
  28251. * * If `enclose` is false, a ring surface is one element.
  28252. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  28253. * * 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
  28254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28255. * * 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
  28256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28257. * @param name defines the name of the mesh
  28258. * @param options defines the options used to create the mesh
  28259. * @param scene defines the hosting scene
  28260. * @returns the cylinder mesh
  28261. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  28262. */
  28263. static CreateCylinder(name: string, options: {
  28264. height?: number;
  28265. diameterTop?: number;
  28266. diameterBottom?: number;
  28267. diameter?: number;
  28268. tessellation?: number;
  28269. subdivisions?: number;
  28270. arc?: number;
  28271. faceColors?: Color4[];
  28272. faceUV?: Vector4[];
  28273. updatable?: boolean;
  28274. hasRings?: boolean;
  28275. enclose?: boolean;
  28276. sideOrientation?: number;
  28277. frontUVs?: Vector4;
  28278. backUVs?: Vector4;
  28279. }, scene: any): Mesh;
  28280. /**
  28281. * Creates a torus mesh
  28282. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28283. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28284. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28285. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28286. * * 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
  28287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28288. * @param name defines the name of the mesh
  28289. * @param options defines the options used to create the mesh
  28290. * @param scene defines the hosting scene
  28291. * @returns the torus mesh
  28292. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  28293. */
  28294. static CreateTorus(name: string, options: {
  28295. diameter?: number;
  28296. thickness?: number;
  28297. tessellation?: number;
  28298. updatable?: boolean;
  28299. sideOrientation?: number;
  28300. frontUVs?: Vector4;
  28301. backUVs?: Vector4;
  28302. }, scene: any): Mesh;
  28303. /**
  28304. * Creates a torus knot mesh
  28305. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28306. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28307. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28308. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28309. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28310. * * 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
  28311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28312. * @param name defines the name of the mesh
  28313. * @param options defines the options used to create the mesh
  28314. * @param scene defines the hosting scene
  28315. * @returns the torus knot mesh
  28316. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  28317. */
  28318. static CreateTorusKnot(name: string, options: {
  28319. radius?: number;
  28320. tube?: number;
  28321. radialSegments?: number;
  28322. tubularSegments?: number;
  28323. p?: number;
  28324. q?: number;
  28325. updatable?: boolean;
  28326. sideOrientation?: number;
  28327. frontUVs?: Vector4;
  28328. backUVs?: Vector4;
  28329. }, scene: any): Mesh;
  28330. /**
  28331. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28332. * * 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
  28333. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28334. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28335. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28336. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28337. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28338. * * 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
  28339. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28342. * @param name defines the name of the new line system
  28343. * @param options defines the options used to create the line system
  28344. * @param scene defines the hosting scene
  28345. * @returns a new line system mesh
  28346. */
  28347. static CreateLineSystem(name: string, options: {
  28348. lines: Vector3[][];
  28349. updatable?: boolean;
  28350. instance?: Nullable<LinesMesh>;
  28351. colors?: Nullable<Color4[][]>;
  28352. useVertexAlpha?: boolean;
  28353. }, scene: Nullable<Scene>): LinesMesh;
  28354. /**
  28355. * Creates a line mesh
  28356. * 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
  28357. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28358. * * The parameter `points` is an array successive Vector3
  28359. * * 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
  28360. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28361. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28362. * * When updating an instance, remember that only point positions can change, not the number of points
  28363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28364. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  28365. * @param name defines the name of the new line system
  28366. * @param options defines the options used to create the line system
  28367. * @param scene defines the hosting scene
  28368. * @returns a new line mesh
  28369. */
  28370. static CreateLines(name: string, options: {
  28371. points: Vector3[];
  28372. updatable?: boolean;
  28373. instance?: Nullable<LinesMesh>;
  28374. colors?: Color4[];
  28375. useVertexAlpha?: boolean;
  28376. }, scene?: Nullable<Scene>): LinesMesh;
  28377. /**
  28378. * Creates a dashed line mesh
  28379. * * 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
  28380. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28381. * * The parameter `points` is an array successive Vector3
  28382. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28383. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28384. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28385. * * 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
  28386. * * When updating an instance, remember that only point positions can change, not the number of points
  28387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28388. * @param name defines the name of the mesh
  28389. * @param options defines the options used to create the mesh
  28390. * @param scene defines the hosting scene
  28391. * @returns the dashed line mesh
  28392. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28393. */
  28394. static CreateDashedLines(name: string, options: {
  28395. points: Vector3[];
  28396. dashSize?: number;
  28397. gapSize?: number;
  28398. dashNb?: number;
  28399. updatable?: boolean;
  28400. instance?: LinesMesh;
  28401. }, scene?: Nullable<Scene>): LinesMesh;
  28402. /**
  28403. * 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.
  28404. * * 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.
  28405. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28406. * * 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.
  28407. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28408. * * 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
  28409. * * 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
  28410. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28412. * * 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
  28413. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28415. * @param name defines the name of the mesh
  28416. * @param options defines the options used to create the mesh
  28417. * @param scene defines the hosting scene
  28418. * @returns the extruded shape mesh
  28419. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28420. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28421. */
  28422. static ExtrudeShape(name: string, options: {
  28423. shape: Vector3[];
  28424. path: Vector3[];
  28425. scale?: number;
  28426. rotation?: number;
  28427. cap?: number;
  28428. updatable?: boolean;
  28429. sideOrientation?: number;
  28430. frontUVs?: Vector4;
  28431. backUVs?: Vector4;
  28432. instance?: Mesh;
  28433. invertUV?: boolean;
  28434. }, scene?: Nullable<Scene>): Mesh;
  28435. /**
  28436. * Creates an custom extruded shape mesh.
  28437. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28438. * * 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.
  28439. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28440. * * 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
  28441. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28442. * * 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
  28443. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28444. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28445. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28446. * * 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
  28447. * * 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
  28448. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28450. * * 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
  28451. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28453. * @param name defines the name of the mesh
  28454. * @param options defines the options used to create the mesh
  28455. * @param scene defines the hosting scene
  28456. * @returns the custom extruded shape mesh
  28457. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28458. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28459. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28460. */
  28461. static ExtrudeShapeCustom(name: string, options: {
  28462. shape: Vector3[];
  28463. path: Vector3[];
  28464. scaleFunction?: any;
  28465. rotationFunction?: any;
  28466. ribbonCloseArray?: boolean;
  28467. ribbonClosePath?: boolean;
  28468. cap?: number;
  28469. updatable?: boolean;
  28470. sideOrientation?: number;
  28471. frontUVs?: Vector4;
  28472. backUVs?: Vector4;
  28473. instance?: Mesh;
  28474. invertUV?: boolean;
  28475. }, scene: Scene): Mesh;
  28476. /**
  28477. * Creates lathe mesh.
  28478. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28479. * * 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
  28480. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28481. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28482. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28483. * * 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
  28484. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28485. * * 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
  28486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28487. * * 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
  28488. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28490. * @param name defines the name of the mesh
  28491. * @param options defines the options used to create the mesh
  28492. * @param scene defines the hosting scene
  28493. * @returns the lathe mesh
  28494. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28495. */
  28496. static CreateLathe(name: string, options: {
  28497. shape: Vector3[];
  28498. radius?: number;
  28499. tessellation?: number;
  28500. clip?: number;
  28501. arc?: number;
  28502. closed?: boolean;
  28503. updatable?: boolean;
  28504. sideOrientation?: number;
  28505. frontUVs?: Vector4;
  28506. backUVs?: Vector4;
  28507. cap?: number;
  28508. invertUV?: boolean;
  28509. }, scene: Scene): Mesh;
  28510. /**
  28511. * Creates a plane mesh
  28512. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28513. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28514. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28516. * * 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
  28517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28518. * @param name defines the name of the mesh
  28519. * @param options defines the options used to create the mesh
  28520. * @param scene defines the hosting scene
  28521. * @returns the plane mesh
  28522. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  28523. */
  28524. static CreatePlane(name: string, options: {
  28525. size?: number;
  28526. width?: number;
  28527. height?: number;
  28528. sideOrientation?: number;
  28529. frontUVs?: Vector4;
  28530. backUVs?: Vector4;
  28531. updatable?: boolean;
  28532. sourcePlane?: Plane;
  28533. }, scene: Scene): Mesh;
  28534. /**
  28535. * Creates a ground mesh
  28536. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28537. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28539. * @param name defines the name of the mesh
  28540. * @param options defines the options used to create the mesh
  28541. * @param scene defines the hosting scene
  28542. * @returns the ground mesh
  28543. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  28544. */
  28545. static CreateGround(name: string, options: {
  28546. width?: number;
  28547. height?: number;
  28548. subdivisions?: number;
  28549. subdivisionsX?: number;
  28550. subdivisionsY?: number;
  28551. updatable?: boolean;
  28552. }, scene: any): Mesh;
  28553. /**
  28554. * Creates a tiled ground mesh
  28555. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28556. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28557. * * 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
  28558. * * 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
  28559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28560. * @param name defines the name of the mesh
  28561. * @param options defines the options used to create the mesh
  28562. * @param scene defines the hosting scene
  28563. * @returns the tiled ground mesh
  28564. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  28565. */
  28566. static CreateTiledGround(name: string, options: {
  28567. xmin: number;
  28568. zmin: number;
  28569. xmax: number;
  28570. zmax: number;
  28571. subdivisions?: {
  28572. w: number;
  28573. h: number;
  28574. };
  28575. precision?: {
  28576. w: number;
  28577. h: number;
  28578. };
  28579. updatable?: boolean;
  28580. }, scene: Scene): Mesh;
  28581. /**
  28582. * Creates a ground mesh from a height map
  28583. * * The parameter `url` sets the URL of the height map image resource.
  28584. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28585. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28586. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28587. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28588. * * 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.
  28589. * * 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).
  28590. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28592. * @param name defines the name of the mesh
  28593. * @param url defines the url to the height map
  28594. * @param options defines the options used to create the mesh
  28595. * @param scene defines the hosting scene
  28596. * @returns the ground mesh
  28597. * @see https://doc.babylonjs.com/babylon101/height_map
  28598. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  28599. */
  28600. static CreateGroundFromHeightMap(name: string, url: string, options: {
  28601. width?: number;
  28602. height?: number;
  28603. subdivisions?: number;
  28604. minHeight?: number;
  28605. maxHeight?: number;
  28606. colorFilter?: Color3;
  28607. alphaFilter?: number;
  28608. updatable?: boolean;
  28609. onReady?: (mesh: GroundMesh) => void;
  28610. }, scene: Scene): GroundMesh;
  28611. /**
  28612. * Creates a polygon mesh
  28613. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  28614. * * 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
  28615. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28617. * * 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)
  28618. * * Remember you can only change the shape positions, not their number when updating a polygon
  28619. * @param name defines the name of the mesh
  28620. * @param options defines the options used to create the mesh
  28621. * @param scene defines the hosting scene
  28622. * @returns the polygon mesh
  28623. */
  28624. static CreatePolygon(name: string, options: {
  28625. shape: Vector3[];
  28626. holes?: Vector3[][];
  28627. depth?: number;
  28628. faceUV?: Vector4[];
  28629. faceColors?: Color4[];
  28630. updatable?: boolean;
  28631. sideOrientation?: number;
  28632. frontUVs?: Vector4;
  28633. backUVs?: Vector4;
  28634. }, scene: Scene): Mesh;
  28635. /**
  28636. * Creates an extruded polygon mesh, with depth in the Y direction.
  28637. * * 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)
  28638. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28639. * @param name defines the name of the mesh
  28640. * @param options defines the options used to create the mesh
  28641. * @param scene defines the hosting scene
  28642. * @returns the polygon mesh
  28643. */
  28644. static ExtrudePolygon(name: string, options: {
  28645. shape: Vector3[];
  28646. holes?: Vector3[][];
  28647. depth?: number;
  28648. faceUV?: Vector4[];
  28649. faceColors?: Color4[];
  28650. updatable?: boolean;
  28651. sideOrientation?: number;
  28652. frontUVs?: Vector4;
  28653. backUVs?: Vector4;
  28654. }, scene: Scene): Mesh;
  28655. /**
  28656. * Creates a tube mesh.
  28657. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28658. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  28659. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  28660. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  28661. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  28662. * * 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)
  28663. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  28664. * * 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
  28665. * * 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
  28666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28667. * * 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
  28668. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28670. * @param name defines the name of the mesh
  28671. * @param options defines the options used to create the mesh
  28672. * @param scene defines the hosting scene
  28673. * @returns the tube mesh
  28674. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28675. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  28676. */
  28677. static CreateTube(name: string, options: {
  28678. path: Vector3[];
  28679. radius?: number;
  28680. tessellation?: number;
  28681. radiusFunction?: {
  28682. (i: number, distance: number): number;
  28683. };
  28684. cap?: number;
  28685. arc?: number;
  28686. updatable?: boolean;
  28687. sideOrientation?: number;
  28688. frontUVs?: Vector4;
  28689. backUVs?: Vector4;
  28690. instance?: Mesh;
  28691. invertUV?: boolean;
  28692. }, scene: Scene): Mesh;
  28693. /**
  28694. * Creates a polyhedron mesh
  28695. * * 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
  28696. * * The parameter `size` (positive float, default 1) sets the polygon size
  28697. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28698. * * 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`
  28699. * * 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
  28700. * * 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)`)
  28701. * * 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
  28702. * * 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
  28703. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28704. * * 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
  28705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28706. * @param name defines the name of the mesh
  28707. * @param options defines the options used to create the mesh
  28708. * @param scene defines the hosting scene
  28709. * @returns the polyhedron mesh
  28710. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  28711. */
  28712. static CreatePolyhedron(name: string, options: {
  28713. type?: number;
  28714. size?: number;
  28715. sizeX?: number;
  28716. sizeY?: number;
  28717. sizeZ?: number;
  28718. custom?: any;
  28719. faceUV?: Vector4[];
  28720. faceColors?: Color4[];
  28721. flat?: boolean;
  28722. updatable?: boolean;
  28723. sideOrientation?: number;
  28724. frontUVs?: Vector4;
  28725. backUVs?: Vector4;
  28726. }, scene: Scene): Mesh;
  28727. /**
  28728. * Creates a decal mesh.
  28729. * 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
  28730. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  28731. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  28732. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  28733. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  28734. * @param name defines the name of the mesh
  28735. * @param sourceMesh defines the mesh where the decal must be applied
  28736. * @param options defines the options used to create the mesh
  28737. * @param scene defines the hosting scene
  28738. * @returns the decal mesh
  28739. * @see https://doc.babylonjs.com/how_to/decals
  28740. */
  28741. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28742. position?: Vector3;
  28743. normal?: Vector3;
  28744. size?: Vector3;
  28745. angle?: number;
  28746. }): Mesh;
  28747. private static _ExtrudeShapeGeneric;
  28748. }
  28749. }
  28750. declare module BABYLON {
  28751. /**
  28752. * Class used to represent a specific level of detail of a mesh
  28753. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28754. */
  28755. class MeshLODLevel {
  28756. /** Defines the distance where this level should star being displayed */
  28757. distance: number;
  28758. /** Defines the mesh to use to render this level */
  28759. mesh: Nullable<Mesh>;
  28760. /**
  28761. * Creates a new LOD level
  28762. * @param distance defines the distance where this level should star being displayed
  28763. * @param mesh defines the mesh to use to render this level
  28764. */
  28765. constructor(
  28766. /** Defines the distance where this level should star being displayed */
  28767. distance: number,
  28768. /** Defines the mesh to use to render this level */
  28769. mesh: Nullable<Mesh>);
  28770. }
  28771. }
  28772. declare module BABYLON {
  28773. /**
  28774. * A simplifier interface for future simplification implementations
  28775. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28776. */
  28777. interface ISimplifier {
  28778. /**
  28779. * Simplification of a given mesh according to the given settings.
  28780. * Since this requires computation, it is assumed that the function runs async.
  28781. * @param settings The settings of the simplification, including quality and distance
  28782. * @param successCallback A callback that will be called after the mesh was simplified.
  28783. * @param errorCallback in case of an error, this callback will be called. optional.
  28784. */
  28785. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28786. }
  28787. /**
  28788. * Expected simplification settings.
  28789. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28790. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28791. */
  28792. interface ISimplificationSettings {
  28793. /**
  28794. * Gets or sets the expected quality
  28795. */
  28796. quality: number;
  28797. /**
  28798. * Gets or sets the distance when this optimized version should be used
  28799. */
  28800. distance: number;
  28801. /**
  28802. * Gets an already optimized mesh
  28803. */
  28804. optimizeMesh?: boolean;
  28805. }
  28806. /**
  28807. * Class used to specify simplification options
  28808. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28809. */
  28810. class SimplificationSettings implements ISimplificationSettings {
  28811. /** expected quality */
  28812. quality: number;
  28813. /** distance when this optimized version should be used */
  28814. distance: number;
  28815. /** already optimized mesh */
  28816. optimizeMesh?: boolean | undefined;
  28817. /**
  28818. * Creates a SimplificationSettings
  28819. * @param quality expected quality
  28820. * @param distance distance when this optimized version should be used
  28821. * @param optimizeMesh already optimized mesh
  28822. */
  28823. constructor(
  28824. /** expected quality */
  28825. quality: number,
  28826. /** distance when this optimized version should be used */
  28827. distance: number,
  28828. /** already optimized mesh */
  28829. optimizeMesh?: boolean | undefined);
  28830. }
  28831. /**
  28832. * Interface used to define a simplification task
  28833. */
  28834. interface ISimplificationTask {
  28835. /**
  28836. * Array of settings
  28837. */
  28838. settings: Array<ISimplificationSettings>;
  28839. /**
  28840. * Simplification type
  28841. */
  28842. simplificationType: SimplificationType;
  28843. /**
  28844. * Mesh to simplify
  28845. */
  28846. mesh: Mesh;
  28847. /**
  28848. * Callback called on success
  28849. */
  28850. successCallback?: () => void;
  28851. /**
  28852. * Defines if parallel processing can be used
  28853. */
  28854. parallelProcessing: boolean;
  28855. }
  28856. /**
  28857. * Queue used to order the simplification tasks
  28858. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28859. */
  28860. class SimplificationQueue {
  28861. private _simplificationArray;
  28862. /**
  28863. * Gets a boolean indicating that the process is still running
  28864. */
  28865. running: boolean;
  28866. /**
  28867. * Creates a new queue
  28868. */
  28869. constructor();
  28870. /**
  28871. * Adds a new simplification task
  28872. * @param task defines a task to add
  28873. */
  28874. addTask(task: ISimplificationTask): void;
  28875. /**
  28876. * Execute next task
  28877. */
  28878. executeNext(): void;
  28879. /**
  28880. * Execute a simplification task
  28881. * @param task defines the task to run
  28882. */
  28883. runSimplification(task: ISimplificationTask): void;
  28884. private getSimplifier;
  28885. }
  28886. /**
  28887. * The implemented types of simplification
  28888. * At the moment only Quadratic Error Decimation is implemented
  28889. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28890. */
  28891. enum SimplificationType {
  28892. /** Quadratic error decimation */
  28893. QUADRATIC = 0
  28894. }
  28895. }
  28896. declare module BABYLON {
  28897. interface Scene {
  28898. /** @hidden (Backing field) */
  28899. _simplificationQueue: SimplificationQueue;
  28900. /**
  28901. * Gets or sets the simplification queue attached to the scene
  28902. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28903. */
  28904. simplificationQueue: SimplificationQueue;
  28905. }
  28906. interface Mesh {
  28907. /**
  28908. * Simplify the mesh according to the given array of settings.
  28909. * Function will return immediately and will simplify async
  28910. * @param settings a collection of simplification settings
  28911. * @param parallelProcessing should all levels calculate parallel or one after the other
  28912. * @param simplificationType the type of simplification to run
  28913. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  28914. * @returns the current mesh
  28915. */
  28916. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  28917. }
  28918. /**
  28919. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  28920. * created in a scene
  28921. */
  28922. class SimplicationQueueSceneComponent implements ISceneComponent {
  28923. /**
  28924. * The component name helpfull to identify the component in the list of scene components.
  28925. */
  28926. readonly name: string;
  28927. /**
  28928. * The scene the component belongs to.
  28929. */
  28930. scene: Scene;
  28931. /**
  28932. * Creates a new instance of the component for the given scene
  28933. * @param scene Defines the scene to register the component in
  28934. */
  28935. constructor(scene: Scene);
  28936. /**
  28937. * Registers the component in a given scene
  28938. */
  28939. register(): void;
  28940. /**
  28941. * Rebuilds the elements related to this component in case of
  28942. * context lost for instance.
  28943. */
  28944. rebuild(): void;
  28945. /**
  28946. * Disposes the component and the associated ressources
  28947. */
  28948. dispose(): void;
  28949. private _beforeCameraUpdate;
  28950. }
  28951. }
  28952. declare module BABYLON {
  28953. /**
  28954. * Polygon
  28955. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28956. */
  28957. class Polygon {
  28958. /**
  28959. * Creates a rectangle
  28960. * @param xmin bottom X coord
  28961. * @param ymin bottom Y coord
  28962. * @param xmax top X coord
  28963. * @param ymax top Y coord
  28964. * @returns points that make the resulting rectation
  28965. */
  28966. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  28967. /**
  28968. * Creates a circle
  28969. * @param radius radius of circle
  28970. * @param cx scale in x
  28971. * @param cy scale in y
  28972. * @param numberOfSides number of sides that make up the circle
  28973. * @returns points that make the resulting circle
  28974. */
  28975. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  28976. /**
  28977. * Creates a polygon from input string
  28978. * @param input Input polygon data
  28979. * @returns the parsed points
  28980. */
  28981. static Parse(input: string): Vector2[];
  28982. /**
  28983. * Starts building a polygon from x and y coordinates
  28984. * @param x x coordinate
  28985. * @param y y coordinate
  28986. * @returns the started path2
  28987. */
  28988. static StartingAt(x: number, y: number): Path2;
  28989. }
  28990. /**
  28991. * Builds a polygon
  28992. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  28993. */
  28994. class PolygonMeshBuilder {
  28995. private _points;
  28996. private _outlinepoints;
  28997. private _holes;
  28998. private _name;
  28999. private _scene;
  29000. private _epoints;
  29001. private _eholes;
  29002. private _addToepoint;
  29003. /**
  29004. * Creates a PolygonMeshBuilder
  29005. * @param name name of the builder
  29006. * @param contours Path of the polygon
  29007. * @param scene scene to add to
  29008. */
  29009. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  29010. /**
  29011. * Adds a whole within the polygon
  29012. * @param hole Array of points defining the hole
  29013. * @returns this
  29014. */
  29015. addHole(hole: Vector2[]): PolygonMeshBuilder;
  29016. /**
  29017. * Creates the polygon
  29018. * @param updatable If the mesh should be updatable
  29019. * @param depth The depth of the mesh created
  29020. * @returns the created mesh
  29021. */
  29022. build(updatable?: boolean, depth?: number): Mesh;
  29023. /**
  29024. * Adds a side to the polygon
  29025. * @param positions points that make the polygon
  29026. * @param normals normals of the polygon
  29027. * @param uvs uvs of the polygon
  29028. * @param indices indices of the polygon
  29029. * @param bounds bounds of the polygon
  29030. * @param points points of the polygon
  29031. * @param depth depth of the polygon
  29032. * @param flip flip of the polygon
  29033. */
  29034. private addSide;
  29035. }
  29036. }
  29037. declare module BABYLON {
  29038. /**
  29039. * Base class for submeshes
  29040. */
  29041. class BaseSubMesh {
  29042. /** @hidden */
  29043. _materialDefines: Nullable<MaterialDefines>;
  29044. /** @hidden */
  29045. _materialEffect: Nullable<Effect>;
  29046. /**
  29047. * Gets associated effect
  29048. */
  29049. readonly effect: Nullable<Effect>;
  29050. /**
  29051. * Sets associated effect (effect used to render this submesh)
  29052. * @param effect defines the effect to associate with
  29053. * @param defines defines the set of defines used to compile this effect
  29054. */
  29055. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29056. }
  29057. /**
  29058. * Defines a subdivision inside a mesh
  29059. */
  29060. class SubMesh extends BaseSubMesh implements ICullable {
  29061. /** the material index to use */
  29062. materialIndex: number;
  29063. /** vertex index start */
  29064. verticesStart: number;
  29065. /** vertices count */
  29066. verticesCount: number;
  29067. /** index start */
  29068. indexStart: number;
  29069. /** indices count */
  29070. indexCount: number;
  29071. /** @hidden */
  29072. _linesIndexCount: number;
  29073. private _mesh;
  29074. private _renderingMesh;
  29075. private _boundingInfo;
  29076. private _linesIndexBuffer;
  29077. /** @hidden */
  29078. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29079. /** @hidden */
  29080. _trianglePlanes: Plane[];
  29081. /** @hidden */
  29082. _lastColliderTransformMatrix: Matrix;
  29083. /** @hidden */
  29084. _renderId: number;
  29085. /** @hidden */
  29086. _alphaIndex: number;
  29087. /** @hidden */
  29088. _distanceToCamera: number;
  29089. /** @hidden */
  29090. _id: number;
  29091. private _currentMaterial;
  29092. /**
  29093. * Add a new submesh to a mesh
  29094. * @param materialIndex defines the material index to use
  29095. * @param verticesStart defines vertex index start
  29096. * @param verticesCount defines vertices count
  29097. * @param indexStart defines index start
  29098. * @param indexCount defines indices count
  29099. * @param mesh defines the parent mesh
  29100. * @param renderingMesh defines an optional rendering mesh
  29101. * @param createBoundingBox defines if bounding box should be created for this submesh
  29102. * @returns the new submesh
  29103. */
  29104. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29105. /**
  29106. * Creates a new submesh
  29107. * @param materialIndex defines the material index to use
  29108. * @param verticesStart defines vertex index start
  29109. * @param verticesCount defines vertices count
  29110. * @param indexStart defines index start
  29111. * @param indexCount defines indices count
  29112. * @param mesh defines the parent mesh
  29113. * @param renderingMesh defines an optional rendering mesh
  29114. * @param createBoundingBox defines if bounding box should be created for this submesh
  29115. */
  29116. constructor(
  29117. /** the material index to use */
  29118. materialIndex: number,
  29119. /** vertex index start */
  29120. verticesStart: number,
  29121. /** vertices count */
  29122. verticesCount: number,
  29123. /** index start */
  29124. indexStart: number,
  29125. /** indices count */
  29126. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  29127. /**
  29128. * Returns true if this submesh covers the entire parent mesh
  29129. * @ignorenaming
  29130. */
  29131. readonly IsGlobal: boolean;
  29132. /**
  29133. * Returns the submesh BoudingInfo object
  29134. * @returns current bounding info (or mesh's one if the submesh is global)
  29135. */
  29136. getBoundingInfo(): BoundingInfo;
  29137. /**
  29138. * Sets the submesh BoundingInfo
  29139. * @param boundingInfo defines the new bounding info to use
  29140. * @returns the SubMesh
  29141. */
  29142. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29143. /**
  29144. * Returns the mesh of the current submesh
  29145. * @return the parent mesh
  29146. */
  29147. getMesh(): AbstractMesh;
  29148. /**
  29149. * Returns the rendering mesh of the submesh
  29150. * @returns the rendering mesh (could be different from parent mesh)
  29151. */
  29152. getRenderingMesh(): Mesh;
  29153. /**
  29154. * Returns the submesh material
  29155. * @returns null or the current material
  29156. */
  29157. getMaterial(): Nullable<Material>;
  29158. /**
  29159. * Sets a new updated BoundingInfo object to the submesh
  29160. * @returns the SubMesh
  29161. */
  29162. refreshBoundingInfo(): SubMesh;
  29163. /** @hidden */
  29164. _checkCollision(collider: Collider): boolean;
  29165. /**
  29166. * Updates the submesh BoundingInfo
  29167. * @param world defines the world matrix to use to update the bounding info
  29168. * @returns the submesh
  29169. */
  29170. updateBoundingInfo(world: Matrix): SubMesh;
  29171. /**
  29172. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29173. * @param frustumPlanes defines the frustum planes
  29174. * @returns true if the submesh is intersecting with the frustum
  29175. */
  29176. isInFrustum(frustumPlanes: Plane[]): boolean;
  29177. /**
  29178. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29179. * @param frustumPlanes defines the frustum planes
  29180. * @returns true if the submesh is inside the frustum
  29181. */
  29182. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29183. /**
  29184. * Renders the submesh
  29185. * @param enableAlphaMode defines if alpha needs to be used
  29186. * @returns the submesh
  29187. */
  29188. render(enableAlphaMode: boolean): SubMesh;
  29189. /**
  29190. * @hidden
  29191. */
  29192. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  29193. /**
  29194. * Checks if the submesh intersects with a ray
  29195. * @param ray defines the ray to test
  29196. * @returns true is the passed ray intersects the submesh bounding box
  29197. */
  29198. canIntersects(ray: Ray): boolean;
  29199. /**
  29200. * Intersects current submesh with a ray
  29201. * @param ray defines the ray to test
  29202. * @param positions defines mesh's positions array
  29203. * @param indices defines mesh's indices array
  29204. * @param fastCheck defines if only bounding info should be used
  29205. * @returns intersection info or null if no intersection
  29206. */
  29207. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  29208. /** @hidden */
  29209. private _intersectLines;
  29210. /** @hidden */
  29211. private _intersectTriangles;
  29212. /** @hidden */
  29213. _rebuild(): void;
  29214. /**
  29215. * Creates a new submesh from the passed mesh
  29216. * @param newMesh defines the new hosting mesh
  29217. * @param newRenderingMesh defines an optional rendering mesh
  29218. * @returns the new submesh
  29219. */
  29220. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29221. /**
  29222. * Release associated resources
  29223. */
  29224. dispose(): void;
  29225. /**
  29226. * Creates a new submesh from indices data
  29227. * @param materialIndex the index of the main mesh material
  29228. * @param startIndex the index where to start the copy in the mesh indices array
  29229. * @param indexCount the number of indices to copy then from the startIndex
  29230. * @param mesh the main mesh to create the submesh from
  29231. * @param renderingMesh the optional rendering mesh
  29232. * @returns a new submesh
  29233. */
  29234. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29235. }
  29236. }
  29237. declare module BABYLON {
  29238. /**
  29239. * 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.
  29240. * @see https://doc.babylonjs.com/how_to/transformnode
  29241. */
  29242. class TransformNode extends Node {
  29243. /**
  29244. * Object will not rotate to face the camera
  29245. */
  29246. static BILLBOARDMODE_NONE: number;
  29247. /**
  29248. * Object will rotate to face the camera but only on the x axis
  29249. */
  29250. static BILLBOARDMODE_X: number;
  29251. /**
  29252. * Object will rotate to face the camera but only on the y axis
  29253. */
  29254. static BILLBOARDMODE_Y: number;
  29255. /**
  29256. * Object will rotate to face the camera but only on the z axis
  29257. */
  29258. static BILLBOARDMODE_Z: number;
  29259. /**
  29260. * Object will rotate to face the camera
  29261. */
  29262. static BILLBOARDMODE_ALL: number;
  29263. private _forward;
  29264. private _forwardInverted;
  29265. private _up;
  29266. private _right;
  29267. private _rightInverted;
  29268. private _position;
  29269. private _rotation;
  29270. private _rotationQuaternion;
  29271. protected _scaling: Vector3;
  29272. protected _isDirty: boolean;
  29273. private _transformToBoneReferal;
  29274. /**
  29275. * Set the billboard mode. Default is 0.
  29276. *
  29277. * | Value | Type | Description |
  29278. * | --- | --- | --- |
  29279. * | 0 | BILLBOARDMODE_NONE | |
  29280. * | 1 | BILLBOARDMODE_X | |
  29281. * | 2 | BILLBOARDMODE_Y | |
  29282. * | 4 | BILLBOARDMODE_Z | |
  29283. * | 7 | BILLBOARDMODE_ALL | |
  29284. *
  29285. */
  29286. billboardMode: number;
  29287. /**
  29288. * 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
  29289. */
  29290. scalingDeterminant: number;
  29291. /**
  29292. * Sets the distance of the object to max, often used by skybox
  29293. */
  29294. infiniteDistance: boolean;
  29295. /**
  29296. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29297. * By default the system will update normals to compensate
  29298. */
  29299. ignoreNonUniformScaling: boolean;
  29300. /** @hidden */
  29301. _poseMatrix: Matrix;
  29302. private _localWorld;
  29303. private _absolutePosition;
  29304. private _pivotMatrix;
  29305. private _pivotMatrixInverse;
  29306. protected _postMultiplyPivotMatrix: boolean;
  29307. protected _isWorldMatrixFrozen: boolean;
  29308. /** @hidden */
  29309. _indexInSceneTransformNodesArray: number;
  29310. /**
  29311. * An event triggered after the world matrix is updated
  29312. */
  29313. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29314. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29315. /**
  29316. * Gets a string identifying the name of the class
  29317. * @returns "TransformNode" string
  29318. */
  29319. getClassName(): string;
  29320. /**
  29321. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29322. */
  29323. position: Vector3;
  29324. /**
  29325. * 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)).
  29326. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29327. */
  29328. rotation: Vector3;
  29329. /**
  29330. * 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)).
  29331. */
  29332. scaling: Vector3;
  29333. /**
  29334. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  29335. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29336. */
  29337. rotationQuaternion: Nullable<Quaternion>;
  29338. /**
  29339. * The forward direction of that transform in world space.
  29340. */
  29341. readonly forward: Vector3;
  29342. /**
  29343. * The up direction of that transform in world space.
  29344. */
  29345. readonly up: Vector3;
  29346. /**
  29347. * The right direction of that transform in world space.
  29348. */
  29349. readonly right: Vector3;
  29350. /**
  29351. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29352. * @param matrix the matrix to copy the pose from
  29353. * @returns this TransformNode.
  29354. */
  29355. updatePoseMatrix(matrix: Matrix): TransformNode;
  29356. /**
  29357. * Returns the mesh Pose matrix.
  29358. * @returns the pose matrix
  29359. */
  29360. getPoseMatrix(): Matrix;
  29361. /** @hidden */
  29362. _isSynchronized(): boolean;
  29363. /** @hidden */
  29364. _initCache(): void;
  29365. /**
  29366. * Flag the transform node as dirty (Forcing it to update everything)
  29367. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29368. * @returns this transform node
  29369. */
  29370. markAsDirty(property: string): TransformNode;
  29371. /**
  29372. * Returns the current mesh absolute position.
  29373. * Returns a Vector3.
  29374. */
  29375. readonly absolutePosition: Vector3;
  29376. /**
  29377. * Sets a new matrix to apply before all other transformation
  29378. * @param matrix defines the transform matrix
  29379. * @returns the current TransformNode
  29380. */
  29381. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29382. /**
  29383. * Sets a new pivot matrix to the current node
  29384. * @param matrix defines the new pivot matrix to use
  29385. * @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
  29386. * @returns the current TransformNode
  29387. */
  29388. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  29389. /**
  29390. * Returns the mesh pivot matrix.
  29391. * Default : Identity.
  29392. * @returns the matrix
  29393. */
  29394. getPivotMatrix(): Matrix;
  29395. /**
  29396. * Prevents the World matrix to be computed any longer.
  29397. * @returns the TransformNode.
  29398. */
  29399. freezeWorldMatrix(): TransformNode;
  29400. /**
  29401. * Allows back the World matrix computation.
  29402. * @returns the TransformNode.
  29403. */
  29404. unfreezeWorldMatrix(): this;
  29405. /**
  29406. * True if the World matrix has been frozen.
  29407. */
  29408. readonly isWorldMatrixFrozen: boolean;
  29409. /**
  29410. * Retuns the mesh absolute position in the World.
  29411. * @returns a Vector3.
  29412. */
  29413. getAbsolutePosition(): Vector3;
  29414. /**
  29415. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29416. * @param absolutePosition the absolute position to set
  29417. * @returns the TransformNode.
  29418. */
  29419. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29420. /**
  29421. * Sets the mesh position in its local space.
  29422. * @param vector3 the position to set in localspace
  29423. * @returns the TransformNode.
  29424. */
  29425. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29426. /**
  29427. * Returns the mesh position in the local space from the current World matrix values.
  29428. * @returns a new Vector3.
  29429. */
  29430. getPositionExpressedInLocalSpace(): Vector3;
  29431. /**
  29432. * Translates the mesh along the passed Vector3 in its local space.
  29433. * @param vector3 the distance to translate in localspace
  29434. * @returns the TransformNode.
  29435. */
  29436. locallyTranslate(vector3: Vector3): TransformNode;
  29437. private static _lookAtVectorCache;
  29438. /**
  29439. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29440. * @param targetPoint the position (must be in same space as current mesh) to look at
  29441. * @param yawCor optional yaw (y-axis) correction in radians
  29442. * @param pitchCor optional pitch (x-axis) correction in radians
  29443. * @param rollCor optional roll (z-axis) correction in radians
  29444. * @param space the choosen space of the target
  29445. * @returns the TransformNode.
  29446. */
  29447. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29448. /**
  29449. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29450. * This Vector3 is expressed in the World space.
  29451. * @param localAxis axis to rotate
  29452. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29453. */
  29454. getDirection(localAxis: Vector3): Vector3;
  29455. /**
  29456. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29457. * localAxis is expressed in the mesh local space.
  29458. * result is computed in the Wordl space from the mesh World matrix.
  29459. * @param localAxis axis to rotate
  29460. * @param result the resulting transformnode
  29461. * @returns this TransformNode.
  29462. */
  29463. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29464. /**
  29465. * Sets a new pivot point to the current node
  29466. * @param point defines the new pivot point to use
  29467. * @param space defines if the point is in world or local space (local by default)
  29468. * @returns the current TransformNode
  29469. */
  29470. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29471. /**
  29472. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29473. * @returns the pivot point
  29474. */
  29475. getPivotPoint(): Vector3;
  29476. /**
  29477. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29478. * @param result the vector3 to store the result
  29479. * @returns this TransformNode.
  29480. */
  29481. getPivotPointToRef(result: Vector3): TransformNode;
  29482. /**
  29483. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29484. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29485. */
  29486. getAbsolutePivotPoint(): Vector3;
  29487. /**
  29488. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29489. * @param result vector3 to store the result
  29490. * @returns this TransformNode.
  29491. */
  29492. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29493. /**
  29494. * Defines the passed node as the parent of the current node.
  29495. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29496. * @param node the node ot set as the parent
  29497. * @returns this TransformNode.
  29498. */
  29499. setParent(node: Nullable<Node>): TransformNode;
  29500. private _nonUniformScaling;
  29501. /**
  29502. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29503. */
  29504. readonly nonUniformScaling: boolean;
  29505. /** @hidden */
  29506. _updateNonUniformScalingState(value: boolean): boolean;
  29507. /**
  29508. * Attach the current TransformNode to another TransformNode associated with a bone
  29509. * @param bone Bone affecting the TransformNode
  29510. * @param affectedTransformNode TransformNode associated with the bone
  29511. * @returns this object
  29512. */
  29513. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29514. /**
  29515. * Detach the transform node if its associated with a bone
  29516. * @returns this object
  29517. */
  29518. detachFromBone(): TransformNode;
  29519. private static _rotationAxisCache;
  29520. /**
  29521. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29522. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29523. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29524. * The passed axis is also normalized.
  29525. * @param axis the axis to rotate around
  29526. * @param amount the amount to rotate in radians
  29527. * @param space Space to rotate in (Default: local)
  29528. * @returns the TransformNode.
  29529. */
  29530. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29531. /**
  29532. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29533. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29534. * The passed axis is also normalized. .
  29535. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29536. * @param point the point to rotate around
  29537. * @param axis the axis to rotate around
  29538. * @param amount the amount to rotate in radians
  29539. * @returns the TransformNode
  29540. */
  29541. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29542. /**
  29543. * Translates the mesh along the axis vector for the passed distance in the given space.
  29544. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29545. * @param axis the axis to translate in
  29546. * @param distance the distance to translate
  29547. * @param space Space to rotate in (Default: local)
  29548. * @returns the TransformNode.
  29549. */
  29550. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29551. /**
  29552. * Adds a rotation step to the mesh current rotation.
  29553. * x, y, z are Euler angles expressed in radians.
  29554. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29555. * This means this rotation is made in the mesh local space only.
  29556. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29557. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29558. * ```javascript
  29559. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29560. * ```
  29561. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29562. * 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.
  29563. * @param x Rotation to add
  29564. * @param y Rotation to add
  29565. * @param z Rotation to add
  29566. * @returns the TransformNode.
  29567. */
  29568. addRotation(x: number, y: number, z: number): TransformNode;
  29569. /**
  29570. * Computes the world matrix of the node
  29571. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29572. * @returns the world matrix
  29573. */
  29574. computeWorldMatrix(force?: boolean): Matrix;
  29575. protected _afterComputeWorldMatrix(): void;
  29576. /**
  29577. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29578. * @param func callback function to add
  29579. *
  29580. * @returns the TransformNode.
  29581. */
  29582. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29583. /**
  29584. * Removes a registered callback function.
  29585. * @param func callback function to remove
  29586. * @returns the TransformNode.
  29587. */
  29588. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29589. /**
  29590. * Gets the position of the current mesh in camera space
  29591. * @param camera defines the camera to use
  29592. * @returns a position
  29593. */
  29594. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  29595. /**
  29596. * Returns the distance from the mesh to the active camera
  29597. * @param camera defines the camera to use
  29598. * @returns the distance
  29599. */
  29600. getDistanceToCamera(camera?: Nullable<Camera>): number;
  29601. /**
  29602. * Clone the current transform node
  29603. * @param name Name of the new clone
  29604. * @param newParent New parent for the clone
  29605. * @param doNotCloneChildren Do not clone children hierarchy
  29606. * @returns the new transform node
  29607. */
  29608. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  29609. /**
  29610. * Serializes the objects information.
  29611. * @param currentSerializationObject defines the object to serialize in
  29612. * @returns the serialized object
  29613. */
  29614. serialize(currentSerializationObject?: any): any;
  29615. /**
  29616. * Returns a new TransformNode object parsed from the source provided.
  29617. * @param parsedTransformNode is the source.
  29618. * @param scene the scne the object belongs to
  29619. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  29620. * @returns a new TransformNode object parsed from the source provided.
  29621. */
  29622. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  29623. /**
  29624. * Releases resources associated with this transform node.
  29625. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29626. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29627. */
  29628. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29629. }
  29630. }
  29631. declare module BABYLON {
  29632. /**
  29633. * Specialized buffer used to store vertex data
  29634. */
  29635. class VertexBuffer {
  29636. /** @hidden */
  29637. _buffer: Buffer;
  29638. private _kind;
  29639. private _size;
  29640. private _ownsBuffer;
  29641. private _instanced;
  29642. private _instanceDivisor;
  29643. /**
  29644. * The byte type.
  29645. */
  29646. static readonly BYTE: number;
  29647. /**
  29648. * The unsigned byte type.
  29649. */
  29650. static readonly UNSIGNED_BYTE: number;
  29651. /**
  29652. * The short type.
  29653. */
  29654. static readonly SHORT: number;
  29655. /**
  29656. * The unsigned short type.
  29657. */
  29658. static readonly UNSIGNED_SHORT: number;
  29659. /**
  29660. * The integer type.
  29661. */
  29662. static readonly INT: number;
  29663. /**
  29664. * The unsigned integer type.
  29665. */
  29666. static readonly UNSIGNED_INT: number;
  29667. /**
  29668. * The float type.
  29669. */
  29670. static readonly FLOAT: number;
  29671. /**
  29672. * Gets or sets the instance divisor when in instanced mode
  29673. */
  29674. instanceDivisor: number;
  29675. /**
  29676. * Gets the byte stride.
  29677. */
  29678. readonly byteStride: number;
  29679. /**
  29680. * Gets the byte offset.
  29681. */
  29682. readonly byteOffset: number;
  29683. /**
  29684. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  29685. */
  29686. readonly normalized: boolean;
  29687. /**
  29688. * Gets the data type of each component in the array.
  29689. */
  29690. readonly type: number;
  29691. /**
  29692. * Constructor
  29693. * @param engine the engine
  29694. * @param data the data to use for this vertex buffer
  29695. * @param kind the vertex buffer kind
  29696. * @param updatable whether the data is updatable
  29697. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  29698. * @param stride the stride (optional)
  29699. * @param instanced whether the buffer is instanced (optional)
  29700. * @param offset the offset of the data (optional)
  29701. * @param size the number of components (optional)
  29702. * @param type the type of the component (optional)
  29703. * @param normalized whether the data contains normalized data (optional)
  29704. * @param useBytes set to true if stride and offset are in bytes (optional)
  29705. */
  29706. 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);
  29707. /** @hidden */
  29708. _rebuild(): void;
  29709. /**
  29710. * Returns the kind of the VertexBuffer (string)
  29711. * @returns a string
  29712. */
  29713. getKind(): string;
  29714. /**
  29715. * Gets a boolean indicating if the VertexBuffer is updatable?
  29716. * @returns true if the buffer is updatable
  29717. */
  29718. isUpdatable(): boolean;
  29719. /**
  29720. * Gets current buffer's data
  29721. * @returns a DataArray or null
  29722. */
  29723. getData(): Nullable<DataArray>;
  29724. /**
  29725. * Gets underlying native buffer
  29726. * @returns underlying native buffer
  29727. */
  29728. getBuffer(): Nullable<WebGLBuffer>;
  29729. /**
  29730. * Gets the stride in float32 units (i.e. byte stride / 4).
  29731. * May not be an integer if the byte stride is not divisible by 4.
  29732. * DEPRECATED. Use byteStride instead.
  29733. * @returns the stride in float32 units
  29734. */
  29735. getStrideSize(): number;
  29736. /**
  29737. * Returns the offset as a multiple of the type byte length.
  29738. * DEPRECATED. Use byteOffset instead.
  29739. * @returns the offset in bytes
  29740. */
  29741. getOffset(): number;
  29742. /**
  29743. * Returns the number of components per vertex attribute (integer)
  29744. * @returns the size in float
  29745. */
  29746. getSize(): number;
  29747. /**
  29748. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  29749. * @returns true if this buffer is instanced
  29750. */
  29751. getIsInstanced(): boolean;
  29752. /**
  29753. * Returns the instancing divisor, zero for non-instanced (integer).
  29754. * @returns a number
  29755. */
  29756. getInstanceDivisor(): number;
  29757. /**
  29758. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29759. * @param data defines the data to store
  29760. */
  29761. create(data?: DataArray): void;
  29762. /**
  29763. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29764. * This function will create a new buffer if the current one is not updatable
  29765. * @param data defines the data to store
  29766. */
  29767. update(data: DataArray): void;
  29768. /**
  29769. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29770. * Returns the directly updated WebGLBuffer.
  29771. * @param data the new data
  29772. * @param offset the new offset
  29773. * @param useBytes set to true if the offset is in bytes
  29774. */
  29775. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29776. /**
  29777. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29778. */
  29779. dispose(): void;
  29780. /**
  29781. * Enumerates each value of this vertex buffer as numbers.
  29782. * @param count the number of values to enumerate
  29783. * @param callback the callback function called for each value
  29784. */
  29785. forEach(count: number, callback: (value: number, index: number) => void): void;
  29786. /**
  29787. * Positions
  29788. */
  29789. static readonly PositionKind: string;
  29790. /**
  29791. * Normals
  29792. */
  29793. static readonly NormalKind: string;
  29794. /**
  29795. * Tangents
  29796. */
  29797. static readonly TangentKind: string;
  29798. /**
  29799. * Texture coordinates
  29800. */
  29801. static readonly UVKind: string;
  29802. /**
  29803. * Texture coordinates 2
  29804. */
  29805. static readonly UV2Kind: string;
  29806. /**
  29807. * Texture coordinates 3
  29808. */
  29809. static readonly UV3Kind: string;
  29810. /**
  29811. * Texture coordinates 4
  29812. */
  29813. static readonly UV4Kind: string;
  29814. /**
  29815. * Texture coordinates 5
  29816. */
  29817. static readonly UV5Kind: string;
  29818. /**
  29819. * Texture coordinates 6
  29820. */
  29821. static readonly UV6Kind: string;
  29822. /**
  29823. * Colors
  29824. */
  29825. static readonly ColorKind: string;
  29826. /**
  29827. * Matrix indices (for bones)
  29828. */
  29829. static readonly MatricesIndicesKind: string;
  29830. /**
  29831. * Matrix weights (for bones)
  29832. */
  29833. static readonly MatricesWeightsKind: string;
  29834. /**
  29835. * Additional matrix indices (for bones)
  29836. */
  29837. static readonly MatricesIndicesExtraKind: string;
  29838. /**
  29839. * Additional matrix weights (for bones)
  29840. */
  29841. static readonly MatricesWeightsExtraKind: string;
  29842. /**
  29843. * Deduces the stride given a kind.
  29844. * @param kind The kind string to deduce
  29845. * @returns The deduced stride
  29846. */
  29847. static DeduceStride(kind: string): number;
  29848. /**
  29849. * Gets the byte length of the given type.
  29850. * @param type the type
  29851. * @returns the number of bytes
  29852. */
  29853. static GetTypeByteLength(type: number): number;
  29854. /**
  29855. * Enumerates each value of the given parameters as numbers.
  29856. * @param data the data to enumerate
  29857. * @param byteOffset the byte offset of the data
  29858. * @param byteStride the byte stride of the data
  29859. * @param componentCount the number of components per element
  29860. * @param componentType the type of the component
  29861. * @param count the total number of components
  29862. * @param normalized whether the data is normalized
  29863. * @param callback the callback function called for each value
  29864. */
  29865. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  29866. private static _GetFloatValue;
  29867. }
  29868. }
  29869. declare module BABYLON {
  29870. /**
  29871. * Defines a target to use with MorphTargetManager
  29872. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29873. */
  29874. class MorphTarget implements IAnimatable {
  29875. /** defines the name of the target */
  29876. name: string;
  29877. /**
  29878. * Gets or sets the list of animations
  29879. */
  29880. animations: Animation[];
  29881. private _scene;
  29882. private _positions;
  29883. private _normals;
  29884. private _tangents;
  29885. private _influence;
  29886. /**
  29887. * Observable raised when the influence changes
  29888. */
  29889. onInfluenceChanged: Observable<boolean>;
  29890. /** @hidden */
  29891. _onDataLayoutChanged: Observable<void>;
  29892. /**
  29893. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  29894. */
  29895. influence: number;
  29896. /**
  29897. * Gets or sets the id of the morph Target
  29898. */
  29899. id: string;
  29900. private _animationPropertiesOverride;
  29901. /**
  29902. * Gets or sets the animation properties override
  29903. */
  29904. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  29905. /**
  29906. * Creates a new MorphTarget
  29907. * @param name defines the name of the target
  29908. * @param influence defines the influence to use
  29909. */
  29910. constructor(
  29911. /** defines the name of the target */
  29912. name: string, influence?: number, scene?: Nullable<Scene>);
  29913. /**
  29914. * Gets a boolean defining if the target contains position data
  29915. */
  29916. readonly hasPositions: boolean;
  29917. /**
  29918. * Gets a boolean defining if the target contains normal data
  29919. */
  29920. readonly hasNormals: boolean;
  29921. /**
  29922. * Gets a boolean defining if the target contains tangent data
  29923. */
  29924. readonly hasTangents: boolean;
  29925. /**
  29926. * Affects position data to this target
  29927. * @param data defines the position data to use
  29928. */
  29929. setPositions(data: Nullable<FloatArray>): void;
  29930. /**
  29931. * Gets the position data stored in this target
  29932. * @returns a FloatArray containing the position data (or null if not present)
  29933. */
  29934. getPositions(): Nullable<FloatArray>;
  29935. /**
  29936. * Affects normal data to this target
  29937. * @param data defines the normal data to use
  29938. */
  29939. setNormals(data: Nullable<FloatArray>): void;
  29940. /**
  29941. * Gets the normal data stored in this target
  29942. * @returns a FloatArray containing the normal data (or null if not present)
  29943. */
  29944. getNormals(): Nullable<FloatArray>;
  29945. /**
  29946. * Affects tangent data to this target
  29947. * @param data defines the tangent data to use
  29948. */
  29949. setTangents(data: Nullable<FloatArray>): void;
  29950. /**
  29951. * Gets the tangent data stored in this target
  29952. * @returns a FloatArray containing the tangent data (or null if not present)
  29953. */
  29954. getTangents(): Nullable<FloatArray>;
  29955. /**
  29956. * Serializes the current target into a Serialization object
  29957. * @returns the serialized object
  29958. */
  29959. serialize(): any;
  29960. /**
  29961. * Returns the string "MorphTarget"
  29962. * @returns "MorphTarget"
  29963. */
  29964. getClassName(): string;
  29965. /**
  29966. * Creates a new target from serialized data
  29967. * @param serializationObject defines the serialized data to use
  29968. * @returns a new MorphTarget
  29969. */
  29970. static Parse(serializationObject: any): MorphTarget;
  29971. /**
  29972. * Creates a MorphTarget from mesh data
  29973. * @param mesh defines the source mesh
  29974. * @param name defines the name to use for the new target
  29975. * @param influence defines the influence to attach to the target
  29976. * @returns a new MorphTarget
  29977. */
  29978. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  29979. }
  29980. }
  29981. declare module BABYLON {
  29982. /**
  29983. * This class is used to deform meshes using morphing between different targets
  29984. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29985. */
  29986. class MorphTargetManager {
  29987. private _targets;
  29988. private _targetInfluenceChangedObservers;
  29989. private _targetDataLayoutChangedObservers;
  29990. private _activeTargets;
  29991. private _scene;
  29992. private _influences;
  29993. private _supportsNormals;
  29994. private _supportsTangents;
  29995. private _vertexCount;
  29996. private _uniqueId;
  29997. private _tempInfluences;
  29998. /**
  29999. * Creates a new MorphTargetManager
  30000. * @param scene defines the current scene
  30001. */
  30002. constructor(scene?: Nullable<Scene>);
  30003. /**
  30004. * Gets the unique ID of this manager
  30005. */
  30006. readonly uniqueId: number;
  30007. /**
  30008. * Gets the number of vertices handled by this manager
  30009. */
  30010. readonly vertexCount: number;
  30011. /**
  30012. * Gets a boolean indicating if this manager supports morphing of normals
  30013. */
  30014. readonly supportsNormals: boolean;
  30015. /**
  30016. * Gets a boolean indicating if this manager supports morphing of tangents
  30017. */
  30018. readonly supportsTangents: boolean;
  30019. /**
  30020. * Gets the number of targets stored in this manager
  30021. */
  30022. readonly numTargets: number;
  30023. /**
  30024. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30025. */
  30026. readonly numInfluencers: number;
  30027. /**
  30028. * Gets the list of influences (one per target)
  30029. */
  30030. readonly influences: Float32Array;
  30031. /**
  30032. * Gets the active target at specified index. An active target is a target with an influence > 0
  30033. * @param index defines the index to check
  30034. * @returns the requested target
  30035. */
  30036. getActiveTarget(index: number): MorphTarget;
  30037. /**
  30038. * Gets the target at specified index
  30039. * @param index defines the index to check
  30040. * @returns the requested target
  30041. */
  30042. getTarget(index: number): MorphTarget;
  30043. /**
  30044. * Add a new target to this manager
  30045. * @param target defines the target to add
  30046. */
  30047. addTarget(target: MorphTarget): void;
  30048. /**
  30049. * Removes a target from the manager
  30050. * @param target defines the target to remove
  30051. */
  30052. removeTarget(target: MorphTarget): void;
  30053. /**
  30054. * Serializes the current manager into a Serialization object
  30055. * @returns the serialized object
  30056. */
  30057. serialize(): any;
  30058. private _syncActiveTargets;
  30059. /**
  30060. * Syncrhonize the targets with all the meshes using this morph target manager
  30061. */
  30062. synchronize(): void;
  30063. /**
  30064. * Creates a new MorphTargetManager from serialized data
  30065. * @param serializationObject defines the serialized data
  30066. * @param scene defines the hosting scene
  30067. * @returns the new MorphTargetManager
  30068. */
  30069. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  30070. }
  30071. }
  30072. declare module BABYLON {
  30073. /**
  30074. * Class used to enable access to IndexedDB
  30075. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30076. */
  30077. class Database implements IOfflineProvider {
  30078. private _callbackManifestChecked;
  30079. private _currentSceneUrl;
  30080. private _db;
  30081. private _enableSceneOffline;
  30082. private _enableTexturesOffline;
  30083. private _manifestVersionFound;
  30084. private _mustUpdateRessources;
  30085. private _hasReachedQuota;
  30086. private _isSupported;
  30087. private _idbFactory;
  30088. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  30089. private static IsUASupportingBlobStorage;
  30090. /**
  30091. * Gets a boolean indicating if Database storate is enabled (off by default)
  30092. */
  30093. static IDBStorageEnabled: boolean;
  30094. /**
  30095. * Gets a boolean indicating if scene must be saved in the database
  30096. */
  30097. readonly enableSceneOffline: boolean;
  30098. /**
  30099. * Gets a boolean indicating if textures must be saved in the database
  30100. */
  30101. readonly enableTexturesOffline: boolean;
  30102. /**
  30103. * Creates a new Database
  30104. * @param urlToScene defines the url to load the scene
  30105. * @param callbackManifestChecked defines the callback to use when manifest is checked
  30106. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  30107. */
  30108. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  30109. private static _ParseURL;
  30110. private static _ReturnFullUrlLocation;
  30111. private _checkManifestFile;
  30112. /**
  30113. * Open the database and make it available
  30114. * @param successCallback defines the callback to call on success
  30115. * @param errorCallback defines the callback to call on error
  30116. */
  30117. open(successCallback: () => void, errorCallback: () => void): void;
  30118. /**
  30119. * Loads an image from the database
  30120. * @param url defines the url to load from
  30121. * @param image defines the target DOM image
  30122. */
  30123. loadImage(url: string, image: HTMLImageElement): void;
  30124. private _loadImageFromDBAsync;
  30125. private _saveImageIntoDBAsync;
  30126. private _checkVersionFromDB;
  30127. private _loadVersionFromDBAsync;
  30128. private _saveVersionIntoDBAsync;
  30129. /**
  30130. * Loads a file from database
  30131. * @param url defines the URL to load from
  30132. * @param sceneLoaded defines a callback to call on success
  30133. * @param progressCallBack defines a callback to call when progress changed
  30134. * @param errorCallback defines a callback to call on error
  30135. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30136. */
  30137. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30138. private _loadFileAsync;
  30139. private _saveFileAsync;
  30140. }
  30141. }
  30142. declare module BABYLON {
  30143. /**
  30144. * Class used to enable access to offline support
  30145. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30146. */
  30147. interface IOfflineProvider {
  30148. /**
  30149. * Gets a boolean indicating if scene must be saved in the database
  30150. */
  30151. enableSceneOffline: boolean;
  30152. /**
  30153. * Gets a boolean indicating if textures must be saved in the database
  30154. */
  30155. enableTexturesOffline: boolean;
  30156. /**
  30157. * Open the offline support and make it available
  30158. * @param successCallback defines the callback to call on success
  30159. * @param errorCallback defines the callback to call on error
  30160. */
  30161. open(successCallback: () => void, errorCallback: () => void): void;
  30162. /**
  30163. * Loads an image from the offline support
  30164. * @param url defines the url to load from
  30165. * @param image defines the target DOM image
  30166. */
  30167. loadImage(url: string, image: HTMLImageElement): void;
  30168. /**
  30169. * Loads a file from offline support
  30170. * @param url defines the URL to load from
  30171. * @param sceneLoaded defines a callback to call on success
  30172. * @param progressCallBack defines a callback to call when progress changed
  30173. * @param errorCallback defines a callback to call on error
  30174. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30175. */
  30176. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30177. }
  30178. }
  30179. declare module BABYLON {
  30180. /**
  30181. * This represents the base class for particle system in Babylon.
  30182. * 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.
  30183. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  30184. * @example https://doc.babylonjs.com/babylon101/particles
  30185. */
  30186. class BaseParticleSystem {
  30187. /**
  30188. * Source color is added to the destination color without alpha affecting the result
  30189. */
  30190. static BLENDMODE_ONEONE: number;
  30191. /**
  30192. * Blend current color and particle color using particle’s alpha
  30193. */
  30194. static BLENDMODE_STANDARD: number;
  30195. /**
  30196. * Add current color and particle color multiplied by particle’s alpha
  30197. */
  30198. static BLENDMODE_ADD: number;
  30199. /**
  30200. * Multiply current color with particle color
  30201. */
  30202. static BLENDMODE_MULTIPLY: number;
  30203. /**
  30204. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  30205. */
  30206. static BLENDMODE_MULTIPLYADD: number;
  30207. /**
  30208. * List of animations used by the particle system.
  30209. */
  30210. animations: Animation[];
  30211. /**
  30212. * The id of the Particle system.
  30213. */
  30214. id: string;
  30215. /**
  30216. * The friendly name of the Particle system.
  30217. */
  30218. name: string;
  30219. /**
  30220. * The rendering group used by the Particle system to chose when to render.
  30221. */
  30222. renderingGroupId: number;
  30223. /**
  30224. * The emitter represents the Mesh or position we are attaching the particle system to.
  30225. */
  30226. emitter: Nullable<AbstractMesh | Vector3>;
  30227. /**
  30228. * The maximum number of particles to emit per frame
  30229. */
  30230. emitRate: number;
  30231. /**
  30232. * If you want to launch only a few particles at once, that can be done, as well.
  30233. */
  30234. manualEmitCount: number;
  30235. /**
  30236. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30237. */
  30238. updateSpeed: number;
  30239. /**
  30240. * The amount of time the particle system is running (depends of the overall update speed).
  30241. */
  30242. targetStopDuration: number;
  30243. /**
  30244. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  30245. */
  30246. disposeOnStop: boolean;
  30247. /**
  30248. * Minimum power of emitting particles.
  30249. */
  30250. minEmitPower: number;
  30251. /**
  30252. * Maximum power of emitting particles.
  30253. */
  30254. maxEmitPower: number;
  30255. /**
  30256. * Minimum life time of emitting particles.
  30257. */
  30258. minLifeTime: number;
  30259. /**
  30260. * Maximum life time of emitting particles.
  30261. */
  30262. maxLifeTime: number;
  30263. /**
  30264. * Minimum Size of emitting particles.
  30265. */
  30266. minSize: number;
  30267. /**
  30268. * Maximum Size of emitting particles.
  30269. */
  30270. maxSize: number;
  30271. /**
  30272. * Minimum scale of emitting particles on X axis.
  30273. */
  30274. minScaleX: number;
  30275. /**
  30276. * Maximum scale of emitting particles on X axis.
  30277. */
  30278. maxScaleX: number;
  30279. /**
  30280. * Minimum scale of emitting particles on Y axis.
  30281. */
  30282. minScaleY: number;
  30283. /**
  30284. * Maximum scale of emitting particles on Y axis.
  30285. */
  30286. maxScaleY: number;
  30287. /**
  30288. * Gets or sets the minimal initial rotation in radians.
  30289. */
  30290. minInitialRotation: number;
  30291. /**
  30292. * Gets or sets the maximal initial rotation in radians.
  30293. */
  30294. maxInitialRotation: number;
  30295. /**
  30296. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  30297. */
  30298. minAngularSpeed: number;
  30299. /**
  30300. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  30301. */
  30302. maxAngularSpeed: number;
  30303. /**
  30304. * The texture used to render each particle. (this can be a spritesheet)
  30305. */
  30306. particleTexture: Nullable<Texture>;
  30307. /**
  30308. * The layer mask we are rendering the particles through.
  30309. */
  30310. layerMask: number;
  30311. /**
  30312. * This can help using your own shader to render the particle system.
  30313. * The according effect will be created
  30314. */
  30315. customShader: any;
  30316. /**
  30317. * By default particle system starts as soon as they are created. This prevents the
  30318. * automatic start to happen and let you decide when to start emitting particles.
  30319. */
  30320. preventAutoStart: boolean;
  30321. /**
  30322. * Gets or sets a texture used to add random noise to particle positions
  30323. */
  30324. noiseTexture: Nullable<ProceduralTexture>;
  30325. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  30326. noiseStrength: Vector3;
  30327. /**
  30328. * Callback triggered when the particle animation is ending.
  30329. */
  30330. onAnimationEnd: Nullable<() => void>;
  30331. /**
  30332. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  30333. */
  30334. blendMode: number;
  30335. /**
  30336. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30337. * to override the particles.
  30338. */
  30339. forceDepthWrite: boolean;
  30340. /** 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 */
  30341. preWarmCycles: number;
  30342. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  30343. preWarmStepOffset: number;
  30344. /**
  30345. * 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)
  30346. */
  30347. spriteCellChangeSpeed: number;
  30348. /**
  30349. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  30350. */
  30351. startSpriteCellID: number;
  30352. /**
  30353. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  30354. */
  30355. endSpriteCellID: number;
  30356. /**
  30357. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  30358. */
  30359. spriteCellWidth: number;
  30360. /**
  30361. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  30362. */
  30363. spriteCellHeight: number;
  30364. /**
  30365. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  30366. */
  30367. spriteRandomStartCell: boolean;
  30368. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  30369. translationPivot: Vector2;
  30370. /** @hidden */
  30371. protected _isAnimationSheetEnabled: boolean;
  30372. /**
  30373. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  30374. */
  30375. beginAnimationOnStart: boolean;
  30376. /**
  30377. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  30378. */
  30379. beginAnimationFrom: number;
  30380. /**
  30381. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  30382. */
  30383. beginAnimationTo: number;
  30384. /**
  30385. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  30386. */
  30387. beginAnimationLoop: boolean;
  30388. /**
  30389. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  30390. */
  30391. isAnimationSheetEnabled: boolean;
  30392. /**
  30393. * Get hosting scene
  30394. * @returns the scene
  30395. */
  30396. getScene(): Scene;
  30397. /**
  30398. * You can use gravity if you want to give an orientation to your particles.
  30399. */
  30400. gravity: Vector3;
  30401. protected _colorGradients: Nullable<Array<ColorGradient>>;
  30402. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  30403. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  30404. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  30405. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  30406. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  30407. protected _dragGradients: Nullable<Array<FactorGradient>>;
  30408. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  30409. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  30410. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  30411. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  30412. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  30413. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  30414. /**
  30415. * Defines the delay in milliseconds before starting the system (0 by default)
  30416. */
  30417. startDelay: number;
  30418. /**
  30419. * Gets the current list of drag gradients.
  30420. * You must use addDragGradient and removeDragGradient to udpate this list
  30421. * @returns the list of drag gradients
  30422. */
  30423. getDragGradients(): Nullable<Array<FactorGradient>>;
  30424. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30425. limitVelocityDamping: number;
  30426. /**
  30427. * Gets the current list of limit velocity gradients.
  30428. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30429. * @returns the list of limit velocity gradients
  30430. */
  30431. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30432. /**
  30433. * Gets the current list of color gradients.
  30434. * You must use addColorGradient and removeColorGradient to udpate this list
  30435. * @returns the list of color gradients
  30436. */
  30437. getColorGradients(): Nullable<Array<ColorGradient>>;
  30438. /**
  30439. * Gets the current list of size gradients.
  30440. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30441. * @returns the list of size gradients
  30442. */
  30443. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30444. /**
  30445. * Gets the current list of color remap gradients.
  30446. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  30447. * @returns the list of color remap gradients
  30448. */
  30449. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  30450. /**
  30451. * Gets the current list of alpha remap gradients.
  30452. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  30453. * @returns the list of alpha remap gradients
  30454. */
  30455. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  30456. /**
  30457. * Gets the current list of life time gradients.
  30458. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  30459. * @returns the list of life time gradients
  30460. */
  30461. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  30462. /**
  30463. * Gets the current list of angular speed gradients.
  30464. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30465. * @returns the list of angular speed gradients
  30466. */
  30467. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30468. /**
  30469. * Gets the current list of velocity gradients.
  30470. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30471. * @returns the list of velocity gradients
  30472. */
  30473. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30474. /**
  30475. * Gets the current list of start size gradients.
  30476. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  30477. * @returns the list of start size gradients
  30478. */
  30479. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  30480. /**
  30481. * Gets the current list of emit rate gradients.
  30482. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  30483. * @returns the list of emit rate gradients
  30484. */
  30485. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  30486. /**
  30487. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30488. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30489. */
  30490. direction1: Vector3;
  30491. /**
  30492. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30493. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30494. */
  30495. direction2: Vector3;
  30496. /**
  30497. * 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.
  30498. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30499. */
  30500. minEmitBox: Vector3;
  30501. /**
  30502. * 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.
  30503. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30504. */
  30505. maxEmitBox: Vector3;
  30506. /**
  30507. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30508. */
  30509. color1: Color4;
  30510. /**
  30511. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30512. */
  30513. color2: Color4;
  30514. /**
  30515. * Color the particle will have at the end of its lifetime
  30516. */
  30517. colorDead: Color4;
  30518. /**
  30519. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  30520. */
  30521. textureMask: Color4;
  30522. /**
  30523. * The particle emitter type defines the emitter used by the particle system.
  30524. * It can be for example box, sphere, or cone...
  30525. */
  30526. particleEmitterType: IParticleEmitterType;
  30527. /** @hidden */
  30528. _isSubEmitter: boolean;
  30529. /**
  30530. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30531. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30532. */
  30533. billboardMode: number;
  30534. protected _isBillboardBased: boolean;
  30535. /**
  30536. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30537. */
  30538. isBillboardBased: boolean;
  30539. /**
  30540. * The scene the particle system belongs to.
  30541. */
  30542. protected _scene: Scene;
  30543. /**
  30544. * Local cache of defines for image processing.
  30545. */
  30546. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  30547. /**
  30548. * Default configuration related to image processing available in the standard Material.
  30549. */
  30550. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30551. /**
  30552. * Gets the image processing configuration used either in this material.
  30553. */
  30554. /**
  30555. * Sets the Default image processing configuration used either in the this material.
  30556. *
  30557. * If sets to null, the scene one is in use.
  30558. */
  30559. imageProcessingConfiguration: ImageProcessingConfiguration;
  30560. /**
  30561. * Attaches a new image processing configuration to the Standard Material.
  30562. * @param configuration
  30563. */
  30564. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30565. /** @hidden */
  30566. protected _reset(): void;
  30567. /** @hidden */
  30568. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  30569. /**
  30570. * Instantiates a particle system.
  30571. * 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.
  30572. * @param name The name of the particle system
  30573. */
  30574. constructor(name: string);
  30575. /**
  30576. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  30577. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30578. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30579. * @returns the emitter
  30580. */
  30581. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  30582. /**
  30583. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  30584. * @param radius The radius of the hemisphere to emit from
  30585. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30586. * @returns the emitter
  30587. */
  30588. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  30589. /**
  30590. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30591. * @param radius The radius of the sphere to emit from
  30592. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30593. * @returns the emitter
  30594. */
  30595. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  30596. /**
  30597. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  30598. * @param radius The radius of the sphere to emit from
  30599. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  30600. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  30601. * @returns the emitter
  30602. */
  30603. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  30604. /**
  30605. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  30606. * @param radius The radius of the emission cylinder
  30607. * @param height The height of the emission cylinder
  30608. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  30609. * @param directionRandomizer How much to randomize the particle direction [0-1]
  30610. * @returns the emitter
  30611. */
  30612. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  30613. /**
  30614. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  30615. * @param radius The radius of the cylinder to emit from
  30616. * @param height The height of the emission cylinder
  30617. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  30618. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  30619. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  30620. * @returns the emitter
  30621. */
  30622. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  30623. /**
  30624. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  30625. * @param radius The radius of the cone to emit from
  30626. * @param angle The base angle of the cone
  30627. * @returns the emitter
  30628. */
  30629. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  30630. /**
  30631. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  30632. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30633. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30634. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30635. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30636. * @returns the emitter
  30637. */
  30638. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  30639. }
  30640. }
  30641. declare module BABYLON {
  30642. /**
  30643. * This represents a GPU particle system in Babylon
  30644. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  30645. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  30646. */
  30647. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  30648. /**
  30649. * The layer mask we are rendering the particles through.
  30650. */
  30651. layerMask: number;
  30652. private _capacity;
  30653. private _activeCount;
  30654. private _currentActiveCount;
  30655. private _accumulatedCount;
  30656. private _renderEffect;
  30657. private _updateEffect;
  30658. private _buffer0;
  30659. private _buffer1;
  30660. private _spriteBuffer;
  30661. private _updateVAO;
  30662. private _renderVAO;
  30663. private _targetIndex;
  30664. private _sourceBuffer;
  30665. private _targetBuffer;
  30666. private _engine;
  30667. private _currentRenderId;
  30668. private _started;
  30669. private _stopped;
  30670. private _timeDelta;
  30671. private _randomTexture;
  30672. private _randomTexture2;
  30673. private _attributesStrideSize;
  30674. private _updateEffectOptions;
  30675. private _randomTextureSize;
  30676. private _actualFrame;
  30677. private readonly _rawTextureWidth;
  30678. /**
  30679. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  30680. */
  30681. static readonly IsSupported: boolean;
  30682. /**
  30683. * An event triggered when the system is disposed.
  30684. */
  30685. onDisposeObservable: Observable<GPUParticleSystem>;
  30686. /**
  30687. * Gets the maximum number of particles active at the same time.
  30688. * @returns The max number of active particles.
  30689. */
  30690. getCapacity(): number;
  30691. /**
  30692. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30693. * to override the particles.
  30694. */
  30695. forceDepthWrite: boolean;
  30696. /**
  30697. * Gets or set the number of active particles
  30698. */
  30699. activeParticleCount: number;
  30700. private _preWarmDone;
  30701. /**
  30702. * Is this system ready to be used/rendered
  30703. * @return true if the system is ready
  30704. */
  30705. isReady(): boolean;
  30706. /**
  30707. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30708. * @returns True if it has been started, otherwise false.
  30709. */
  30710. isStarted(): boolean;
  30711. /**
  30712. * Starts the particle system and begins to emit
  30713. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  30714. */
  30715. start(delay?: number): void;
  30716. /**
  30717. * Stops the particle system.
  30718. */
  30719. stop(): void;
  30720. /**
  30721. * Remove all active particles
  30722. */
  30723. reset(): void;
  30724. /**
  30725. * Returns the string "GPUParticleSystem"
  30726. * @returns a string containing the class name
  30727. */
  30728. getClassName(): string;
  30729. private _colorGradientsTexture;
  30730. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  30731. /**
  30732. * Adds a new color gradient
  30733. * @param gradient defines the gradient to use (between 0 and 1)
  30734. * @param color1 defines the color to affect to the specified gradient
  30735. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30736. * @returns the current particle system
  30737. */
  30738. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  30739. /**
  30740. * Remove a specific color gradient
  30741. * @param gradient defines the gradient to remove
  30742. * @returns the current particle system
  30743. */
  30744. removeColorGradient(gradient: number): GPUParticleSystem;
  30745. private _angularSpeedGradientsTexture;
  30746. private _sizeGradientsTexture;
  30747. private _velocityGradientsTexture;
  30748. private _limitVelocityGradientsTexture;
  30749. private _dragGradientsTexture;
  30750. private _addFactorGradient;
  30751. /**
  30752. * Adds a new size gradient
  30753. * @param gradient defines the gradient to use (between 0 and 1)
  30754. * @param factor defines the size factor to affect to the specified gradient
  30755. * @returns the current particle system
  30756. */
  30757. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  30758. /**
  30759. * Remove a specific size gradient
  30760. * @param gradient defines the gradient to remove
  30761. * @returns the current particle system
  30762. */
  30763. removeSizeGradient(gradient: number): GPUParticleSystem;
  30764. /**
  30765. * Adds a new angular speed gradient
  30766. * @param gradient defines the gradient to use (between 0 and 1)
  30767. * @param factor defines the angular speed to affect to the specified gradient
  30768. * @returns the current particle system
  30769. */
  30770. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  30771. /**
  30772. * Remove a specific angular speed gradient
  30773. * @param gradient defines the gradient to remove
  30774. * @returns the current particle system
  30775. */
  30776. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  30777. /**
  30778. * Adds a new velocity gradient
  30779. * @param gradient defines the gradient to use (between 0 and 1)
  30780. * @param factor defines the velocity to affect to the specified gradient
  30781. * @returns the current particle system
  30782. */
  30783. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30784. /**
  30785. * Remove a specific velocity gradient
  30786. * @param gradient defines the gradient to remove
  30787. * @returns the current particle system
  30788. */
  30789. removeVelocityGradient(gradient: number): GPUParticleSystem;
  30790. /**
  30791. * Adds a new limit velocity gradient
  30792. * @param gradient defines the gradient to use (between 0 and 1)
  30793. * @param factor defines the limit velocity value to affect to the specified gradient
  30794. * @returns the current particle system
  30795. */
  30796. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30797. /**
  30798. * Remove a specific limit velocity gradient
  30799. * @param gradient defines the gradient to remove
  30800. * @returns the current particle system
  30801. */
  30802. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  30803. /**
  30804. * Adds a new drag gradient
  30805. * @param gradient defines the gradient to use (between 0 and 1)
  30806. * @param factor defines the drag value to affect to the specified gradient
  30807. * @returns the current particle system
  30808. */
  30809. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  30810. /**
  30811. * Remove a specific drag gradient
  30812. * @param gradient defines the gradient to remove
  30813. * @returns the current particle system
  30814. */
  30815. removeDragGradient(gradient: number): GPUParticleSystem;
  30816. /**
  30817. * Not supported by GPUParticleSystem
  30818. * @param gradient defines the gradient to use (between 0 and 1)
  30819. * @param factor defines the emit rate value to affect to the specified gradient
  30820. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30821. * @returns the current particle system
  30822. */
  30823. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30824. /**
  30825. * Not supported by GPUParticleSystem
  30826. * @param gradient defines the gradient to remove
  30827. * @returns the current particle system
  30828. */
  30829. removeEmitRateGradient(gradient: number): IParticleSystem;
  30830. /**
  30831. * Not supported by GPUParticleSystem
  30832. * @param gradient defines the gradient to use (between 0 and 1)
  30833. * @param factor defines the start size value to affect to the specified gradient
  30834. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30835. * @returns the current particle system
  30836. */
  30837. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30838. /**
  30839. * Not supported by GPUParticleSystem
  30840. * @param gradient defines the gradient to remove
  30841. * @returns the current particle system
  30842. */
  30843. removeStartSizeGradient(gradient: number): IParticleSystem;
  30844. /**
  30845. * Not supported by GPUParticleSystem
  30846. * @param gradient defines the gradient to use (between 0 and 1)
  30847. * @param min defines the color remap minimal range
  30848. * @param max defines the color remap maximal range
  30849. * @returns the current particle system
  30850. */
  30851. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30852. /**
  30853. * Not supported by GPUParticleSystem
  30854. * @param gradient defines the gradient to remove
  30855. * @returns the current particle system
  30856. */
  30857. removeColorRemapGradient(gradient: number): IParticleSystem;
  30858. /**
  30859. * Not supported by GPUParticleSystem
  30860. * @param gradient defines the gradient to use (between 0 and 1)
  30861. * @param min defines the alpha remap minimal range
  30862. * @param max defines the alpha remap maximal range
  30863. * @returns the current particle system
  30864. */
  30865. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30866. /**
  30867. * Not supported by GPUParticleSystem
  30868. * @param gradient defines the gradient to remove
  30869. * @returns the current particle system
  30870. */
  30871. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  30872. /**
  30873. * Not supported by GPUParticleSystem
  30874. * @param gradient defines the gradient to use (between 0 and 1)
  30875. * @param color defines the color to affect to the specified gradient
  30876. * @returns the current particle system
  30877. */
  30878. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  30879. /**
  30880. * Not supported by GPUParticleSystem
  30881. * @param gradient defines the gradient to remove
  30882. * @returns the current particle system
  30883. */
  30884. removeRampGradient(gradient: number): IParticleSystem;
  30885. /**
  30886. * Not supported by GPUParticleSystem
  30887. * @returns the list of ramp gradients
  30888. */
  30889. getRampGradients(): Nullable<Array<Color3Gradient>>;
  30890. /**
  30891. * Not supported by GPUParticleSystem
  30892. * Gets or sets a boolean indicating that ramp gradients must be used
  30893. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  30894. */
  30895. useRampGradients: boolean;
  30896. /**
  30897. * Not supported by GPUParticleSystem
  30898. * @param gradient defines the gradient to use (between 0 and 1)
  30899. * @param factor defines the life time factor to affect to the specified gradient
  30900. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30901. * @returns the current particle system
  30902. */
  30903. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30904. /**
  30905. * Not supported by GPUParticleSystem
  30906. * @param gradient defines the gradient to remove
  30907. * @returns the current particle system
  30908. */
  30909. removeLifeTimeGradient(gradient: number): IParticleSystem;
  30910. /**
  30911. * Instantiates a GPU particle system.
  30912. * 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.
  30913. * @param name The name of the particle system
  30914. * @param options The options used to create the system
  30915. * @param scene The scene the particle system belongs to
  30916. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  30917. */
  30918. constructor(name: string, options: Partial<{
  30919. capacity: number;
  30920. randomTextureSize: number;
  30921. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  30922. protected _reset(): void;
  30923. private _createUpdateVAO;
  30924. private _createRenderVAO;
  30925. private _initialize;
  30926. /** @hidden */
  30927. _recreateUpdateEffect(): void;
  30928. /** @hidden */
  30929. _recreateRenderEffect(): void;
  30930. /**
  30931. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  30932. * @param preWarm defines if we are in the pre-warmimg phase
  30933. */
  30934. animate(preWarm?: boolean): void;
  30935. private _createFactorGradientTexture;
  30936. private _createSizeGradientTexture;
  30937. private _createAngularSpeedGradientTexture;
  30938. private _createVelocityGradientTexture;
  30939. private _createLimitVelocityGradientTexture;
  30940. private _createDragGradientTexture;
  30941. private _createColorGradientTexture;
  30942. /**
  30943. * Renders the particle system in its current state
  30944. * @param preWarm defines if the system should only update the particles but not render them
  30945. * @returns the current number of particles
  30946. */
  30947. render(preWarm?: boolean): number;
  30948. /**
  30949. * Rebuilds the particle system
  30950. */
  30951. rebuild(): void;
  30952. private _releaseBuffers;
  30953. private _releaseVAOs;
  30954. /**
  30955. * Disposes the particle system and free the associated resources
  30956. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  30957. */
  30958. dispose(disposeTexture?: boolean): void;
  30959. /**
  30960. * Clones the particle system.
  30961. * @param name The name of the cloned object
  30962. * @param newEmitter The new emitter to use
  30963. * @returns the cloned particle system
  30964. */
  30965. clone(name: string, newEmitter: any): GPUParticleSystem;
  30966. /**
  30967. * Serializes the particle system to a JSON object.
  30968. * @returns the JSON object
  30969. */
  30970. serialize(): any;
  30971. /**
  30972. * Parses a JSON object to create a GPU particle system.
  30973. * @param parsedParticleSystem The JSON object to parse
  30974. * @param scene The scene to create the particle system in
  30975. * @param rootUrl The root url to use to load external dependencies like texture
  30976. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  30977. * @returns the parsed GPU particle system
  30978. */
  30979. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  30980. }
  30981. }
  30982. declare module BABYLON {
  30983. /**
  30984. * Interface representing a particle system in Babylon.js.
  30985. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  30986. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  30987. */
  30988. interface IParticleSystem {
  30989. /**
  30990. * List of animations used by the particle system.
  30991. */
  30992. animations: Animation[];
  30993. /**
  30994. * The id of the Particle system.
  30995. */
  30996. id: string;
  30997. /**
  30998. * The name of the Particle system.
  30999. */
  31000. name: string;
  31001. /**
  31002. * The emitter represents the Mesh or position we are attaching the particle system to.
  31003. */
  31004. emitter: Nullable<AbstractMesh | Vector3>;
  31005. /**
  31006. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  31007. */
  31008. isBillboardBased: boolean;
  31009. /**
  31010. * The rendering group used by the Particle system to chose when to render.
  31011. */
  31012. renderingGroupId: number;
  31013. /**
  31014. * The layer mask we are rendering the particles through.
  31015. */
  31016. layerMask: number;
  31017. /**
  31018. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  31019. */
  31020. updateSpeed: number;
  31021. /**
  31022. * The amount of time the particle system is running (depends of the overall update speed).
  31023. */
  31024. targetStopDuration: number;
  31025. /**
  31026. * The texture used to render each particle. (this can be a spritesheet)
  31027. */
  31028. particleTexture: Nullable<Texture>;
  31029. /**
  31030. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  31031. */
  31032. blendMode: number;
  31033. /**
  31034. * Minimum life time of emitting particles.
  31035. */
  31036. minLifeTime: number;
  31037. /**
  31038. * Maximum life time of emitting particles.
  31039. */
  31040. maxLifeTime: number;
  31041. /**
  31042. * Minimum Size of emitting particles.
  31043. */
  31044. minSize: number;
  31045. /**
  31046. * Maximum Size of emitting particles.
  31047. */
  31048. maxSize: number;
  31049. /**
  31050. * Minimum scale of emitting particles on X axis.
  31051. */
  31052. minScaleX: number;
  31053. /**
  31054. * Maximum scale of emitting particles on X axis.
  31055. */
  31056. maxScaleX: number;
  31057. /**
  31058. * Minimum scale of emitting particles on Y axis.
  31059. */
  31060. minScaleY: number;
  31061. /**
  31062. * Maximum scale of emitting particles on Y axis.
  31063. */
  31064. maxScaleY: number;
  31065. /**
  31066. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31067. */
  31068. color1: Color4;
  31069. /**
  31070. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31071. */
  31072. color2: Color4;
  31073. /**
  31074. * Color the particle will have at the end of its lifetime.
  31075. */
  31076. colorDead: Color4;
  31077. /**
  31078. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  31079. */
  31080. emitRate: number;
  31081. /**
  31082. * You can use gravity if you want to give an orientation to your particles.
  31083. */
  31084. gravity: Vector3;
  31085. /**
  31086. * Minimum power of emitting particles.
  31087. */
  31088. minEmitPower: number;
  31089. /**
  31090. * Maximum power of emitting particles.
  31091. */
  31092. maxEmitPower: number;
  31093. /**
  31094. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  31095. */
  31096. minAngularSpeed: number;
  31097. /**
  31098. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  31099. */
  31100. maxAngularSpeed: number;
  31101. /**
  31102. * Gets or sets the minimal initial rotation in radians.
  31103. */
  31104. minInitialRotation: number;
  31105. /**
  31106. * Gets or sets the maximal initial rotation in radians.
  31107. */
  31108. maxInitialRotation: number;
  31109. /**
  31110. * The particle emitter type defines the emitter used by the particle system.
  31111. * It can be for example box, sphere, or cone...
  31112. */
  31113. particleEmitterType: Nullable<IParticleEmitterType>;
  31114. /**
  31115. * Defines the delay in milliseconds before starting the system (0 by default)
  31116. */
  31117. startDelay: number;
  31118. /**
  31119. * 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
  31120. */
  31121. preWarmCycles: number;
  31122. /**
  31123. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  31124. */
  31125. preWarmStepOffset: number;
  31126. /**
  31127. * 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)
  31128. */
  31129. spriteCellChangeSpeed: number;
  31130. /**
  31131. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  31132. */
  31133. startSpriteCellID: number;
  31134. /**
  31135. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  31136. */
  31137. endSpriteCellID: number;
  31138. /**
  31139. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  31140. */
  31141. spriteCellWidth: number;
  31142. /**
  31143. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  31144. */
  31145. spriteCellHeight: number;
  31146. /**
  31147. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  31148. */
  31149. spriteRandomStartCell: boolean;
  31150. /**
  31151. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  31152. */
  31153. isAnimationSheetEnabled: boolean;
  31154. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  31155. translationPivot: Vector2;
  31156. /**
  31157. * Gets or sets a texture used to add random noise to particle positions
  31158. */
  31159. noiseTexture: Nullable<BaseTexture>;
  31160. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  31161. noiseStrength: Vector3;
  31162. /**
  31163. * Gets or sets the billboard mode to use when isBillboardBased = true.
  31164. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  31165. */
  31166. billboardMode: number;
  31167. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  31168. limitVelocityDamping: number;
  31169. /**
  31170. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  31171. */
  31172. beginAnimationOnStart: boolean;
  31173. /**
  31174. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  31175. */
  31176. beginAnimationFrom: number;
  31177. /**
  31178. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  31179. */
  31180. beginAnimationTo: number;
  31181. /**
  31182. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  31183. */
  31184. beginAnimationLoop: boolean;
  31185. /**
  31186. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  31187. */
  31188. disposeOnStop: boolean;
  31189. /**
  31190. * Gets the maximum number of particles active at the same time.
  31191. * @returns The max number of active particles.
  31192. */
  31193. getCapacity(): number;
  31194. /**
  31195. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31196. * @returns True if it has been started, otherwise false.
  31197. */
  31198. isStarted(): boolean;
  31199. /**
  31200. * Animates the particle system for this frame.
  31201. */
  31202. animate(): void;
  31203. /**
  31204. * Renders the particle system in its current state.
  31205. * @returns the current number of particles
  31206. */
  31207. render(): number;
  31208. /**
  31209. * Dispose the particle system and frees its associated resources.
  31210. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31211. */
  31212. dispose(disposeTexture?: boolean): void;
  31213. /**
  31214. * Clones the particle system.
  31215. * @param name The name of the cloned object
  31216. * @param newEmitter The new emitter to use
  31217. * @returns the cloned particle system
  31218. */
  31219. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  31220. /**
  31221. * Serializes the particle system to a JSON object.
  31222. * @returns the JSON object
  31223. */
  31224. serialize(): any;
  31225. /**
  31226. * Rebuild the particle system
  31227. */
  31228. rebuild(): void;
  31229. /**
  31230. * Starts the particle system and begins to emit
  31231. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  31232. */
  31233. start(delay?: number): void;
  31234. /**
  31235. * Stops the particle system.
  31236. */
  31237. stop(): void;
  31238. /**
  31239. * Remove all active particles
  31240. */
  31241. reset(): void;
  31242. /**
  31243. * Is this system ready to be used/rendered
  31244. * @return true if the system is ready
  31245. */
  31246. isReady(): boolean;
  31247. /**
  31248. * Adds a new color gradient
  31249. * @param gradient defines the gradient to use (between 0 and 1)
  31250. * @param color1 defines the color to affect to the specified gradient
  31251. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31252. * @returns the current particle system
  31253. */
  31254. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31255. /**
  31256. * Remove a specific color gradient
  31257. * @param gradient defines the gradient to remove
  31258. * @returns the current particle system
  31259. */
  31260. removeColorGradient(gradient: number): IParticleSystem;
  31261. /**
  31262. * Adds a new size gradient
  31263. * @param gradient defines the gradient to use (between 0 and 1)
  31264. * @param factor defines the size factor to affect to the specified gradient
  31265. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31266. * @returns the current particle system
  31267. */
  31268. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31269. /**
  31270. * Remove a specific size gradient
  31271. * @param gradient defines the gradient to remove
  31272. * @returns the current particle system
  31273. */
  31274. removeSizeGradient(gradient: number): IParticleSystem;
  31275. /**
  31276. * Gets the current list of color gradients.
  31277. * You must use addColorGradient and removeColorGradient to udpate this list
  31278. * @returns the list of color gradients
  31279. */
  31280. getColorGradients(): Nullable<Array<ColorGradient>>;
  31281. /**
  31282. * Gets the current list of size gradients.
  31283. * You must use addSizeGradient and removeSizeGradient to udpate this list
  31284. * @returns the list of size gradients
  31285. */
  31286. getSizeGradients(): Nullable<Array<FactorGradient>>;
  31287. /**
  31288. * Gets the current list of angular speed gradients.
  31289. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  31290. * @returns the list of angular speed gradients
  31291. */
  31292. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  31293. /**
  31294. * Adds a new angular speed gradient
  31295. * @param gradient defines the gradient to use (between 0 and 1)
  31296. * @param factor defines the angular speed to affect to the specified gradient
  31297. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31298. * @returns the current particle system
  31299. */
  31300. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31301. /**
  31302. * Remove a specific angular speed gradient
  31303. * @param gradient defines the gradient to remove
  31304. * @returns the current particle system
  31305. */
  31306. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31307. /**
  31308. * Gets the current list of velocity gradients.
  31309. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  31310. * @returns the list of velocity gradients
  31311. */
  31312. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  31313. /**
  31314. * Adds a new velocity gradient
  31315. * @param gradient defines the gradient to use (between 0 and 1)
  31316. * @param factor defines the velocity to affect to the specified gradient
  31317. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31318. * @returns the current particle system
  31319. */
  31320. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31321. /**
  31322. * Remove a specific velocity gradient
  31323. * @param gradient defines the gradient to remove
  31324. * @returns the current particle system
  31325. */
  31326. removeVelocityGradient(gradient: number): IParticleSystem;
  31327. /**
  31328. * Gets the current list of limit velocity gradients.
  31329. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  31330. * @returns the list of limit velocity gradients
  31331. */
  31332. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  31333. /**
  31334. * Adds a new limit velocity gradient
  31335. * @param gradient defines the gradient to use (between 0 and 1)
  31336. * @param factor defines the limit velocity to affect to the specified gradient
  31337. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31338. * @returns the current particle system
  31339. */
  31340. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31341. /**
  31342. * Remove a specific limit velocity gradient
  31343. * @param gradient defines the gradient to remove
  31344. * @returns the current particle system
  31345. */
  31346. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31347. /**
  31348. * Adds a new drag gradient
  31349. * @param gradient defines the gradient to use (between 0 and 1)
  31350. * @param factor defines the drag to affect to the specified gradient
  31351. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31352. * @returns the current particle system
  31353. */
  31354. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31355. /**
  31356. * Remove a specific drag gradient
  31357. * @param gradient defines the gradient to remove
  31358. * @returns the current particle system
  31359. */
  31360. removeDragGradient(gradient: number): IParticleSystem;
  31361. /**
  31362. * Gets the current list of drag gradients.
  31363. * You must use addDragGradient and removeDragGradient to udpate this list
  31364. * @returns the list of drag gradients
  31365. */
  31366. getDragGradients(): Nullable<Array<FactorGradient>>;
  31367. /**
  31368. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31369. * @param gradient defines the gradient to use (between 0 and 1)
  31370. * @param factor defines the emit rate to affect to the specified gradient
  31371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31372. * @returns the current particle system
  31373. */
  31374. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31375. /**
  31376. * Remove a specific emit rate gradient
  31377. * @param gradient defines the gradient to remove
  31378. * @returns the current particle system
  31379. */
  31380. removeEmitRateGradient(gradient: number): IParticleSystem;
  31381. /**
  31382. * Gets the current list of emit rate gradients.
  31383. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  31384. * @returns the list of emit rate gradients
  31385. */
  31386. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  31387. /**
  31388. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31389. * @param gradient defines the gradient to use (between 0 and 1)
  31390. * @param factor defines the start size to affect to the specified gradient
  31391. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31392. * @returns the current particle system
  31393. */
  31394. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31395. /**
  31396. * Remove a specific start size gradient
  31397. * @param gradient defines the gradient to remove
  31398. * @returns the current particle system
  31399. */
  31400. removeStartSizeGradient(gradient: number): IParticleSystem;
  31401. /**
  31402. * Gets the current list of start size gradients.
  31403. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  31404. * @returns the list of start size gradients
  31405. */
  31406. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  31407. /**
  31408. * Adds a new life time gradient
  31409. * @param gradient defines the gradient to use (between 0 and 1)
  31410. * @param factor defines the life time factor to affect to the specified gradient
  31411. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31412. * @returns the current particle system
  31413. */
  31414. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31415. /**
  31416. * Remove a specific life time gradient
  31417. * @param gradient defines the gradient to remove
  31418. * @returns the current particle system
  31419. */
  31420. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31421. /**
  31422. * Gets the current list of life time gradients.
  31423. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  31424. * @returns the list of life time gradients
  31425. */
  31426. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  31427. /**
  31428. * Gets the current list of color gradients.
  31429. * You must use addColorGradient and removeColorGradient to udpate this list
  31430. * @returns the list of color gradients
  31431. */
  31432. getColorGradients(): Nullable<Array<ColorGradient>>;
  31433. /**
  31434. * Adds a new ramp gradient used to remap particle colors
  31435. * @param gradient defines the gradient to use (between 0 and 1)
  31436. * @param color defines the color to affect to the specified gradient
  31437. * @returns the current particle system
  31438. */
  31439. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31440. /**
  31441. * Gets the current list of ramp gradients.
  31442. * You must use addRampGradient and removeRampGradient to udpate this list
  31443. * @returns the list of ramp gradients
  31444. */
  31445. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31446. /** Gets or sets a boolean indicating that ramp gradients must be used
  31447. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31448. */
  31449. useRampGradients: boolean;
  31450. /**
  31451. * Adds a new color remap gradient
  31452. * @param gradient defines the gradient to use (between 0 and 1)
  31453. * @param min defines the color remap minimal range
  31454. * @param max defines the color remap maximal range
  31455. * @returns the current particle system
  31456. */
  31457. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31458. /**
  31459. * Gets the current list of color remap gradients.
  31460. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  31461. * @returns the list of color remap gradients
  31462. */
  31463. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  31464. /**
  31465. * Adds a new alpha remap gradient
  31466. * @param gradient defines the gradient to use (between 0 and 1)
  31467. * @param min defines the alpha remap minimal range
  31468. * @param max defines the alpha remap maximal range
  31469. * @returns the current particle system
  31470. */
  31471. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31472. /**
  31473. * Gets the current list of alpha remap gradients.
  31474. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  31475. * @returns the list of alpha remap gradients
  31476. */
  31477. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  31478. /**
  31479. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  31480. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31481. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31482. * @returns the emitter
  31483. */
  31484. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  31485. /**
  31486. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  31487. * @param radius The radius of the hemisphere to emit from
  31488. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31489. * @returns the emitter
  31490. */
  31491. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  31492. /**
  31493. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  31494. * @param radius The radius of the sphere to emit from
  31495. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31496. * @returns the emitter
  31497. */
  31498. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  31499. /**
  31500. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  31501. * @param radius The radius of the sphere to emit from
  31502. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  31503. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  31504. * @returns the emitter
  31505. */
  31506. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31507. /**
  31508. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  31509. * @param radius The radius of the emission cylinder
  31510. * @param height The height of the emission cylinder
  31511. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  31512. * @param directionRandomizer How much to randomize the particle direction [0-1]
  31513. * @returns the emitter
  31514. */
  31515. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  31516. /**
  31517. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  31518. * @param radius The radius of the cylinder to emit from
  31519. * @param height The height of the emission cylinder
  31520. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  31521. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  31522. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  31523. * @returns the emitter
  31524. */
  31525. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31526. /**
  31527. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  31528. * @param radius The radius of the cone to emit from
  31529. * @param angle The base angle of the cone
  31530. * @returns the emitter
  31531. */
  31532. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  31533. /**
  31534. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  31535. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31536. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31537. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31538. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31539. * @returns the emitter
  31540. */
  31541. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  31542. /**
  31543. * Get hosting scene
  31544. * @returns the scene
  31545. */
  31546. getScene(): Scene;
  31547. }
  31548. }
  31549. declare module BABYLON {
  31550. /**
  31551. * A particle represents one of the element emitted by a particle system.
  31552. * This is mainly define by its coordinates, direction, velocity and age.
  31553. */
  31554. class Particle {
  31555. /**
  31556. * The particle system the particle belongs to.
  31557. */
  31558. particleSystem: ParticleSystem;
  31559. private static _Count;
  31560. /**
  31561. * Unique ID of the particle
  31562. */
  31563. id: number;
  31564. /**
  31565. * The world position of the particle in the scene.
  31566. */
  31567. position: Vector3;
  31568. /**
  31569. * The world direction of the particle in the scene.
  31570. */
  31571. direction: Vector3;
  31572. /**
  31573. * The color of the particle.
  31574. */
  31575. color: Color4;
  31576. /**
  31577. * The color change of the particle per step.
  31578. */
  31579. colorStep: Color4;
  31580. /**
  31581. * Defines how long will the life of the particle be.
  31582. */
  31583. lifeTime: number;
  31584. /**
  31585. * The current age of the particle.
  31586. */
  31587. age: number;
  31588. /**
  31589. * The current size of the particle.
  31590. */
  31591. size: number;
  31592. /**
  31593. * The current scale of the particle.
  31594. */
  31595. scale: Vector2;
  31596. /**
  31597. * The current angle of the particle.
  31598. */
  31599. angle: number;
  31600. /**
  31601. * Defines how fast is the angle changing.
  31602. */
  31603. angularSpeed: number;
  31604. /**
  31605. * Defines the cell index used by the particle to be rendered from a sprite.
  31606. */
  31607. cellIndex: number;
  31608. /**
  31609. * The information required to support color remapping
  31610. */
  31611. remapData: Vector4;
  31612. /** @hidden */
  31613. _randomCellOffset?: number;
  31614. /** @hidden */
  31615. _initialDirection: Nullable<Vector3>;
  31616. /** @hidden */
  31617. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  31618. /** @hidden */
  31619. _initialStartSpriteCellID: number;
  31620. /** @hidden */
  31621. _initialEndSpriteCellID: number;
  31622. /** @hidden */
  31623. _currentColorGradient: Nullable<ColorGradient>;
  31624. /** @hidden */
  31625. _currentColor1: Color4;
  31626. /** @hidden */
  31627. _currentColor2: Color4;
  31628. /** @hidden */
  31629. _currentSizeGradient: Nullable<FactorGradient>;
  31630. /** @hidden */
  31631. _currentSize1: number;
  31632. /** @hidden */
  31633. _currentSize2: number;
  31634. /** @hidden */
  31635. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  31636. /** @hidden */
  31637. _currentAngularSpeed1: number;
  31638. /** @hidden */
  31639. _currentAngularSpeed2: number;
  31640. /** @hidden */
  31641. _currentVelocityGradient: Nullable<FactorGradient>;
  31642. /** @hidden */
  31643. _currentVelocity1: number;
  31644. /** @hidden */
  31645. _currentVelocity2: number;
  31646. /** @hidden */
  31647. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  31648. /** @hidden */
  31649. _currentLimitVelocity1: number;
  31650. /** @hidden */
  31651. _currentLimitVelocity2: number;
  31652. /** @hidden */
  31653. _currentDragGradient: Nullable<FactorGradient>;
  31654. /** @hidden */
  31655. _currentDrag1: number;
  31656. /** @hidden */
  31657. _currentDrag2: number;
  31658. /** @hidden */
  31659. _randomNoiseCoordinates1: Vector3;
  31660. /** @hidden */
  31661. _randomNoiseCoordinates2: Vector3;
  31662. /**
  31663. * Creates a new instance Particle
  31664. * @param particleSystem the particle system the particle belongs to
  31665. */
  31666. constructor(
  31667. /**
  31668. * The particle system the particle belongs to.
  31669. */
  31670. particleSystem: ParticleSystem);
  31671. private updateCellInfoFromSystem;
  31672. /**
  31673. * Defines how the sprite cell index is updated for the particle
  31674. */
  31675. updateCellIndex(): void;
  31676. /** @hidden */
  31677. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  31678. /** @hidden */
  31679. _inheritParticleInfoToSubEmitters(): void;
  31680. /** @hidden */
  31681. _reset(): void;
  31682. /**
  31683. * Copy the properties of particle to another one.
  31684. * @param other the particle to copy the information to.
  31685. */
  31686. copyTo(other: Particle): void;
  31687. }
  31688. }
  31689. declare module BABYLON {
  31690. /**
  31691. * This class is made for on one-liner static method to help creating particle system set.
  31692. */
  31693. class ParticleHelper {
  31694. /**
  31695. * Gets or sets base Assets URL
  31696. */
  31697. static BaseAssetsUrl: string;
  31698. /**
  31699. * Create a default particle system that you can tweak
  31700. * @param emitter defines the emitter to use
  31701. * @param capacity defines the system capacity (default is 500 particles)
  31702. * @param scene defines the hosting scene
  31703. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  31704. * @returns the new Particle system
  31705. */
  31706. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  31707. /**
  31708. * This is the main static method (one-liner) of this helper to create different particle systems
  31709. * @param type This string represents the type to the particle system to create
  31710. * @param scene The scene where the particle system should live
  31711. * @param gpu If the system will use gpu
  31712. * @returns the ParticleSystemSet created
  31713. */
  31714. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  31715. /**
  31716. * Static function used to export a particle system to a ParticleSystemSet variable.
  31717. * Please note that the emitter shape is not exported
  31718. * @param systems defines the particle systems to export
  31719. * @returns the created particle system set
  31720. */
  31721. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  31722. }
  31723. }
  31724. declare module BABYLON {
  31725. /**
  31726. * This represents a particle system in Babylon.
  31727. * 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.
  31728. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31729. * @example https://doc.babylonjs.com/babylon101/particles
  31730. */
  31731. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  31732. /**
  31733. * Billboard mode will only apply to Y axis
  31734. */
  31735. static readonly BILLBOARDMODE_Y: number;
  31736. /**
  31737. * Billboard mode will apply to all axes
  31738. */
  31739. static readonly BILLBOARDMODE_ALL: number;
  31740. /**
  31741. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  31742. */
  31743. static readonly BILLBOARDMODE_STRETCHED: number;
  31744. /**
  31745. * This function can be defined to provide custom update for active particles.
  31746. * This function will be called instead of regular update (age, position, color, etc.).
  31747. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  31748. */
  31749. updateFunction: (particles: Particle[]) => void;
  31750. private _emitterWorldMatrix;
  31751. /**
  31752. * This function can be defined to specify initial direction for every new particle.
  31753. * It by default use the emitterType defined function
  31754. */
  31755. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  31756. /**
  31757. * This function can be defined to specify initial position for every new particle.
  31758. * It by default use the emitterType defined function
  31759. */
  31760. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  31761. /**
  31762. * @hidden
  31763. */
  31764. _inheritedVelocityOffset: Vector3;
  31765. /**
  31766. * An event triggered when the system is disposed
  31767. */
  31768. onDisposeObservable: Observable<ParticleSystem>;
  31769. private _onDisposeObserver;
  31770. /**
  31771. * Sets a callback that will be triggered when the system is disposed
  31772. */
  31773. onDispose: () => void;
  31774. private _particles;
  31775. private _epsilon;
  31776. private _capacity;
  31777. private _stockParticles;
  31778. private _newPartsExcess;
  31779. private _vertexData;
  31780. private _vertexBuffer;
  31781. private _vertexBuffers;
  31782. private _spriteBuffer;
  31783. private _indexBuffer;
  31784. private _effect;
  31785. private _customEffect;
  31786. private _cachedDefines;
  31787. private _scaledColorStep;
  31788. private _colorDiff;
  31789. private _scaledDirection;
  31790. private _scaledGravity;
  31791. private _currentRenderId;
  31792. private _alive;
  31793. private _useInstancing;
  31794. private _started;
  31795. private _stopped;
  31796. private _actualFrame;
  31797. private _scaledUpdateSpeed;
  31798. private _vertexBufferSize;
  31799. /** @hidden */
  31800. _currentEmitRateGradient: Nullable<FactorGradient>;
  31801. /** @hidden */
  31802. _currentEmitRate1: number;
  31803. /** @hidden */
  31804. _currentEmitRate2: number;
  31805. /** @hidden */
  31806. _currentStartSizeGradient: Nullable<FactorGradient>;
  31807. /** @hidden */
  31808. _currentStartSize1: number;
  31809. /** @hidden */
  31810. _currentStartSize2: number;
  31811. private readonly _rawTextureWidth;
  31812. private _rampGradientsTexture;
  31813. private _useRampGradients;
  31814. /** Gets or sets a boolean indicating that ramp gradients must be used
  31815. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31816. */
  31817. useRampGradients: boolean;
  31818. /**
  31819. * 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.
  31820. * 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: [])
  31821. */
  31822. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  31823. private _subEmitters;
  31824. /**
  31825. * @hidden
  31826. * If the particle systems emitter should be disposed when the particle system is disposed
  31827. */
  31828. _disposeEmitterOnDispose: boolean;
  31829. /**
  31830. * The current active Sub-systems, this property is used by the root particle system only.
  31831. */
  31832. activeSubSystems: Array<ParticleSystem>;
  31833. private _rootParticleSystem;
  31834. /**
  31835. * Gets the current list of active particles
  31836. */
  31837. readonly particles: Particle[];
  31838. /**
  31839. * Returns the string "ParticleSystem"
  31840. * @returns a string containing the class name
  31841. */
  31842. getClassName(): string;
  31843. /**
  31844. * Instantiates a particle system.
  31845. * 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.
  31846. * @param name The name of the particle system
  31847. * @param capacity The max number of particles alive at the same time
  31848. * @param scene The scene the particle system belongs to
  31849. * @param customEffect a custom effect used to change the way particles are rendered by default
  31850. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31851. * @param epsilon Offset used to render the particles
  31852. */
  31853. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  31854. private _addFactorGradient;
  31855. private _removeFactorGradient;
  31856. /**
  31857. * Adds a new life time gradient
  31858. * @param gradient defines the gradient to use (between 0 and 1)
  31859. * @param factor defines the life time factor to affect to the specified gradient
  31860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31861. * @returns the current particle system
  31862. */
  31863. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31864. /**
  31865. * Remove a specific life time gradient
  31866. * @param gradient defines the gradient to remove
  31867. * @returns the current particle system
  31868. */
  31869. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31870. /**
  31871. * Adds a new size gradient
  31872. * @param gradient defines the gradient to use (between 0 and 1)
  31873. * @param factor defines the size factor to affect to the specified gradient
  31874. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31875. * @returns the current particle system
  31876. */
  31877. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31878. /**
  31879. * Remove a specific size gradient
  31880. * @param gradient defines the gradient to remove
  31881. * @returns the current particle system
  31882. */
  31883. removeSizeGradient(gradient: number): IParticleSystem;
  31884. /**
  31885. * Adds a new color remap gradient
  31886. * @param gradient defines the gradient to use (between 0 and 1)
  31887. * @param min defines the color remap minimal range
  31888. * @param max defines the color remap maximal range
  31889. * @returns the current particle system
  31890. */
  31891. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31892. /**
  31893. * Remove a specific color remap gradient
  31894. * @param gradient defines the gradient to remove
  31895. * @returns the current particle system
  31896. */
  31897. removeColorRemapGradient(gradient: number): IParticleSystem;
  31898. /**
  31899. * Adds a new alpha remap gradient
  31900. * @param gradient defines the gradient to use (between 0 and 1)
  31901. * @param min defines the alpha remap minimal range
  31902. * @param max defines the alpha remap maximal range
  31903. * @returns the current particle system
  31904. */
  31905. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31906. /**
  31907. * Remove a specific alpha remap gradient
  31908. * @param gradient defines the gradient to remove
  31909. * @returns the current particle system
  31910. */
  31911. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  31912. /**
  31913. * Adds a new angular speed gradient
  31914. * @param gradient defines the gradient to use (between 0 and 1)
  31915. * @param factor defines the angular speed to affect to the specified gradient
  31916. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31917. * @returns the current particle system
  31918. */
  31919. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31920. /**
  31921. * Remove a specific angular speed gradient
  31922. * @param gradient defines the gradient to remove
  31923. * @returns the current particle system
  31924. */
  31925. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31926. /**
  31927. * Adds a new velocity gradient
  31928. * @param gradient defines the gradient to use (between 0 and 1)
  31929. * @param factor defines the velocity to affect to the specified gradient
  31930. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31931. * @returns the current particle system
  31932. */
  31933. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31934. /**
  31935. * Remove a specific velocity gradient
  31936. * @param gradient defines the gradient to remove
  31937. * @returns the current particle system
  31938. */
  31939. removeVelocityGradient(gradient: number): IParticleSystem;
  31940. /**
  31941. * Adds a new limit velocity gradient
  31942. * @param gradient defines the gradient to use (between 0 and 1)
  31943. * @param factor defines the limit velocity value to affect to the specified gradient
  31944. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31945. * @returns the current particle system
  31946. */
  31947. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31948. /**
  31949. * Remove a specific limit velocity gradient
  31950. * @param gradient defines the gradient to remove
  31951. * @returns the current particle system
  31952. */
  31953. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31954. /**
  31955. * Adds a new drag gradient
  31956. * @param gradient defines the gradient to use (between 0 and 1)
  31957. * @param factor defines the drag value to affect to the specified gradient
  31958. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31959. * @returns the current particle system
  31960. */
  31961. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31962. /**
  31963. * Remove a specific drag gradient
  31964. * @param gradient defines the gradient to remove
  31965. * @returns the current particle system
  31966. */
  31967. removeDragGradient(gradient: number): IParticleSystem;
  31968. /**
  31969. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31970. * @param gradient defines the gradient to use (between 0 and 1)
  31971. * @param factor defines the emit rate value to affect to the specified gradient
  31972. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31973. * @returns the current particle system
  31974. */
  31975. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31976. /**
  31977. * Remove a specific emit rate gradient
  31978. * @param gradient defines the gradient to remove
  31979. * @returns the current particle system
  31980. */
  31981. removeEmitRateGradient(gradient: number): IParticleSystem;
  31982. /**
  31983. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31984. * @param gradient defines the gradient to use (between 0 and 1)
  31985. * @param factor defines the start size value to affect to the specified gradient
  31986. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31987. * @returns the current particle system
  31988. */
  31989. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31990. /**
  31991. * Remove a specific start size gradient
  31992. * @param gradient defines the gradient to remove
  31993. * @returns the current particle system
  31994. */
  31995. removeStartSizeGradient(gradient: number): IParticleSystem;
  31996. private _createRampGradientTexture;
  31997. /**
  31998. * Gets the current list of ramp gradients.
  31999. * You must use addRampGradient and removeRampGradient to udpate this list
  32000. * @returns the list of ramp gradients
  32001. */
  32002. getRampGradients(): Nullable<Array<Color3Gradient>>;
  32003. /**
  32004. * Adds a new ramp gradient used to remap particle colors
  32005. * @param gradient defines the gradient to use (between 0 and 1)
  32006. * @param color defines the color to affect to the specified gradient
  32007. * @returns the current particle system
  32008. */
  32009. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  32010. /**
  32011. * Remove a specific ramp gradient
  32012. * @param gradient defines the gradient to remove
  32013. * @returns the current particle system
  32014. */
  32015. removeRampGradient(gradient: number): ParticleSystem;
  32016. /**
  32017. * Adds a new color gradient
  32018. * @param gradient defines the gradient to use (between 0 and 1)
  32019. * @param color1 defines the color to affect to the specified gradient
  32020. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32021. * @returns this particle system
  32022. */
  32023. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  32024. /**
  32025. * Remove a specific color gradient
  32026. * @param gradient defines the gradient to remove
  32027. * @returns this particle system
  32028. */
  32029. removeColorGradient(gradient: number): IParticleSystem;
  32030. private _fetchR;
  32031. protected _reset(): void;
  32032. private _resetEffect;
  32033. private _createVertexBuffers;
  32034. private _createIndexBuffer;
  32035. /**
  32036. * Gets the maximum number of particles active at the same time.
  32037. * @returns The max number of active particles.
  32038. */
  32039. getCapacity(): number;
  32040. /**
  32041. * Gets whether there are still active particles in the system.
  32042. * @returns True if it is alive, otherwise false.
  32043. */
  32044. isAlive(): boolean;
  32045. /**
  32046. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32047. * @returns True if it has been started, otherwise false.
  32048. */
  32049. isStarted(): boolean;
  32050. private _prepareSubEmitterInternalArray;
  32051. /**
  32052. * Starts the particle system and begins to emit
  32053. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  32054. */
  32055. start(delay?: number): void;
  32056. /**
  32057. * Stops the particle system.
  32058. * @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.
  32059. */
  32060. stop(stopSubEmitters?: boolean): void;
  32061. /**
  32062. * Remove all active particles
  32063. */
  32064. reset(): void;
  32065. /**
  32066. * @hidden (for internal use only)
  32067. */
  32068. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  32069. /**
  32070. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  32071. * Its lifetime will start back at 0.
  32072. */
  32073. recycleParticle: (particle: Particle) => void;
  32074. private _stopSubEmitters;
  32075. private _createParticle;
  32076. private _removeFromRoot;
  32077. private _emitFromParticle;
  32078. private _update;
  32079. /** @hidden */
  32080. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  32081. /** @hidden */
  32082. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  32083. /** @hidden */
  32084. private _getEffect;
  32085. /**
  32086. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  32087. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  32088. */
  32089. animate(preWarmOnly?: boolean): void;
  32090. private _appendParticleVertices;
  32091. /**
  32092. * Rebuilds the particle system.
  32093. */
  32094. rebuild(): void;
  32095. /**
  32096. * Is this system ready to be used/rendered
  32097. * @return true if the system is ready
  32098. */
  32099. isReady(): boolean;
  32100. private _render;
  32101. /**
  32102. * Renders the particle system in its current state.
  32103. * @returns the current number of particles
  32104. */
  32105. render(): number;
  32106. /**
  32107. * Disposes the particle system and free the associated resources
  32108. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32109. */
  32110. dispose(disposeTexture?: boolean): void;
  32111. /**
  32112. * Clones the particle system.
  32113. * @param name The name of the cloned object
  32114. * @param newEmitter The new emitter to use
  32115. * @returns the cloned particle system
  32116. */
  32117. clone(name: string, newEmitter: any): ParticleSystem;
  32118. /**
  32119. * Serializes the particle system to a JSON object.
  32120. * @returns the JSON object
  32121. */
  32122. serialize(): any;
  32123. /** @hidden */
  32124. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  32125. /** @hidden */
  32126. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  32127. /**
  32128. * Parses a JSON object to create a particle system.
  32129. * @param parsedParticleSystem The JSON object to parse
  32130. * @param scene The scene to create the particle system in
  32131. * @param rootUrl The root url to use to load external dependencies like texture
  32132. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  32133. * @returns the Parsed particle system
  32134. */
  32135. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  32136. }
  32137. }
  32138. declare module BABYLON {
  32139. interface Engine {
  32140. /**
  32141. * Create an effect to use with particle systems.
  32142. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  32143. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  32144. * @param uniformsNames defines a list of attribute names
  32145. * @param samplers defines an array of string used to represent textures
  32146. * @param defines defines the string containing the defines to use to compile the shaders
  32147. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32148. * @param onCompiled defines a function to call when the effect creation is successful
  32149. * @param onError defines a function to call when the effect creation has failed
  32150. * @returns the new Effect
  32151. */
  32152. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  32153. }
  32154. interface Mesh {
  32155. /**
  32156. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  32157. * @returns an array of IParticleSystem
  32158. */
  32159. getEmittedParticleSystems(): IParticleSystem[];
  32160. /**
  32161. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  32162. * @returns an array of IParticleSystem
  32163. */
  32164. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  32165. }
  32166. }
  32167. declare module BABYLON {
  32168. /**
  32169. * Represents a set of particle systems working together to create a specific effect
  32170. */
  32171. class ParticleSystemSet implements IDisposable {
  32172. private _emitterCreationOptions;
  32173. private _emitterNode;
  32174. /**
  32175. * Gets the particle system list
  32176. */
  32177. systems: IParticleSystem[];
  32178. /**
  32179. * Gets the emitter node used with this set
  32180. */
  32181. readonly emitterNode: Nullable<TransformNode>;
  32182. /**
  32183. * Creates a new emitter mesh as a sphere
  32184. * @param options defines the options used to create the sphere
  32185. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  32186. * @param scene defines the hosting scene
  32187. */
  32188. setEmitterAsSphere(options: {
  32189. diameter: number;
  32190. segments: number;
  32191. color: Color3;
  32192. }, renderingGroupId: number, scene: Scene): void;
  32193. /**
  32194. * Starts all particle systems of the set
  32195. * @param emitter defines an optional mesh to use as emitter for the particle systems
  32196. */
  32197. start(emitter?: AbstractMesh): void;
  32198. /**
  32199. * Release all associated resources
  32200. */
  32201. dispose(): void;
  32202. /**
  32203. * Serialize the set into a JSON compatible object
  32204. * @returns a JSON compatible representation of the set
  32205. */
  32206. serialize(): any;
  32207. /**
  32208. * Parse a new ParticleSystemSet from a serialized source
  32209. * @param data defines a JSON compatible representation of the set
  32210. * @param scene defines the hosting scene
  32211. * @param gpu defines if we want GPU particles or CPU particles
  32212. * @returns a new ParticleSystemSet
  32213. */
  32214. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  32215. }
  32216. }
  32217. declare module BABYLON {
  32218. /**
  32219. * Represents one particle of a solid particle system.
  32220. */
  32221. class SolidParticle {
  32222. /**
  32223. * particle global index
  32224. */
  32225. idx: number;
  32226. /**
  32227. * The color of the particle
  32228. */
  32229. color: Nullable<Color4>;
  32230. /**
  32231. * The world space position of the particle.
  32232. */
  32233. position: Vector3;
  32234. /**
  32235. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32236. */
  32237. rotation: Vector3;
  32238. /**
  32239. * The world space rotation quaternion of the particle.
  32240. */
  32241. rotationQuaternion: Nullable<Quaternion>;
  32242. /**
  32243. * The scaling of the particle.
  32244. */
  32245. scaling: Vector3;
  32246. /**
  32247. * The uvs of the particle.
  32248. */
  32249. uvs: Vector4;
  32250. /**
  32251. * The current speed of the particle.
  32252. */
  32253. velocity: Vector3;
  32254. /**
  32255. * The pivot point in the particle local space.
  32256. */
  32257. pivot: Vector3;
  32258. /**
  32259. * Must the particle be translated from its pivot point in its local space ?
  32260. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32261. * Default : false
  32262. */
  32263. translateFromPivot: boolean;
  32264. /**
  32265. * Is the particle active or not ?
  32266. */
  32267. alive: boolean;
  32268. /**
  32269. * Is the particle visible or not ?
  32270. */
  32271. isVisible: boolean;
  32272. /**
  32273. * Index of this particle in the global "positions" array (Internal use)
  32274. * @hidden
  32275. */
  32276. _pos: number;
  32277. /**
  32278. * @hidden Index of this particle in the global "indices" array (Internal use)
  32279. */
  32280. _ind: number;
  32281. /**
  32282. * @hidden ModelShape of this particle (Internal use)
  32283. */
  32284. _model: ModelShape;
  32285. /**
  32286. * ModelShape id of this particle
  32287. */
  32288. shapeId: number;
  32289. /**
  32290. * Index of the particle in its shape id (Internal use)
  32291. */
  32292. idxInShape: number;
  32293. /**
  32294. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32295. */
  32296. _modelBoundingInfo: BoundingInfo;
  32297. /**
  32298. * @hidden Particle BoundingInfo object (Internal use)
  32299. */
  32300. _boundingInfo: BoundingInfo;
  32301. /**
  32302. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32303. */
  32304. _sps: SolidParticleSystem;
  32305. /**
  32306. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32307. */
  32308. _stillInvisible: boolean;
  32309. /**
  32310. * @hidden Last computed particle rotation matrix
  32311. */
  32312. _rotationMatrix: number[];
  32313. /**
  32314. * Parent particle Id, if any.
  32315. * Default null.
  32316. */
  32317. parentId: Nullable<number>;
  32318. /**
  32319. * @hidden Internal global position in the SPS.
  32320. */
  32321. _globalPosition: Vector3;
  32322. /**
  32323. * Creates a Solid Particle object.
  32324. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32325. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  32326. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32327. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32328. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32329. * @param shapeId (integer) is the model shape identifier in the SPS.
  32330. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32331. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32332. */
  32333. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  32334. /**
  32335. * Legacy support, changed scale to scaling
  32336. */
  32337. /**
  32338. * Legacy support, changed scale to scaling
  32339. */
  32340. scale: Vector3;
  32341. /**
  32342. * Legacy support, changed quaternion to rotationQuaternion
  32343. */
  32344. /**
  32345. * Legacy support, changed quaternion to rotationQuaternion
  32346. */
  32347. quaternion: Nullable<Quaternion>;
  32348. /**
  32349. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32350. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32351. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32352. * @returns true if it intersects
  32353. */
  32354. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32355. /**
  32356. * get the rotation matrix of the particle
  32357. * @hidden
  32358. */
  32359. getRotationMatrix(m: Matrix): void;
  32360. }
  32361. /**
  32362. * Represents the shape of the model used by one particle of a solid particle system.
  32363. * SPS internal tool, don't use it manually.
  32364. */
  32365. class ModelShape {
  32366. /**
  32367. * The shape id
  32368. * @hidden
  32369. */
  32370. shapeID: number;
  32371. /**
  32372. * flat array of model positions (internal use)
  32373. * @hidden
  32374. */
  32375. _shape: Vector3[];
  32376. /**
  32377. * flat array of model UVs (internal use)
  32378. * @hidden
  32379. */
  32380. _shapeUV: number[];
  32381. /**
  32382. * length of the shape in the model indices array (internal use)
  32383. * @hidden
  32384. */
  32385. _indicesLength: number;
  32386. /**
  32387. * Custom position function (internal use)
  32388. * @hidden
  32389. */
  32390. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32391. /**
  32392. * Custom vertex function (internal use)
  32393. * @hidden
  32394. */
  32395. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32396. /**
  32397. * 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.
  32398. * SPS internal tool, don't use it manually.
  32399. * @hidden
  32400. */
  32401. 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>);
  32402. }
  32403. /**
  32404. * Represents a Depth Sorted Particle in the solid particle system.
  32405. */
  32406. class DepthSortedParticle {
  32407. /**
  32408. * Index of the particle in the "indices" array
  32409. */
  32410. ind: number;
  32411. /**
  32412. * Length of the particle shape in the "indices" array
  32413. */
  32414. indicesLength: number;
  32415. /**
  32416. * Squared distance from the particle to the camera
  32417. */
  32418. sqDistance: number;
  32419. }
  32420. }
  32421. declare module BABYLON {
  32422. /**
  32423. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32424. *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.
  32425. * The SPS is also a particle system. It provides some methods to manage the particles.
  32426. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32427. *
  32428. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  32429. */
  32430. class SolidParticleSystem implements IDisposable {
  32431. /**
  32432. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32433. * Example : var p = SPS.particles[i];
  32434. */
  32435. particles: SolidParticle[];
  32436. /**
  32437. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32438. */
  32439. nbParticles: number;
  32440. /**
  32441. * If the particles must ever face the camera (default false). Useful for planar particles.
  32442. */
  32443. billboard: boolean;
  32444. /**
  32445. * Recompute normals when adding a shape
  32446. */
  32447. recomputeNormals: boolean;
  32448. /**
  32449. * This a counter ofr your own usage. It's not set by any SPS functions.
  32450. */
  32451. counter: number;
  32452. /**
  32453. * The SPS name. This name is also given to the underlying mesh.
  32454. */
  32455. name: string;
  32456. /**
  32457. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32458. */
  32459. mesh: Mesh;
  32460. /**
  32461. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32462. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  32463. */
  32464. vars: any;
  32465. /**
  32466. * This array is populated when the SPS is set as 'pickable'.
  32467. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32468. * Each element of this array is an object `{idx: int, faceId: int}`.
  32469. * `idx` is the picked particle index in the `SPS.particles` array
  32470. * `faceId` is the picked face index counted within this particle.
  32471. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  32472. */
  32473. pickedParticles: {
  32474. idx: number;
  32475. faceId: number;
  32476. }[];
  32477. /**
  32478. * This array is populated when `enableDepthSort` is set to true.
  32479. * Each element of this array is an instance of the class DepthSortedParticle.
  32480. */
  32481. depthSortedParticles: DepthSortedParticle[];
  32482. /**
  32483. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32484. * @hidden
  32485. */
  32486. _bSphereOnly: boolean;
  32487. /**
  32488. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32489. * @hidden
  32490. */
  32491. _bSphereRadiusFactor: number;
  32492. private _scene;
  32493. private _positions;
  32494. private _indices;
  32495. private _normals;
  32496. private _colors;
  32497. private _uvs;
  32498. private _indices32;
  32499. private _positions32;
  32500. private _normals32;
  32501. private _fixedNormal32;
  32502. private _colors32;
  32503. private _uvs32;
  32504. private _index;
  32505. private _updatable;
  32506. private _pickable;
  32507. private _isVisibilityBoxLocked;
  32508. private _alwaysVisible;
  32509. private _depthSort;
  32510. private _shapeCounter;
  32511. private _copy;
  32512. private _color;
  32513. private _computeParticleColor;
  32514. private _computeParticleTexture;
  32515. private _computeParticleRotation;
  32516. private _computeParticleVertex;
  32517. private _computeBoundingBox;
  32518. private _depthSortParticles;
  32519. private _camera;
  32520. private _mustUnrotateFixedNormals;
  32521. private _particlesIntersect;
  32522. private _needs32Bits;
  32523. /**
  32524. * Creates a SPS (Solid Particle System) object.
  32525. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32526. * @param scene (Scene) is the scene in which the SPS is added.
  32527. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32528. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32529. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32530. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32531. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32532. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32533. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32534. */
  32535. constructor(name: string, scene: Scene, options?: {
  32536. updatable?: boolean;
  32537. isPickable?: boolean;
  32538. enableDepthSort?: boolean;
  32539. particleIntersection?: boolean;
  32540. boundingSphereOnly?: boolean;
  32541. bSphereRadiusFactor?: number;
  32542. });
  32543. /**
  32544. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32545. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32546. * @returns the created mesh
  32547. */
  32548. buildMesh(): Mesh;
  32549. /**
  32550. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32551. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32552. * Thus the particles generated from `digest()` have their property `position` set yet.
  32553. * @param mesh ( Mesh ) is the mesh to be digested
  32554. * @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
  32555. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32556. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32557. * @returns the current SPS
  32558. */
  32559. digest(mesh: Mesh, options?: {
  32560. facetNb?: number;
  32561. number?: number;
  32562. delta?: number;
  32563. }): SolidParticleSystem;
  32564. private _unrotateFixedNormals;
  32565. private _resetCopy;
  32566. private _meshBuilder;
  32567. private _posToShape;
  32568. private _uvsToShapeUV;
  32569. private _addParticle;
  32570. /**
  32571. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32572. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  32573. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32574. * @param nb (positive integer) the number of particles to be created from this model
  32575. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32576. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32577. * @returns the number of shapes in the system
  32578. */
  32579. addShape(mesh: Mesh, nb: number, options?: {
  32580. positionFunction?: any;
  32581. vertexFunction?: any;
  32582. }): number;
  32583. private _rebuildParticle;
  32584. /**
  32585. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32586. * @returns the SPS.
  32587. */
  32588. rebuildMesh(): SolidParticleSystem;
  32589. /**
  32590. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32591. * This method calls `updateParticle()` for each particle of the SPS.
  32592. * For an animated SPS, it is usually called within the render loop.
  32593. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32594. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32595. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32596. * @returns the SPS.
  32597. */
  32598. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32599. /**
  32600. * Disposes the SPS.
  32601. */
  32602. dispose(): void;
  32603. /**
  32604. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32605. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32606. * @returns the SPS.
  32607. */
  32608. refreshVisibleSize(): SolidParticleSystem;
  32609. /**
  32610. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32611. * @param size the size (float) of the visibility box
  32612. * note : this doesn't lock the SPS mesh bounding box.
  32613. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32614. */
  32615. setVisibilityBox(size: number): void;
  32616. /**
  32617. * Gets whether the SPS as always visible or not
  32618. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32619. */
  32620. /**
  32621. * Sets the SPS as always visible or not
  32622. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32623. */
  32624. isAlwaysVisible: boolean;
  32625. /**
  32626. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32627. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32628. */
  32629. /**
  32630. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32631. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32632. */
  32633. isVisibilityBoxLocked: boolean;
  32634. /**
  32635. * Tells to `setParticles()` to compute the particle rotations or not.
  32636. * Default value : true. The SPS is faster when it's set to false.
  32637. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32638. */
  32639. /**
  32640. * Gets if `setParticles()` computes the particle rotations or not.
  32641. * Default value : true. The SPS is faster when it's set to false.
  32642. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32643. */
  32644. computeParticleRotation: boolean;
  32645. /**
  32646. * Tells to `setParticles()` to compute the particle colors or not.
  32647. * Default value : true. The SPS is faster when it's set to false.
  32648. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32649. */
  32650. /**
  32651. * Gets if `setParticles()` computes the particle colors or not.
  32652. * Default value : true. The SPS is faster when it's set to false.
  32653. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32654. */
  32655. computeParticleColor: boolean;
  32656. /**
  32657. * Gets if `setParticles()` computes the particle textures or not.
  32658. * Default value : true. The SPS is faster when it's set to false.
  32659. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32660. */
  32661. computeParticleTexture: boolean;
  32662. /**
  32663. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32664. * Default value : false. The SPS is faster when it's set to false.
  32665. * Note : the particle custom vertex positions aren't stored values.
  32666. */
  32667. /**
  32668. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32669. * Default value : false. The SPS is faster when it's set to false.
  32670. * Note : the particle custom vertex positions aren't stored values.
  32671. */
  32672. computeParticleVertex: boolean;
  32673. /**
  32674. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32675. */
  32676. /**
  32677. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32678. */
  32679. computeBoundingBox: boolean;
  32680. /**
  32681. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32682. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32683. * Default : `true`
  32684. */
  32685. /**
  32686. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32687. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32688. * Default : `true`
  32689. */
  32690. depthSortParticles: boolean;
  32691. /**
  32692. * This function does nothing. It may be overwritten to set all the particle first values.
  32693. * The SPS doesn't call this function, you may have to call it by your own.
  32694. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32695. */
  32696. initParticles(): void;
  32697. /**
  32698. * This function does nothing. It may be overwritten to recycle a particle.
  32699. * The SPS doesn't call this function, you may have to call it by your own.
  32700. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32701. * @param particle The particle to recycle
  32702. * @returns the recycled particle
  32703. */
  32704. recycleParticle(particle: SolidParticle): SolidParticle;
  32705. /**
  32706. * Updates a particle : this function should be overwritten by the user.
  32707. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32708. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32709. * @example : just set a particle position or velocity and recycle conditions
  32710. * @param particle The particle to update
  32711. * @returns the updated particle
  32712. */
  32713. updateParticle(particle: SolidParticle): SolidParticle;
  32714. /**
  32715. * Updates a vertex of a particle : it can be overwritten by the user.
  32716. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32717. * @param particle the current particle
  32718. * @param vertex the current index of the current particle
  32719. * @param pt the index of the current vertex in the particle shape
  32720. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  32721. * @example : just set a vertex particle position
  32722. * @returns the updated vertex
  32723. */
  32724. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  32725. /**
  32726. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32727. * This does nothing and may be overwritten by the user.
  32728. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32729. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32730. * @param update the boolean update value actually passed to setParticles()
  32731. */
  32732. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32733. /**
  32734. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32735. * This will be passed three parameters.
  32736. * This does nothing and may be overwritten by the user.
  32737. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32738. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32739. * @param update the boolean update value actually passed to setParticles()
  32740. */
  32741. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32742. }
  32743. }
  32744. declare module BABYLON {
  32745. /**
  32746. * Type of sub emitter
  32747. */
  32748. enum SubEmitterType {
  32749. /**
  32750. * Attached to the particle over it's lifetime
  32751. */
  32752. ATTACHED = 0,
  32753. /**
  32754. * Created when the particle dies
  32755. */
  32756. END = 1
  32757. }
  32758. /**
  32759. * Sub emitter class used to emit particles from an existing particle
  32760. */
  32761. class SubEmitter {
  32762. /**
  32763. * the particle system to be used by the sub emitter
  32764. */
  32765. particleSystem: ParticleSystem;
  32766. /**
  32767. * Type of the submitter (Default: END)
  32768. */
  32769. type: SubEmitterType;
  32770. /**
  32771. * 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)
  32772. * Note: This only is supported when using an emitter of type Mesh
  32773. */
  32774. inheritDirection: boolean;
  32775. /**
  32776. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  32777. */
  32778. inheritedVelocityAmount: number;
  32779. /**
  32780. * Creates a sub emitter
  32781. * @param particleSystem the particle system to be used by the sub emitter
  32782. */
  32783. constructor(
  32784. /**
  32785. * the particle system to be used by the sub emitter
  32786. */
  32787. particleSystem: ParticleSystem);
  32788. /**
  32789. * Clones the sub emitter
  32790. * @returns the cloned sub emitter
  32791. */
  32792. clone(): SubEmitter;
  32793. /**
  32794. * Serialize current object to a JSON object
  32795. * @returns the serialized object
  32796. */
  32797. serialize(): any;
  32798. /**
  32799. * Creates a new SubEmitter from a serialized JSON version
  32800. * @param serializationObject defines the JSON object to read from
  32801. * @param scene defines the hosting scene
  32802. * @param rootUrl defines the rootUrl for data loading
  32803. * @returns a new SubEmitter
  32804. */
  32805. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  32806. /** Release associated resources */
  32807. dispose(): void;
  32808. }
  32809. }
  32810. declare module BABYLON {
  32811. /**
  32812. * Interface used to describe a physics joint
  32813. */
  32814. interface PhysicsImpostorJoint {
  32815. /** Defines the main impostor to which the joint is linked */
  32816. mainImpostor: PhysicsImpostor;
  32817. /** Defines the impostor that is connected to the main impostor using this joint */
  32818. connectedImpostor: PhysicsImpostor;
  32819. /** Defines the joint itself */
  32820. joint: PhysicsJoint;
  32821. }
  32822. /** @hidden */
  32823. interface IPhysicsEnginePlugin {
  32824. world: any;
  32825. name: string;
  32826. setGravity(gravity: Vector3): void;
  32827. setTimeStep(timeStep: number): void;
  32828. getTimeStep(): number;
  32829. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32830. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32831. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32832. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32833. removePhysicsBody(impostor: PhysicsImpostor): void;
  32834. generateJoint(joint: PhysicsImpostorJoint): void;
  32835. removeJoint(joint: PhysicsImpostorJoint): void;
  32836. isSupported(): boolean;
  32837. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32838. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32839. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32840. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32841. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32842. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32843. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32844. getBodyMass(impostor: PhysicsImpostor): number;
  32845. getBodyFriction(impostor: PhysicsImpostor): number;
  32846. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32847. getBodyRestitution(impostor: PhysicsImpostor): number;
  32848. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32849. sleepBody(impostor: PhysicsImpostor): void;
  32850. wakeUpBody(impostor: PhysicsImpostor): void;
  32851. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32852. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32853. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32854. getRadius(impostor: PhysicsImpostor): number;
  32855. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32856. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32857. dispose(): void;
  32858. }
  32859. /**
  32860. * Interface used to define a physics engine
  32861. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32862. */
  32863. interface IPhysicsEngine {
  32864. /**
  32865. * Gets the gravity vector used by the simulation
  32866. */
  32867. gravity: Vector3;
  32868. /**
  32869. * Sets the gravity vector used by the simulation
  32870. * @param gravity defines the gravity vector to use
  32871. */
  32872. setGravity(gravity: Vector3): void;
  32873. /**
  32874. * Set the time step of the physics engine.
  32875. * Default is 1/60.
  32876. * To slow it down, enter 1/600 for example.
  32877. * To speed it up, 1/30
  32878. * @param newTimeStep the new timestep to apply to this world.
  32879. */
  32880. setTimeStep(newTimeStep: number): void;
  32881. /**
  32882. * Get the time step of the physics engine.
  32883. * @returns the current time step
  32884. */
  32885. getTimeStep(): number;
  32886. /**
  32887. * Release all resources
  32888. */
  32889. dispose(): void;
  32890. /**
  32891. * Gets the name of the current physics plugin
  32892. * @returns the name of the plugin
  32893. */
  32894. getPhysicsPluginName(): string;
  32895. /**
  32896. * Adding a new impostor for the impostor tracking.
  32897. * This will be done by the impostor itself.
  32898. * @param impostor the impostor to add
  32899. */
  32900. addImpostor(impostor: PhysicsImpostor): void;
  32901. /**
  32902. * Remove an impostor from the engine.
  32903. * This impostor and its mesh will not longer be updated by the physics engine.
  32904. * @param impostor the impostor to remove
  32905. */
  32906. removeImpostor(impostor: PhysicsImpostor): void;
  32907. /**
  32908. * Add a joint to the physics engine
  32909. * @param mainImpostor defines the main impostor to which the joint is added.
  32910. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32911. * @param joint defines the joint that will connect both impostors.
  32912. */
  32913. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32914. /**
  32915. * Removes a joint from the simulation
  32916. * @param mainImpostor defines the impostor used with the joint
  32917. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32918. * @param joint defines the joint to remove
  32919. */
  32920. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32921. /**
  32922. * Gets the current plugin used to run the simulation
  32923. * @returns current plugin
  32924. */
  32925. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32926. /**
  32927. * Gets the list of physic impostors
  32928. * @returns an array of PhysicsImpostor
  32929. */
  32930. getImpostors(): Array<PhysicsImpostor>;
  32931. /**
  32932. * Gets the impostor for a physics enabled object
  32933. * @param object defines the object impersonated by the impostor
  32934. * @returns the PhysicsImpostor or null if not found
  32935. */
  32936. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32937. /**
  32938. * Gets the impostor for a physics body object
  32939. * @param body defines physics body used by the impostor
  32940. * @returns the PhysicsImpostor or null if not found
  32941. */
  32942. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32943. /**
  32944. * Called by the scene. No need to call it.
  32945. * @param delta defines the timespam between frames
  32946. */
  32947. _step(delta: number): void;
  32948. }
  32949. }
  32950. declare module BABYLON {
  32951. /**
  32952. * Class used to control physics engine
  32953. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32954. */
  32955. class PhysicsEngine implements IPhysicsEngine {
  32956. private _physicsPlugin;
  32957. /**
  32958. * Global value used to control the smallest number supported by the simulation
  32959. */
  32960. static Epsilon: number;
  32961. private _impostors;
  32962. private _joints;
  32963. /**
  32964. * Gets the gravity vector used by the simulation
  32965. */
  32966. gravity: Vector3;
  32967. /**
  32968. * Creates a new Physics Engine
  32969. * @param gravity defines the gravity vector used by the simulation
  32970. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  32971. */
  32972. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  32973. /**
  32974. * Sets the gravity vector used by the simulation
  32975. * @param gravity defines the gravity vector to use
  32976. */
  32977. setGravity(gravity: Vector3): void;
  32978. /**
  32979. * Set the time step of the physics engine.
  32980. * Default is 1/60.
  32981. * To slow it down, enter 1/600 for example.
  32982. * To speed it up, 1/30
  32983. * @param newTimeStep defines the new timestep to apply to this world.
  32984. */
  32985. setTimeStep(newTimeStep?: number): void;
  32986. /**
  32987. * Get the time step of the physics engine.
  32988. * @returns the current time step
  32989. */
  32990. getTimeStep(): number;
  32991. /**
  32992. * Release all resources
  32993. */
  32994. dispose(): void;
  32995. /**
  32996. * Gets the name of the current physics plugin
  32997. * @returns the name of the plugin
  32998. */
  32999. getPhysicsPluginName(): string;
  33000. /**
  33001. * Adding a new impostor for the impostor tracking.
  33002. * This will be done by the impostor itself.
  33003. * @param impostor the impostor to add
  33004. */
  33005. addImpostor(impostor: PhysicsImpostor): void;
  33006. /**
  33007. * Remove an impostor from the engine.
  33008. * This impostor and its mesh will not longer be updated by the physics engine.
  33009. * @param impostor the impostor to remove
  33010. */
  33011. removeImpostor(impostor: PhysicsImpostor): void;
  33012. /**
  33013. * Add a joint to the physics engine
  33014. * @param mainImpostor defines the main impostor to which the joint is added.
  33015. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33016. * @param joint defines the joint that will connect both impostors.
  33017. */
  33018. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33019. /**
  33020. * Removes a joint from the simulation
  33021. * @param mainImpostor defines the impostor used with the joint
  33022. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33023. * @param joint defines the joint to remove
  33024. */
  33025. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33026. /**
  33027. * Called by the scene. No need to call it.
  33028. * @param delta defines the timespam between frames
  33029. */
  33030. _step(delta: number): void;
  33031. /**
  33032. * Gets the current plugin used to run the simulation
  33033. * @returns current plugin
  33034. */
  33035. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33036. /**
  33037. * Gets the list of physic impostors
  33038. * @returns an array of PhysicsImpostor
  33039. */
  33040. getImpostors(): Array<PhysicsImpostor>;
  33041. /**
  33042. * Gets the impostor for a physics enabled object
  33043. * @param object defines the object impersonated by the impostor
  33044. * @returns the PhysicsImpostor or null if not found
  33045. */
  33046. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33047. /**
  33048. * Gets the impostor for a physics body object
  33049. * @param body defines physics body used by the impostor
  33050. * @returns the PhysicsImpostor or null if not found
  33051. */
  33052. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33053. }
  33054. }
  33055. declare module BABYLON {
  33056. interface Scene {
  33057. /** @hidden (Backing field) */
  33058. _physicsEngine: Nullable<IPhysicsEngine>;
  33059. /**
  33060. * Gets the current physics engine
  33061. * @returns a IPhysicsEngine or null if none attached
  33062. */
  33063. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  33064. /**
  33065. * Enables physics to the current scene
  33066. * @param gravity defines the scene's gravity for the physics engine
  33067. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  33068. * @return a boolean indicating if the physics engine was initialized
  33069. */
  33070. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  33071. /**
  33072. * Disables and disposes the physics engine associated with the scene
  33073. */
  33074. disablePhysicsEngine(): void;
  33075. /**
  33076. * Gets a boolean indicating if there is an active physics engine
  33077. * @returns a boolean indicating if there is an active physics engine
  33078. */
  33079. isPhysicsEnabled(): boolean;
  33080. /**
  33081. * Deletes a physics compound impostor
  33082. * @param compound defines the compound to delete
  33083. */
  33084. deleteCompoundImpostor(compound: any): void;
  33085. /**
  33086. * An event triggered when physic simulation is about to be run
  33087. */
  33088. onBeforePhysicsObservable: Observable<Scene>;
  33089. /**
  33090. * An event triggered when physic simulation has been done
  33091. */
  33092. onAfterPhysicsObservable: Observable<Scene>;
  33093. }
  33094. interface AbstractMesh {
  33095. /** @hidden */
  33096. _physicsImpostor: Nullable<PhysicsImpostor>;
  33097. /**
  33098. * Gets or sets impostor used for physic simulation
  33099. * @see http://doc.babylonjs.com/features/physics_engine
  33100. */
  33101. physicsImpostor: Nullable<PhysicsImpostor>;
  33102. /**
  33103. * Gets the current physics impostor
  33104. * @see http://doc.babylonjs.com/features/physics_engine
  33105. * @returns a physics impostor or null
  33106. */
  33107. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  33108. /** Apply a physic impulse to the mesh
  33109. * @param force defines the force to apply
  33110. * @param contactPoint defines where to apply the force
  33111. * @returns the current mesh
  33112. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33113. */
  33114. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  33115. /**
  33116. * Creates a physic joint between two meshes
  33117. * @param otherMesh defines the other mesh to use
  33118. * @param pivot1 defines the pivot to use on this mesh
  33119. * @param pivot2 defines the pivot to use on the other mesh
  33120. * @param options defines additional options (can be plugin dependent)
  33121. * @returns the current mesh
  33122. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  33123. */
  33124. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  33125. /** @hidden */
  33126. _disposePhysicsObserver: Nullable<Observer<Node>>;
  33127. }
  33128. /**
  33129. * Defines the physics engine scene component responsible to manage a physics engine
  33130. */
  33131. class PhysicsEngineSceneComponent implements ISceneComponent {
  33132. /**
  33133. * The component name helpful to identify the component in the list of scene components.
  33134. */
  33135. readonly name: string;
  33136. /**
  33137. * The scene the component belongs to.
  33138. */
  33139. scene: Scene;
  33140. /**
  33141. * Creates a new instance of the component for the given scene
  33142. * @param scene Defines the scene to register the component in
  33143. */
  33144. constructor(scene: Scene);
  33145. /**
  33146. * Registers the component in a given scene
  33147. */
  33148. register(): void;
  33149. /**
  33150. * Rebuilds the elements related to this component in case of
  33151. * context lost for instance.
  33152. */
  33153. rebuild(): void;
  33154. /**
  33155. * Disposes the component and the associated ressources
  33156. */
  33157. dispose(): void;
  33158. }
  33159. }
  33160. declare module BABYLON {
  33161. /**
  33162. * A helper for physics simulations
  33163. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33164. */
  33165. class PhysicsHelper {
  33166. private _scene;
  33167. private _physicsEngine;
  33168. /**
  33169. * Initializes the Physics helper
  33170. * @param scene Babylon.js scene
  33171. */
  33172. constructor(scene: Scene);
  33173. /**
  33174. * Applies a radial explosion impulse
  33175. * @param origin the origin of the explosion
  33176. * @param radius the explosion radius
  33177. * @param strength the explosion strength
  33178. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33179. * @returns A physics radial explosion event, or null
  33180. */
  33181. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33182. /**
  33183. * Applies a radial explosion force
  33184. * @param origin the origin of the explosion
  33185. * @param radius the explosion radius
  33186. * @param strength the explosion strength
  33187. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33188. * @returns A physics radial explosion event, or null
  33189. */
  33190. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33191. /**
  33192. * Creates a gravitational field
  33193. * @param origin the origin of the explosion
  33194. * @param radius the explosion radius
  33195. * @param strength the explosion strength
  33196. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33197. * @returns A physics gravitational field event, or null
  33198. */
  33199. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  33200. /**
  33201. * Creates a physics updraft event
  33202. * @param origin the origin of the updraft
  33203. * @param radius the radius of the updraft
  33204. * @param strength the strength of the updraft
  33205. * @param height the height of the updraft
  33206. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  33207. * @returns A physics updraft event, or null
  33208. */
  33209. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  33210. /**
  33211. * Creates a physics vortex event
  33212. * @param origin the of the vortex
  33213. * @param radius the radius of the vortex
  33214. * @param strength the strength of the vortex
  33215. * @param height the height of the vortex
  33216. * @returns a Physics vortex event, or null
  33217. * A physics vortex event or null
  33218. */
  33219. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  33220. }
  33221. /**
  33222. * Represents a physics radial explosion event
  33223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33224. */
  33225. class PhysicsRadialExplosionEvent {
  33226. private _scene;
  33227. private _sphere;
  33228. private _sphereOptions;
  33229. private _rays;
  33230. private _dataFetched;
  33231. /**
  33232. * Initializes a radial explosioin event
  33233. * @param scene BabylonJS scene
  33234. */
  33235. constructor(scene: Scene);
  33236. /**
  33237. * Returns the data related to the radial explosion event (sphere & rays).
  33238. * @returns The radial explosion event data
  33239. */
  33240. getData(): PhysicsRadialExplosionEventData;
  33241. /**
  33242. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  33243. * @param impostor A physics imposter
  33244. * @param origin the origin of the explosion
  33245. * @param radius the explosion radius
  33246. * @param strength the explosion strength
  33247. * @param falloff possible options: Constant & Linear
  33248. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  33249. */
  33250. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  33251. /**
  33252. * Disposes the sphere.
  33253. * @param force Specifies if the sphere should be disposed by force
  33254. */
  33255. dispose(force?: boolean): void;
  33256. /*** Helpers ***/
  33257. private _prepareSphere;
  33258. private _intersectsWithSphere;
  33259. }
  33260. /**
  33261. * Represents a gravitational field event
  33262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33263. */
  33264. class PhysicsGravitationalFieldEvent {
  33265. private _physicsHelper;
  33266. private _scene;
  33267. private _origin;
  33268. private _radius;
  33269. private _strength;
  33270. private _falloff;
  33271. private _tickCallback;
  33272. private _sphere;
  33273. private _dataFetched;
  33274. /**
  33275. * Initializes the physics gravitational field event
  33276. * @param physicsHelper A physics helper
  33277. * @param scene BabylonJS scene
  33278. * @param origin The origin position of the gravitational field event
  33279. * @param radius The radius of the gravitational field event
  33280. * @param strength The strength of the gravitational field event
  33281. * @param falloff The falloff for the gravitational field event
  33282. */
  33283. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  33284. /**
  33285. * Returns the data related to the gravitational field event (sphere).
  33286. * @returns A gravitational field event
  33287. */
  33288. getData(): PhysicsGravitationalFieldEventData;
  33289. /**
  33290. * Enables the gravitational field.
  33291. */
  33292. enable(): void;
  33293. /**
  33294. * Disables the gravitational field.
  33295. */
  33296. disable(): void;
  33297. /**
  33298. * Disposes the sphere.
  33299. * @param force The force to dispose from the gravitational field event
  33300. */
  33301. dispose(force?: boolean): void;
  33302. private _tick;
  33303. }
  33304. /**
  33305. * Represents a physics updraft event
  33306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33307. */
  33308. class PhysicsUpdraftEvent {
  33309. private _scene;
  33310. private _origin;
  33311. private _radius;
  33312. private _strength;
  33313. private _height;
  33314. private _updraftMode;
  33315. private _physicsEngine;
  33316. private _originTop;
  33317. private _originDirection;
  33318. private _tickCallback;
  33319. private _cylinder;
  33320. private _cylinderPosition;
  33321. private _dataFetched;
  33322. /**
  33323. * Initializes the physics updraft event
  33324. * @param _scene BabylonJS scene
  33325. * @param _origin The origin position of the updraft
  33326. * @param _radius The radius of the updraft
  33327. * @param _strength The strength of the updraft
  33328. * @param _height The height of the updraft
  33329. * @param _updraftMode The mode of the updraft
  33330. */
  33331. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  33332. /**
  33333. * Returns the data related to the updraft event (cylinder).
  33334. * @returns A physics updraft event
  33335. */
  33336. getData(): PhysicsUpdraftEventData;
  33337. /**
  33338. * Enables the updraft.
  33339. */
  33340. enable(): void;
  33341. /**
  33342. * Disables the cortex.
  33343. */
  33344. disable(): void;
  33345. /**
  33346. * Disposes the sphere.
  33347. * @param force Specifies if the updraft should be disposed by force
  33348. */
  33349. dispose(force?: boolean): void;
  33350. private getImpostorForceAndContactPoint;
  33351. private _tick;
  33352. /*** Helpers ***/
  33353. private _prepareCylinder;
  33354. private _intersectsWithCylinder;
  33355. }
  33356. /**
  33357. * Represents a physics vortex event
  33358. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33359. */
  33360. class PhysicsVortexEvent {
  33361. private _scene;
  33362. private _origin;
  33363. private _radius;
  33364. private _strength;
  33365. private _height;
  33366. private _physicsEngine;
  33367. private _originTop;
  33368. private _centripetalForceThreshold;
  33369. private _updraftMultiplier;
  33370. private _tickCallback;
  33371. private _cylinder;
  33372. private _cylinderPosition;
  33373. private _dataFetched;
  33374. /**
  33375. * Initializes the physics vortex event
  33376. * @param _scene The BabylonJS scene
  33377. * @param _origin The origin position of the vortex
  33378. * @param _radius The radius of the vortex
  33379. * @param _strength The strength of the vortex
  33380. * @param _height The height of the vortex
  33381. */
  33382. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  33383. /**
  33384. * Returns the data related to the vortex event (cylinder).
  33385. * @returns The physics vortex event data
  33386. */
  33387. getData(): PhysicsVortexEventData;
  33388. /**
  33389. * Enables the vortex.
  33390. */
  33391. enable(): void;
  33392. /**
  33393. * Disables the cortex.
  33394. */
  33395. disable(): void;
  33396. /**
  33397. * Disposes the sphere.
  33398. * @param force
  33399. */
  33400. dispose(force?: boolean): void;
  33401. private getImpostorForceAndContactPoint;
  33402. private _tick;
  33403. /*** Helpers ***/
  33404. private _prepareCylinder;
  33405. private _intersectsWithCylinder;
  33406. }
  33407. /**
  33408. * The strenght of the force in correspondence to the distance of the affected object
  33409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33410. */
  33411. enum PhysicsRadialImpulseFalloff {
  33412. /** Defines that impulse is constant in strength across it's whole radius */
  33413. Constant = 0,
  33414. /** DEfines that impulse gets weaker if it's further from the origin */
  33415. Linear = 1
  33416. }
  33417. /**
  33418. * The strength of the force in correspondence to the distance of the affected object
  33419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33420. */
  33421. enum PhysicsUpdraftMode {
  33422. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  33423. Center = 0,
  33424. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  33425. Perpendicular = 1
  33426. }
  33427. /**
  33428. * Interface for a physics force and contact point
  33429. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33430. */
  33431. interface PhysicsForceAndContactPoint {
  33432. /**
  33433. * The force applied at the contact point
  33434. */
  33435. force: Vector3;
  33436. /**
  33437. * The contact point
  33438. */
  33439. contactPoint: Vector3;
  33440. }
  33441. /**
  33442. * Interface for radial explosion event data
  33443. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33444. */
  33445. interface PhysicsRadialExplosionEventData {
  33446. /**
  33447. * A sphere used for the radial explosion event
  33448. */
  33449. sphere: Mesh;
  33450. /**
  33451. * An array of rays for the radial explosion event
  33452. */
  33453. rays: Array<Ray>;
  33454. }
  33455. /**
  33456. * Interface for gravitational field event data
  33457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33458. */
  33459. interface PhysicsGravitationalFieldEventData {
  33460. /**
  33461. * A sphere mesh used for the gravitational field event
  33462. */
  33463. sphere: Mesh;
  33464. }
  33465. /**
  33466. * Interface for updraft event data
  33467. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33468. */
  33469. interface PhysicsUpdraftEventData {
  33470. /**
  33471. * A cylinder used for the updraft event
  33472. */
  33473. cylinder: Mesh;
  33474. }
  33475. /**
  33476. * Interface for vortex event data
  33477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33478. */
  33479. interface PhysicsVortexEventData {
  33480. /**
  33481. * A cylinder used for the vortex event
  33482. */
  33483. cylinder: Mesh;
  33484. }
  33485. }
  33486. declare module BABYLON {
  33487. /**
  33488. * The interface for the physics imposter parameters
  33489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33490. */
  33491. interface PhysicsImpostorParameters {
  33492. /**
  33493. * The mass of the physics imposter
  33494. */
  33495. mass: number;
  33496. /**
  33497. * The friction of the physics imposter
  33498. */
  33499. friction?: number;
  33500. /**
  33501. * The coefficient of restitution of the physics imposter
  33502. */
  33503. restitution?: number;
  33504. /**
  33505. * The native options of the physics imposter
  33506. */
  33507. nativeOptions?: any;
  33508. /**
  33509. * Specifies if the parent should be ignored
  33510. */
  33511. ignoreParent?: boolean;
  33512. /**
  33513. * Specifies if bi-directional transformations should be disabled
  33514. */
  33515. disableBidirectionalTransformation?: boolean;
  33516. }
  33517. /**
  33518. * Interface for a physics-enabled object
  33519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33520. */
  33521. interface IPhysicsEnabledObject {
  33522. /**
  33523. * The position of the physics-enabled object
  33524. */
  33525. position: Vector3;
  33526. /**
  33527. * The rotation of the physics-enabled object
  33528. */
  33529. rotationQuaternion: Nullable<Quaternion>;
  33530. /**
  33531. * The scale of the physics-enabled object
  33532. */
  33533. scaling: Vector3;
  33534. /**
  33535. * The rotation of the physics-enabled object
  33536. */
  33537. rotation?: Vector3;
  33538. /**
  33539. * The parent of the physics-enabled object
  33540. */
  33541. parent?: any;
  33542. /**
  33543. * The bounding info of the physics-enabled object
  33544. * @returns The bounding info of the physics-enabled object
  33545. */
  33546. getBoundingInfo(): BoundingInfo;
  33547. /**
  33548. * Computes the world matrix
  33549. * @param force Specifies if the world matrix should be computed by force
  33550. * @returns A world matrix
  33551. */
  33552. computeWorldMatrix(force: boolean): Matrix;
  33553. /**
  33554. * Gets the world matrix
  33555. * @returns A world matrix
  33556. */
  33557. getWorldMatrix?(): Matrix;
  33558. /**
  33559. * Gets the child meshes
  33560. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33561. * @returns An array of abstract meshes
  33562. */
  33563. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33564. /**
  33565. * Gets the vertex data
  33566. * @param kind The type of vertex data
  33567. * @returns A nullable array of numbers, or a float32 array
  33568. */
  33569. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33570. /**
  33571. * Gets the indices from the mesh
  33572. * @returns A nullable array of index arrays
  33573. */
  33574. getIndices?(): Nullable<IndicesArray>;
  33575. /**
  33576. * Gets the scene from the mesh
  33577. * @returns the indices array or null
  33578. */
  33579. getScene?(): Scene;
  33580. /**
  33581. * Gets the absolute position from the mesh
  33582. * @returns the absolute position
  33583. */
  33584. getAbsolutePosition(): Vector3;
  33585. /**
  33586. * Gets the absolute pivot point from the mesh
  33587. * @returns the absolute pivot point
  33588. */
  33589. getAbsolutePivotPoint(): Vector3;
  33590. /**
  33591. * Rotates the mesh
  33592. * @param axis The axis of rotation
  33593. * @param amount The amount of rotation
  33594. * @param space The space of the rotation
  33595. * @returns The rotation transform node
  33596. */
  33597. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33598. /**
  33599. * Translates the mesh
  33600. * @param axis The axis of translation
  33601. * @param distance The distance of translation
  33602. * @param space The space of the translation
  33603. * @returns The transform node
  33604. */
  33605. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33606. /**
  33607. * Sets the absolute position of the mesh
  33608. * @param absolutePosition The absolute position of the mesh
  33609. * @returns The transform node
  33610. */
  33611. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33612. /**
  33613. * Gets the class name of the mesh
  33614. * @returns The class name
  33615. */
  33616. getClassName(): string;
  33617. }
  33618. /**
  33619. * Represents a physics imposter
  33620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33621. */
  33622. class PhysicsImpostor {
  33623. /**
  33624. * The physics-enabled object used as the physics imposter
  33625. */
  33626. object: IPhysicsEnabledObject;
  33627. /**
  33628. * The type of the physics imposter
  33629. */
  33630. type: number;
  33631. private _options;
  33632. private _scene?;
  33633. /**
  33634. * The default object size of the imposter
  33635. */
  33636. static DEFAULT_OBJECT_SIZE: Vector3;
  33637. /**
  33638. * The identity quaternion of the imposter
  33639. */
  33640. static IDENTITY_QUATERNION: Quaternion;
  33641. private _physicsEngine;
  33642. private _physicsBody;
  33643. private _bodyUpdateRequired;
  33644. private _onBeforePhysicsStepCallbacks;
  33645. private _onAfterPhysicsStepCallbacks;
  33646. private _onPhysicsCollideCallbacks;
  33647. private _deltaPosition;
  33648. private _deltaRotation;
  33649. private _deltaRotationConjugated;
  33650. private _parent;
  33651. private _isDisposed;
  33652. private static _tmpVecs;
  33653. private static _tmpQuat;
  33654. /**
  33655. * Specifies if the physics imposter is disposed
  33656. */
  33657. readonly isDisposed: boolean;
  33658. /**
  33659. * Gets the mass of the physics imposter
  33660. */
  33661. mass: number;
  33662. /**
  33663. * Gets the coefficient of friction
  33664. */
  33665. /**
  33666. * Sets the coefficient of friction
  33667. */
  33668. friction: number;
  33669. /**
  33670. * Gets the coefficient of restitution
  33671. */
  33672. /**
  33673. * Sets the coefficient of restitution
  33674. */
  33675. restitution: number;
  33676. /**
  33677. * The unique id of the physics imposter
  33678. * set by the physics engine when adding this impostor to the array
  33679. */
  33680. uniqueId: number;
  33681. private _joints;
  33682. /**
  33683. * Initializes the physics imposter
  33684. * @param object The physics-enabled object used as the physics imposter
  33685. * @param type The type of the physics imposter
  33686. * @param _options The options for the physics imposter
  33687. * @param _scene The Babylon scene
  33688. */
  33689. constructor(
  33690. /**
  33691. * The physics-enabled object used as the physics imposter
  33692. */
  33693. object: IPhysicsEnabledObject,
  33694. /**
  33695. * The type of the physics imposter
  33696. */
  33697. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33698. /**
  33699. * This function will completly initialize this impostor.
  33700. * It will create a new body - but only if this mesh has no parent.
  33701. * If it has, this impostor will not be used other than to define the impostor
  33702. * of the child mesh.
  33703. * @hidden
  33704. */
  33705. _init(): void;
  33706. private _getPhysicsParent;
  33707. /**
  33708. * Should a new body be generated.
  33709. * @returns boolean specifying if body initialization is required
  33710. */
  33711. isBodyInitRequired(): boolean;
  33712. /**
  33713. * Sets the updated scaling
  33714. * @param updated Specifies if the scaling is updated
  33715. */
  33716. setScalingUpdated(updated: boolean): void;
  33717. /**
  33718. * Force a regeneration of this or the parent's impostor's body.
  33719. * Use under cautious - This will remove all joints already implemented.
  33720. */
  33721. forceUpdate(): void;
  33722. /**
  33723. * Gets the body that holds this impostor. Either its own, or its parent.
  33724. */
  33725. /**
  33726. * Set the physics body. Used mainly by the physics engine/plugin
  33727. */
  33728. physicsBody: any;
  33729. /**
  33730. * Get the parent of the physics imposter
  33731. * @returns Physics imposter or null
  33732. */
  33733. /**
  33734. * Sets the parent of the physics imposter
  33735. */
  33736. parent: Nullable<PhysicsImpostor>;
  33737. /**
  33738. * Resets the update flags
  33739. */
  33740. resetUpdateFlags(): void;
  33741. /**
  33742. * Gets the object extend size
  33743. * @returns the object extend size
  33744. */
  33745. getObjectExtendSize(): Vector3;
  33746. /**
  33747. * Gets the object center
  33748. * @returns The object center
  33749. */
  33750. getObjectCenter(): Vector3;
  33751. /**
  33752. * Get a specific parametes from the options parameter
  33753. * @param paramName The object parameter name
  33754. * @returns The object parameter
  33755. */
  33756. getParam(paramName: string): any;
  33757. /**
  33758. * Sets a specific parameter in the options given to the physics plugin
  33759. * @param paramName The parameter name
  33760. * @param value The value of the parameter
  33761. */
  33762. setParam(paramName: string, value: number): void;
  33763. /**
  33764. * Specifically change the body's mass option. Won't recreate the physics body object
  33765. * @param mass The mass of the physics imposter
  33766. */
  33767. setMass(mass: number): void;
  33768. /**
  33769. * Gets the linear velocity
  33770. * @returns linear velocity or null
  33771. */
  33772. getLinearVelocity(): Nullable<Vector3>;
  33773. /**
  33774. * Sets the linear velocity
  33775. * @param velocity linear velocity or null
  33776. */
  33777. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33778. /**
  33779. * Gets the angular velocity
  33780. * @returns angular velocity or null
  33781. */
  33782. getAngularVelocity(): Nullable<Vector3>;
  33783. /**
  33784. * Sets the angular velocity
  33785. * @param velocity The velocity or null
  33786. */
  33787. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33788. /**
  33789. * Execute a function with the physics plugin native code
  33790. * Provide a function the will have two variables - the world object and the physics body object
  33791. * @param func The function to execute with the physics plugin native code
  33792. */
  33793. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33794. /**
  33795. * Register a function that will be executed before the physics world is stepping forward
  33796. * @param func The function to execute before the physics world is stepped forward
  33797. */
  33798. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33799. /**
  33800. * Unregister a function that will be executed before the physics world is stepping forward
  33801. * @param func The function to execute before the physics world is stepped forward
  33802. */
  33803. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33804. /**
  33805. * Register a function that will be executed after the physics step
  33806. * @param func The function to execute after physics step
  33807. */
  33808. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33809. /**
  33810. * Unregisters a function that will be executed after the physics step
  33811. * @param func The function to execute after physics step
  33812. */
  33813. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33814. /**
  33815. * register a function that will be executed when this impostor collides against a different body
  33816. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33817. * @param func Callback that is executed on collision
  33818. */
  33819. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33820. /**
  33821. * Unregisters the physics imposter on contact
  33822. * @param collideAgainst The physics object to collide against
  33823. * @param func Callback to execute on collision
  33824. */
  33825. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33826. private _tmpQuat;
  33827. private _tmpQuat2;
  33828. /**
  33829. * Get the parent rotation
  33830. * @returns The parent rotation
  33831. */
  33832. getParentsRotation(): Quaternion;
  33833. /**
  33834. * this function is executed by the physics engine.
  33835. */
  33836. beforeStep: () => void;
  33837. /**
  33838. * this function is executed by the physics engine
  33839. */
  33840. afterStep: () => void;
  33841. /**
  33842. * Legacy collision detection event support
  33843. */
  33844. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33845. /**
  33846. * event and body object due to cannon's event-based architecture.
  33847. */
  33848. onCollide: (e: {
  33849. body: any;
  33850. }) => void;
  33851. /**
  33852. * Apply a force
  33853. * @param force The force to apply
  33854. * @param contactPoint The contact point for the force
  33855. * @returns The physics imposter
  33856. */
  33857. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33858. /**
  33859. * Apply an impulse
  33860. * @param force The impulse force
  33861. * @param contactPoint The contact point for the impulse force
  33862. * @returns The physics imposter
  33863. */
  33864. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33865. /**
  33866. * A help function to create a joint
  33867. * @param otherImpostor A physics imposter used to create a joint
  33868. * @param jointType The type of joint
  33869. * @param jointData The data for the joint
  33870. * @returns The physics imposter
  33871. */
  33872. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33873. /**
  33874. * Add a joint to this impostor with a different impostor
  33875. * @param otherImpostor A physics imposter used to add a joint
  33876. * @param joint The joint to add
  33877. * @returns The physics imposter
  33878. */
  33879. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33880. /**
  33881. * Will keep this body still, in a sleep mode.
  33882. * @returns the physics imposter
  33883. */
  33884. sleep(): PhysicsImpostor;
  33885. /**
  33886. * Wake the body up.
  33887. * @returns The physics imposter
  33888. */
  33889. wakeUp(): PhysicsImpostor;
  33890. /**
  33891. * Clones the physics imposter
  33892. * @param newObject The physics imposter clones to this physics-enabled object
  33893. * @returns A nullable physics imposter
  33894. */
  33895. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33896. /**
  33897. * Disposes the physics imposter
  33898. */
  33899. dispose(): void;
  33900. /**
  33901. * Sets the delta position
  33902. * @param position The delta position amount
  33903. */
  33904. setDeltaPosition(position: Vector3): void;
  33905. /**
  33906. * Sets the delta rotation
  33907. * @param rotation The delta rotation amount
  33908. */
  33909. setDeltaRotation(rotation: Quaternion): void;
  33910. /**
  33911. * Gets the box size of the physics imposter and stores the result in the input parameter
  33912. * @param result Stores the box size
  33913. * @returns The physics imposter
  33914. */
  33915. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33916. /**
  33917. * Gets the radius of the physics imposter
  33918. * @returns Radius of the physics imposter
  33919. */
  33920. getRadius(): number;
  33921. /**
  33922. * Sync a bone with this impostor
  33923. * @param bone The bone to sync to the impostor.
  33924. * @param boneMesh The mesh that the bone is influencing.
  33925. * @param jointPivot The pivot of the joint / bone in local space.
  33926. * @param distToJoint Optional distance from the impostor to the joint.
  33927. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33928. */
  33929. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33930. /**
  33931. * Sync impostor to a bone
  33932. * @param bone The bone that the impostor will be synced to.
  33933. * @param boneMesh The mesh that the bone is influencing.
  33934. * @param jointPivot The pivot of the joint / bone in local space.
  33935. * @param distToJoint Optional distance from the impostor to the joint.
  33936. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33937. * @param boneAxis Optional vector3 axis the bone is aligned with
  33938. */
  33939. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33940. /**
  33941. * No-Imposter type
  33942. */
  33943. static NoImpostor: number;
  33944. /**
  33945. * Sphere-Imposter type
  33946. */
  33947. static SphereImpostor: number;
  33948. /**
  33949. * Box-Imposter type
  33950. */
  33951. static BoxImpostor: number;
  33952. /**
  33953. * Plane-Imposter type
  33954. */
  33955. static PlaneImpostor: number;
  33956. /**
  33957. * Mesh-imposter type
  33958. */
  33959. static MeshImpostor: number;
  33960. /**
  33961. * Cylinder-Imposter type
  33962. */
  33963. static CylinderImpostor: number;
  33964. /**
  33965. * Particle-Imposter type
  33966. */
  33967. static ParticleImpostor: number;
  33968. /**
  33969. * Heightmap-Imposter type
  33970. */
  33971. static HeightmapImpostor: number;
  33972. }
  33973. }
  33974. declare module BABYLON {
  33975. /**
  33976. * Interface for Physics-Joint data
  33977. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33978. */
  33979. interface PhysicsJointData {
  33980. /**
  33981. * The main pivot of the joint
  33982. */
  33983. mainPivot?: Vector3;
  33984. /**
  33985. * The connected pivot of the joint
  33986. */
  33987. connectedPivot?: Vector3;
  33988. /**
  33989. * The main axis of the joint
  33990. */
  33991. mainAxis?: Vector3;
  33992. /**
  33993. * The connected axis of the joint
  33994. */
  33995. connectedAxis?: Vector3;
  33996. /**
  33997. * The collision of the joint
  33998. */
  33999. collision?: boolean;
  34000. /**
  34001. * Native Oimo/Cannon/Energy data
  34002. */
  34003. nativeParams?: any;
  34004. }
  34005. /**
  34006. * This is a holder class for the physics joint created by the physics plugin
  34007. * It holds a set of functions to control the underlying joint
  34008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34009. */
  34010. class PhysicsJoint {
  34011. /**
  34012. * The type of the physics joint
  34013. */
  34014. type: number;
  34015. /**
  34016. * The data for the physics joint
  34017. */
  34018. jointData: PhysicsJointData;
  34019. private _physicsJoint;
  34020. protected _physicsPlugin: IPhysicsEnginePlugin;
  34021. /**
  34022. * Initializes the physics joint
  34023. * @param type The type of the physics joint
  34024. * @param jointData The data for the physics joint
  34025. */
  34026. constructor(
  34027. /**
  34028. * The type of the physics joint
  34029. */
  34030. type: number,
  34031. /**
  34032. * The data for the physics joint
  34033. */
  34034. jointData: PhysicsJointData);
  34035. /**
  34036. * Gets the physics joint
  34037. */
  34038. /**
  34039. * Sets the physics joint
  34040. */
  34041. physicsJoint: any;
  34042. /**
  34043. * Sets the physics plugin
  34044. */
  34045. physicsPlugin: IPhysicsEnginePlugin;
  34046. /**
  34047. * Execute a function that is physics-plugin specific.
  34048. * @param {Function} func the function that will be executed.
  34049. * It accepts two parameters: the physics world and the physics joint
  34050. */
  34051. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  34052. /**
  34053. * Distance-Joint type
  34054. */
  34055. static DistanceJoint: number;
  34056. /**
  34057. * Hinge-Joint type
  34058. */
  34059. static HingeJoint: number;
  34060. /**
  34061. * Ball-and-Socket joint type
  34062. */
  34063. static BallAndSocketJoint: number;
  34064. /**
  34065. * Wheel-Joint type
  34066. */
  34067. static WheelJoint: number;
  34068. /**
  34069. * Slider-Joint type
  34070. */
  34071. static SliderJoint: number;
  34072. /**
  34073. * Prismatic-Joint type
  34074. */
  34075. static PrismaticJoint: number;
  34076. /**
  34077. * Universal-Joint type
  34078. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  34079. */
  34080. static UniversalJoint: number;
  34081. /**
  34082. * Hinge-Joint 2 type
  34083. */
  34084. static Hinge2Joint: number;
  34085. /**
  34086. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  34087. */
  34088. static PointToPointJoint: number;
  34089. /**
  34090. * Spring-Joint type
  34091. */
  34092. static SpringJoint: number;
  34093. /**
  34094. * Lock-Joint type
  34095. */
  34096. static LockJoint: number;
  34097. }
  34098. /**
  34099. * A class representing a physics distance joint
  34100. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34101. */
  34102. class DistanceJoint extends PhysicsJoint {
  34103. /**
  34104. *
  34105. * @param jointData The data for the Distance-Joint
  34106. */
  34107. constructor(jointData: DistanceJointData);
  34108. /**
  34109. * Update the predefined distance.
  34110. * @param maxDistance The maximum preferred distance
  34111. * @param minDistance The minimum preferred distance
  34112. */
  34113. updateDistance(maxDistance: number, minDistance?: number): void;
  34114. }
  34115. /**
  34116. * Represents a Motor-Enabled Joint
  34117. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34118. */
  34119. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  34120. /**
  34121. * Initializes the Motor-Enabled Joint
  34122. * @param type The type of the joint
  34123. * @param jointData The physica joint data for the joint
  34124. */
  34125. constructor(type: number, jointData: PhysicsJointData);
  34126. /**
  34127. * Set the motor values.
  34128. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34129. * @param force the force to apply
  34130. * @param maxForce max force for this motor.
  34131. */
  34132. setMotor(force?: number, maxForce?: number): void;
  34133. /**
  34134. * Set the motor's limits.
  34135. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34136. * @param upperLimit The upper limit of the motor
  34137. * @param lowerLimit The lower limit of the motor
  34138. */
  34139. setLimit(upperLimit: number, lowerLimit?: number): void;
  34140. }
  34141. /**
  34142. * This class represents a single physics Hinge-Joint
  34143. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34144. */
  34145. class HingeJoint extends MotorEnabledJoint {
  34146. /**
  34147. * Initializes the Hinge-Joint
  34148. * @param jointData The joint data for the Hinge-Joint
  34149. */
  34150. constructor(jointData: PhysicsJointData);
  34151. /**
  34152. * Set the motor values.
  34153. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34154. * @param {number} force the force to apply
  34155. * @param {number} maxForce max force for this motor.
  34156. */
  34157. setMotor(force?: number, maxForce?: number): void;
  34158. /**
  34159. * Set the motor's limits.
  34160. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34161. * @param upperLimit The upper limit of the motor
  34162. * @param lowerLimit The lower limit of the motor
  34163. */
  34164. setLimit(upperLimit: number, lowerLimit?: number): void;
  34165. }
  34166. /**
  34167. * This class represents a dual hinge physics joint (same as wheel joint)
  34168. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34169. */
  34170. class Hinge2Joint extends MotorEnabledJoint {
  34171. /**
  34172. * Initializes the Hinge2-Joint
  34173. * @param jointData The joint data for the Hinge2-Joint
  34174. */
  34175. constructor(jointData: PhysicsJointData);
  34176. /**
  34177. * Set the motor values.
  34178. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34179. * @param {number} force the force to apply
  34180. * @param {number} maxForce max force for this motor.
  34181. * @param {motorIndex} the motor's index, 0 or 1.
  34182. */
  34183. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34184. /**
  34185. * Set the motor limits.
  34186. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34187. * @param {number} upperLimit the upper limit
  34188. * @param {number} lowerLimit lower limit
  34189. * @param {motorIndex} the motor's index, 0 or 1.
  34190. */
  34191. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34192. }
  34193. /**
  34194. * Interface for a motor enabled joint
  34195. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34196. */
  34197. interface IMotorEnabledJoint {
  34198. /**
  34199. * Physics joint
  34200. */
  34201. physicsJoint: any;
  34202. /**
  34203. * Sets the motor of the motor-enabled joint
  34204. * @param force The force of the motor
  34205. * @param maxForce The maximum force of the motor
  34206. * @param motorIndex The index of the motor
  34207. */
  34208. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34209. /**
  34210. * Sets the limit of the motor
  34211. * @param upperLimit The upper limit of the motor
  34212. * @param lowerLimit The lower limit of the motor
  34213. * @param motorIndex The index of the motor
  34214. */
  34215. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34216. }
  34217. /**
  34218. * Joint data for a Distance-Joint
  34219. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34220. */
  34221. interface DistanceJointData extends PhysicsJointData {
  34222. /**
  34223. * Max distance the 2 joint objects can be apart
  34224. */
  34225. maxDistance: number;
  34226. }
  34227. /**
  34228. * Joint data from a spring joint
  34229. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34230. */
  34231. interface SpringJointData extends PhysicsJointData {
  34232. /**
  34233. * Length of the spring
  34234. */
  34235. length: number;
  34236. /**
  34237. * Stiffness of the spring
  34238. */
  34239. stiffness: number;
  34240. /**
  34241. * Damping of the spring
  34242. */
  34243. damping: number;
  34244. /** this callback will be called when applying the force to the impostors. */
  34245. forceApplicationCallback: () => void;
  34246. }
  34247. }
  34248. declare module BABYLON {
  34249. interface AbstractScene {
  34250. /**
  34251. * The list of reflection probes added to the scene
  34252. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34253. */
  34254. reflectionProbes: Array<ReflectionProbe>;
  34255. /**
  34256. * Removes the given reflection probe from this scene.
  34257. * @param toRemove The reflection probe to remove
  34258. * @returns The index of the removed reflection probe
  34259. */
  34260. removeReflectionProbe(toRemove: ReflectionProbe): number;
  34261. /**
  34262. * Adds the given reflection probe to this scene.
  34263. * @param newReflectionProbe The reflection probe to add
  34264. */
  34265. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  34266. }
  34267. /**
  34268. * Class used to generate realtime reflection / refraction cube textures
  34269. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34270. */
  34271. class ReflectionProbe {
  34272. /** defines the name of the probe */
  34273. name: string;
  34274. private _scene;
  34275. private _renderTargetTexture;
  34276. private _projectionMatrix;
  34277. private _viewMatrix;
  34278. private _target;
  34279. private _add;
  34280. private _attachedMesh;
  34281. private _invertYAxis;
  34282. /** Gets or sets probe position (center of the cube map) */
  34283. position: Vector3;
  34284. /**
  34285. * Creates a new reflection probe
  34286. * @param name defines the name of the probe
  34287. * @param size defines the texture resolution (for each face)
  34288. * @param scene defines the hosting scene
  34289. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  34290. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  34291. */
  34292. constructor(
  34293. /** defines the name of the probe */
  34294. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  34295. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  34296. samples: number;
  34297. /** Gets or sets the refresh rate to use (on every frame by default) */
  34298. refreshRate: number;
  34299. /**
  34300. * Gets the hosting scene
  34301. * @returns a Scene
  34302. */
  34303. getScene(): Scene;
  34304. /** Gets the internal CubeTexture used to render to */
  34305. readonly cubeTexture: RenderTargetTexture;
  34306. /** Gets the list of meshes to render */
  34307. readonly renderList: Nullable<AbstractMesh[]>;
  34308. /**
  34309. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  34310. * @param mesh defines the mesh to attach to
  34311. */
  34312. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  34313. /**
  34314. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  34315. * @param renderingGroupId The rendering group id corresponding to its index
  34316. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34317. */
  34318. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34319. /**
  34320. * Clean all associated resources
  34321. */
  34322. dispose(): void;
  34323. /**
  34324. * Converts the reflection probe information to a readable string for debug purpose.
  34325. * @param fullDetails Supports for multiple levels of logging within scene loading
  34326. * @returns the human readable reflection probe info
  34327. */
  34328. toString(fullDetails?: boolean): string;
  34329. /**
  34330. * Get the class name of the relfection probe.
  34331. * @returns "ReflectionProbe"
  34332. */
  34333. getClassName(): string;
  34334. /**
  34335. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  34336. * @returns The JSON representation of the texture
  34337. */
  34338. serialize(): any;
  34339. /**
  34340. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  34341. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  34342. * @param scene Define the scene the parsed reflection probe should be instantiated in
  34343. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  34344. * @returns The parsed reflection probe if successful
  34345. */
  34346. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  34347. }
  34348. }
  34349. declare module BABYLON {
  34350. /**
  34351. * Postprocess used to generate anaglyphic rendering
  34352. */
  34353. class AnaglyphPostProcess extends PostProcess {
  34354. private _passedProcess;
  34355. /**
  34356. * Creates a new AnaglyphPostProcess
  34357. * @param name defines postprocess name
  34358. * @param options defines creation options or target ratio scale
  34359. * @param rigCameras defines cameras using this postprocess
  34360. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  34361. * @param engine defines hosting engine
  34362. * @param reusable defines if the postprocess will be reused multiple times per frame
  34363. */
  34364. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  34365. }
  34366. }
  34367. declare module BABYLON {
  34368. /**
  34369. * Post process used to render in black and white
  34370. */
  34371. class BlackAndWhitePostProcess extends PostProcess {
  34372. /**
  34373. * Linear about to convert he result to black and white (default: 1)
  34374. */
  34375. degree: number;
  34376. /**
  34377. * Creates a black and white post process
  34378. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  34379. * @param name The name of the effect.
  34380. * @param options The required width/height ratio to downsize to before computing the render pass.
  34381. * @param camera The camera to apply the render pass to.
  34382. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34383. * @param engine The engine which the post process will be applied. (default: current engine)
  34384. * @param reusable If the post process can be reused on the same frame. (default: false)
  34385. */
  34386. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34387. }
  34388. }
  34389. declare module BABYLON {
  34390. /**
  34391. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  34392. */
  34393. class BloomEffect extends PostProcessRenderEffect {
  34394. private bloomScale;
  34395. /**
  34396. * @hidden Internal
  34397. */
  34398. _effects: Array<PostProcess>;
  34399. /**
  34400. * @hidden Internal
  34401. */
  34402. _downscale: ExtractHighlightsPostProcess;
  34403. private _blurX;
  34404. private _blurY;
  34405. private _merge;
  34406. /**
  34407. * The luminance threshold to find bright areas of the image to bloom.
  34408. */
  34409. threshold: number;
  34410. /**
  34411. * The strength of the bloom.
  34412. */
  34413. weight: number;
  34414. /**
  34415. * Specifies the size of the bloom blur kernel, relative to the final output size
  34416. */
  34417. kernel: number;
  34418. /**
  34419. * Creates a new instance of @see BloomEffect
  34420. * @param scene The scene the effect belongs to.
  34421. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  34422. * @param bloomKernel The size of the kernel to be used when applying the blur.
  34423. * @param bloomWeight The the strength of bloom.
  34424. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34425. * @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)
  34426. */
  34427. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  34428. /**
  34429. * Disposes each of the internal effects for a given camera.
  34430. * @param camera The camera to dispose the effect on.
  34431. */
  34432. disposeEffects(camera: Camera): void;
  34433. /**
  34434. * @hidden Internal
  34435. */
  34436. _updateEffects(): void;
  34437. /**
  34438. * Internal
  34439. * @returns if all the contained post processes are ready.
  34440. * @hidden
  34441. */
  34442. _isReady(): boolean;
  34443. }
  34444. }
  34445. declare module BABYLON {
  34446. /**
  34447. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34448. */
  34449. class BloomMergePostProcess extends PostProcess {
  34450. /** Weight of the bloom to be added to the original input. */
  34451. weight: number;
  34452. /**
  34453. * Creates a new instance of @see BloomMergePostProcess
  34454. * @param name The name of the effect.
  34455. * @param originalFromInput Post process which's input will be used for the merge.
  34456. * @param blurred Blurred highlights post process which's output will be used.
  34457. * @param weight Weight of the bloom to be added to the original input.
  34458. * @param options The required width/height ratio to downsize to before computing the render pass.
  34459. * @param camera The camera to apply the render pass to.
  34460. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34461. * @param engine The engine which the post process will be applied. (default: current engine)
  34462. * @param reusable If the post process can be reused on the same frame. (default: false)
  34463. * @param textureType Type of textures used when performing the post process. (default: 0)
  34464. * @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)
  34465. */
  34466. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  34467. /** Weight of the bloom to be added to the original input. */
  34468. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34469. }
  34470. }
  34471. declare module BABYLON {
  34472. /**
  34473. * The Blur Post Process which blurs an image based on a kernel and direction.
  34474. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  34475. */
  34476. class BlurPostProcess extends PostProcess {
  34477. /** The direction in which to blur the image. */
  34478. direction: Vector2;
  34479. private blockCompilation;
  34480. protected _kernel: number;
  34481. protected _idealKernel: number;
  34482. protected _packedFloat: boolean;
  34483. private _staticDefines;
  34484. /**
  34485. * Sets the length in pixels of the blur sample region
  34486. */
  34487. /**
  34488. * Gets the length in pixels of the blur sample region
  34489. */
  34490. kernel: number;
  34491. /**
  34492. * Sets wether or not the blur needs to unpack/repack floats
  34493. */
  34494. /**
  34495. * Gets wether or not the blur is unpacking/repacking floats
  34496. */
  34497. packedFloat: boolean;
  34498. /**
  34499. * Creates a new instance BlurPostProcess
  34500. * @param name The name of the effect.
  34501. * @param direction The direction in which to blur the image.
  34502. * @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.
  34503. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  34504. * @param camera The camera to apply the render pass to.
  34505. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34506. * @param engine The engine which the post process will be applied. (default: current engine)
  34507. * @param reusable If the post process can be reused on the same frame. (default: false)
  34508. * @param textureType Type of textures used when performing the post process. (default: 0)
  34509. * @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)
  34510. */
  34511. constructor(name: string,
  34512. /** The direction in which to blur the image. */
  34513. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  34514. /**
  34515. * Updates the effect with the current post process compile time values and recompiles the shader.
  34516. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34517. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34518. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34519. * @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
  34520. * @param onCompiled Called when the shader has been compiled.
  34521. * @param onError Called if there is an error when compiling a shader.
  34522. */
  34523. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34524. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34525. /**
  34526. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  34527. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  34528. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  34529. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  34530. * The gaps between physical kernels are compensated for in the weighting of the samples
  34531. * @param idealKernel Ideal blur kernel.
  34532. * @return Nearest best kernel.
  34533. */
  34534. protected _nearestBestKernel(idealKernel: number): number;
  34535. /**
  34536. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  34537. * @param x The point on the Gaussian distribution to sample.
  34538. * @return the value of the Gaussian function at x.
  34539. */
  34540. protected _gaussianWeight(x: number): number;
  34541. /**
  34542. * Generates a string that can be used as a floating point number in GLSL.
  34543. * @param x Value to print.
  34544. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  34545. * @return GLSL float string.
  34546. */
  34547. protected _glslFloat(x: number, decimalFigures?: number): string;
  34548. }
  34549. }
  34550. declare module BABYLON {
  34551. /**
  34552. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  34553. */
  34554. class ChromaticAberrationPostProcess extends PostProcess {
  34555. /**
  34556. * The amount of seperation of rgb channels (default: 30)
  34557. */
  34558. aberrationAmount: number;
  34559. /**
  34560. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  34561. */
  34562. radialIntensity: number;
  34563. /**
  34564. * 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))
  34565. */
  34566. direction: Vector2;
  34567. /**
  34568. * 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))
  34569. */
  34570. centerPosition: Vector2;
  34571. /**
  34572. * Creates a new instance ChromaticAberrationPostProcess
  34573. * @param name The name of the effect.
  34574. * @param screenWidth The width of the screen to apply the effect on.
  34575. * @param screenHeight The height of the screen to apply the effect on.
  34576. * @param options The required width/height ratio to downsize to before computing the render pass.
  34577. * @param camera The camera to apply the render pass to.
  34578. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34579. * @param engine The engine which the post process will be applied. (default: current engine)
  34580. * @param reusable If the post process can be reused on the same frame. (default: false)
  34581. * @param textureType Type of textures used when performing the post process. (default: 0)
  34582. * @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)
  34583. */
  34584. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34585. }
  34586. }
  34587. declare module BABYLON {
  34588. /**
  34589. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  34590. */
  34591. class CircleOfConfusionPostProcess extends PostProcess {
  34592. /**
  34593. * 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.
  34594. */
  34595. lensSize: number;
  34596. /**
  34597. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34598. */
  34599. fStop: number;
  34600. /**
  34601. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34602. */
  34603. focusDistance: number;
  34604. /**
  34605. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  34606. */
  34607. focalLength: number;
  34608. private _depthTexture;
  34609. /**
  34610. * Creates a new instance CircleOfConfusionPostProcess
  34611. * @param name The name of the effect.
  34612. * @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.
  34613. * @param options The required width/height ratio to downsize to before computing the render pass.
  34614. * @param camera The camera to apply the render pass to.
  34615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34616. * @param engine The engine which the post process will be applied. (default: current engine)
  34617. * @param reusable If the post process can be reused on the same frame. (default: false)
  34618. * @param textureType Type of textures used when performing the post process. (default: 0)
  34619. * @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)
  34620. */
  34621. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34622. /**
  34623. * 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.
  34624. */
  34625. depthTexture: RenderTargetTexture;
  34626. }
  34627. }
  34628. declare module BABYLON {
  34629. /**
  34630. *
  34631. * This post-process allows the modification of rendered colors by using
  34632. * a 'look-up table' (LUT). This effect is also called Color Grading.
  34633. *
  34634. * The object needs to be provided an url to a texture containing the color
  34635. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  34636. * Use an image editing software to tweak the LUT to match your needs.
  34637. *
  34638. * For an example of a color LUT, see here:
  34639. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  34640. * For explanations on color grading, see here:
  34641. * @see http://udn.epicgames.com/Three/ColorGrading.html
  34642. *
  34643. */
  34644. class ColorCorrectionPostProcess extends PostProcess {
  34645. private _colorTableTexture;
  34646. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34647. }
  34648. }
  34649. declare module BABYLON {
  34650. /**
  34651. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  34652. * input texture to perform effects such as edge detection or sharpening
  34653. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  34654. */
  34655. class ConvolutionPostProcess extends PostProcess {
  34656. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34657. kernel: number[];
  34658. /**
  34659. * Creates a new instance ConvolutionPostProcess
  34660. * @param name The name of the effect.
  34661. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  34662. * @param options The required width/height ratio to downsize to before computing the render pass.
  34663. * @param camera The camera to apply the render pass to.
  34664. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34665. * @param engine The engine which the post process will be applied. (default: current engine)
  34666. * @param reusable If the post process can be reused on the same frame. (default: false)
  34667. * @param textureType Type of textures used when performing the post process. (default: 0)
  34668. */
  34669. constructor(name: string,
  34670. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34671. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34672. /**
  34673. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34674. */
  34675. static EdgeDetect0Kernel: number[];
  34676. /**
  34677. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34678. */
  34679. static EdgeDetect1Kernel: number[];
  34680. /**
  34681. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34682. */
  34683. static EdgeDetect2Kernel: number[];
  34684. /**
  34685. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34686. */
  34687. static SharpenKernel: number[];
  34688. /**
  34689. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34690. */
  34691. static EmbossKernel: number[];
  34692. /**
  34693. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34694. */
  34695. static GaussianKernel: number[];
  34696. }
  34697. }
  34698. declare module BABYLON {
  34699. /**
  34700. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  34701. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  34702. * based on samples that have a large difference in distance than the center pixel.
  34703. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  34704. */
  34705. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  34706. direction: Vector2;
  34707. /**
  34708. * Creates a new instance CircleOfConfusionPostProcess
  34709. * @param name The name of the effect.
  34710. * @param scene The scene the effect belongs to.
  34711. * @param direction The direction the blur should be applied.
  34712. * @param kernel The size of the kernel used to blur.
  34713. * @param options The required width/height ratio to downsize to before computing the render pass.
  34714. * @param camera The camera to apply the render pass to.
  34715. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  34716. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  34717. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34718. * @param engine The engine which the post process will be applied. (default: current engine)
  34719. * @param reusable If the post process can be reused on the same frame. (default: false)
  34720. * @param textureType Type of textures used when performing the post process. (default: 0)
  34721. * @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)
  34722. */
  34723. 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);
  34724. }
  34725. }
  34726. declare module BABYLON {
  34727. /**
  34728. * Specifies the level of max blur that should be applied when using the depth of field effect
  34729. */
  34730. enum DepthOfFieldEffectBlurLevel {
  34731. /**
  34732. * Subtle blur
  34733. */
  34734. Low = 0,
  34735. /**
  34736. * Medium blur
  34737. */
  34738. Medium = 1,
  34739. /**
  34740. * Large blur
  34741. */
  34742. High = 2
  34743. }
  34744. /**
  34745. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  34746. */
  34747. class DepthOfFieldEffect extends PostProcessRenderEffect {
  34748. private _circleOfConfusion;
  34749. /**
  34750. * @hidden Internal, blurs from high to low
  34751. */
  34752. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  34753. private _depthOfFieldBlurY;
  34754. private _dofMerge;
  34755. /**
  34756. * @hidden Internal post processes in depth of field effect
  34757. */
  34758. _effects: Array<PostProcess>;
  34759. /**
  34760. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  34761. */
  34762. focalLength: number;
  34763. /**
  34764. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34765. */
  34766. fStop: number;
  34767. /**
  34768. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34769. */
  34770. focusDistance: number;
  34771. /**
  34772. * 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.
  34773. */
  34774. lensSize: number;
  34775. /**
  34776. * Creates a new instance DepthOfFieldEffect
  34777. * @param scene The scene the effect belongs to.
  34778. * @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.
  34779. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  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(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: 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. * Disposes each of the internal effects for a given camera.
  34789. * @param camera The camera to dispose the effect on.
  34790. */
  34791. disposeEffects(camera: Camera): void;
  34792. /**
  34793. * @hidden Internal
  34794. */
  34795. _updateEffects(): void;
  34796. /**
  34797. * Internal
  34798. * @returns if all the contained post processes are ready.
  34799. * @hidden
  34800. */
  34801. _isReady(): boolean;
  34802. }
  34803. }
  34804. declare module BABYLON {
  34805. /**
  34806. * Options to be set when merging outputs from the default pipeline.
  34807. */
  34808. class DepthOfFieldMergePostProcessOptions {
  34809. /**
  34810. * The original image to merge on top of
  34811. */
  34812. originalFromInput: PostProcess;
  34813. /**
  34814. * Parameters to perform the merge of the depth of field effect
  34815. */
  34816. depthOfField?: {
  34817. circleOfConfusion: PostProcess;
  34818. blurSteps: Array<PostProcess>;
  34819. };
  34820. /**
  34821. * Parameters to perform the merge of bloom effect
  34822. */
  34823. bloom?: {
  34824. blurred: PostProcess;
  34825. weight: number;
  34826. };
  34827. }
  34828. /**
  34829. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34830. */
  34831. class DepthOfFieldMergePostProcess extends PostProcess {
  34832. private blurSteps;
  34833. /**
  34834. * Creates a new instance of DepthOfFieldMergePostProcess
  34835. * @param name The name of the effect.
  34836. * @param originalFromInput Post process which's input will be used for the merge.
  34837. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  34838. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  34839. * @param options The required width/height ratio to downsize to before computing the render pass.
  34840. * @param camera The camera to apply the render pass to.
  34841. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34842. * @param engine The engine which the post process will be applied. (default: current engine)
  34843. * @param reusable If the post process can be reused on the same frame. (default: false)
  34844. * @param textureType Type of textures used when performing the post process. (default: 0)
  34845. * @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)
  34846. */
  34847. 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);
  34848. /**
  34849. * Updates the effect with the current post process compile time values and recompiles the shader.
  34850. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34851. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34852. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34853. * @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
  34854. * @param onCompiled Called when the shader has been compiled.
  34855. * @param onError Called if there is an error when compiling a shader.
  34856. */
  34857. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34858. }
  34859. }
  34860. declare module BABYLON {
  34861. /**
  34862. * DisplayPassPostProcess which produces an output the same as it's input
  34863. */
  34864. class DisplayPassPostProcess extends PostProcess {
  34865. /**
  34866. * Creates the DisplayPassPostProcess
  34867. * @param name The name of the effect.
  34868. * @param options The required width/height ratio to downsize to before computing the render pass.
  34869. * @param camera The camera to apply the render pass to.
  34870. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34871. * @param engine The engine which the post process will be applied. (default: current engine)
  34872. * @param reusable If the post process can be reused on the same frame. (default: false)
  34873. */
  34874. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34875. }
  34876. }
  34877. declare module BABYLON {
  34878. /**
  34879. * 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.
  34880. */
  34881. class ExtractHighlightsPostProcess extends PostProcess {
  34882. /**
  34883. * The luminance threshold, pixels below this value will be set to black.
  34884. */
  34885. threshold: number;
  34886. /** @hidden */
  34887. _exposure: number;
  34888. /**
  34889. * Post process which has the input texture to be used when performing highlight extraction
  34890. * @hidden
  34891. */
  34892. _inputPostProcess: Nullable<PostProcess>;
  34893. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34894. }
  34895. }
  34896. declare module BABYLON {
  34897. /**
  34898. * Applies a kernel filter to the image
  34899. */
  34900. class FilterPostProcess extends PostProcess {
  34901. /** The matrix to be applied to the image */
  34902. kernelMatrix: Matrix;
  34903. /**
  34904. *
  34905. * @param name The name of the effect.
  34906. * @param kernelMatrix The matrix to be applied to the image
  34907. * @param options The required width/height ratio to downsize to before computing the render pass.
  34908. * @param camera The camera to apply the render pass to.
  34909. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34910. * @param engine The engine which the post process will be applied. (default: current engine)
  34911. * @param reusable If the post process can be reused on the same frame. (default: false)
  34912. */
  34913. constructor(name: string,
  34914. /** The matrix to be applied to the image */
  34915. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34916. }
  34917. }
  34918. declare module BABYLON {
  34919. /**
  34920. * Fxaa post process
  34921. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  34922. */
  34923. class FxaaPostProcess extends PostProcess {
  34924. /** @hidden */
  34925. texelWidth: number;
  34926. /** @hidden */
  34927. texelHeight: number;
  34928. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34929. private _getDefines;
  34930. }
  34931. }
  34932. declare module BABYLON {
  34933. /**
  34934. * The GrainPostProcess adds noise to the image at mid luminance levels
  34935. */
  34936. class GrainPostProcess extends PostProcess {
  34937. /**
  34938. * The intensity of the grain added (default: 30)
  34939. */
  34940. intensity: number;
  34941. /**
  34942. * If the grain should be randomized on every frame
  34943. */
  34944. animated: boolean;
  34945. /**
  34946. * Creates a new instance of @see GrainPostProcess
  34947. * @param name The name of the effect.
  34948. * @param options The required width/height ratio to downsize to before computing the render pass.
  34949. * @param camera The camera to apply the render pass to.
  34950. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34951. * @param engine The engine which the post process will be applied. (default: current engine)
  34952. * @param reusable If the post process can be reused on the same frame. (default: false)
  34953. * @param textureType Type of textures used when performing the post process. (default: 0)
  34954. * @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)
  34955. */
  34956. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34957. }
  34958. }
  34959. declare module BABYLON {
  34960. /**
  34961. * Extracts highlights from the image
  34962. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34963. */
  34964. class HighlightsPostProcess extends PostProcess {
  34965. /**
  34966. * Extracts highlights from the image
  34967. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34968. * @param name The name of the effect.
  34969. * @param options The required width/height ratio to downsize to before computing the render pass.
  34970. * @param camera The camera to apply the render pass to.
  34971. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34972. * @param engine The engine which the post process will be applied. (default: current engine)
  34973. * @param reusable If the post process can be reused on the same frame. (default: false)
  34974. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  34975. */
  34976. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34977. }
  34978. }
  34979. declare module BABYLON {
  34980. /**
  34981. * ImageProcessingPostProcess
  34982. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  34983. */
  34984. class ImageProcessingPostProcess extends PostProcess {
  34985. /**
  34986. * Default configuration related to image processing available in the PBR Material.
  34987. */
  34988. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34989. /**
  34990. * Gets the image processing configuration used either in this material.
  34991. */
  34992. /**
  34993. * Sets the Default image processing configuration used either in the this material.
  34994. *
  34995. * If sets to null, the scene one is in use.
  34996. */
  34997. imageProcessingConfiguration: ImageProcessingConfiguration;
  34998. /**
  34999. * Keep track of the image processing observer to allow dispose and replace.
  35000. */
  35001. private _imageProcessingObserver;
  35002. /**
  35003. * Attaches a new image processing configuration to the PBR Material.
  35004. * @param configuration
  35005. */
  35006. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  35007. /**
  35008. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35009. */
  35010. /**
  35011. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35012. */
  35013. colorCurves: Nullable<ColorCurves>;
  35014. /**
  35015. * Gets wether the color curves effect is enabled.
  35016. */
  35017. /**
  35018. * Sets wether the color curves effect is enabled.
  35019. */
  35020. colorCurvesEnabled: boolean;
  35021. /**
  35022. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  35023. */
  35024. /**
  35025. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  35026. */
  35027. colorGradingTexture: Nullable<BaseTexture>;
  35028. /**
  35029. * Gets wether the color grading effect is enabled.
  35030. */
  35031. /**
  35032. * Gets wether the color grading effect is enabled.
  35033. */
  35034. colorGradingEnabled: boolean;
  35035. /**
  35036. * Gets exposure used in the effect.
  35037. */
  35038. /**
  35039. * Sets exposure used in the effect.
  35040. */
  35041. exposure: number;
  35042. /**
  35043. * Gets wether tonemapping is enabled or not.
  35044. */
  35045. /**
  35046. * Sets wether tonemapping is enabled or not
  35047. */
  35048. toneMappingEnabled: boolean;
  35049. /**
  35050. * Gets contrast used in the effect.
  35051. */
  35052. /**
  35053. * Sets contrast used in the effect.
  35054. */
  35055. contrast: number;
  35056. /**
  35057. * Gets Vignette stretch size.
  35058. */
  35059. /**
  35060. * Sets Vignette stretch size.
  35061. */
  35062. vignetteStretch: number;
  35063. /**
  35064. * Gets Vignette centre X Offset.
  35065. */
  35066. /**
  35067. * Sets Vignette centre X Offset.
  35068. */
  35069. vignetteCentreX: number;
  35070. /**
  35071. * Gets Vignette centre Y Offset.
  35072. */
  35073. /**
  35074. * Sets Vignette centre Y Offset.
  35075. */
  35076. vignetteCentreY: number;
  35077. /**
  35078. * Gets Vignette weight or intensity of the vignette effect.
  35079. */
  35080. /**
  35081. * Sets Vignette weight or intensity of the vignette effect.
  35082. */
  35083. vignetteWeight: number;
  35084. /**
  35085. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  35086. * if vignetteEnabled is set to true.
  35087. */
  35088. /**
  35089. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  35090. * if vignetteEnabled is set to true.
  35091. */
  35092. vignetteColor: Color4;
  35093. /**
  35094. * Gets Camera field of view used by the Vignette effect.
  35095. */
  35096. /**
  35097. * Sets Camera field of view used by the Vignette effect.
  35098. */
  35099. vignetteCameraFov: number;
  35100. /**
  35101. * Gets the vignette blend mode allowing different kind of effect.
  35102. */
  35103. /**
  35104. * Sets the vignette blend mode allowing different kind of effect.
  35105. */
  35106. vignetteBlendMode: number;
  35107. /**
  35108. * Gets wether the vignette effect is enabled.
  35109. */
  35110. /**
  35111. * Sets wether the vignette effect is enabled.
  35112. */
  35113. vignetteEnabled: boolean;
  35114. private _fromLinearSpace;
  35115. /**
  35116. * Gets wether the input of the processing is in Gamma or Linear Space.
  35117. */
  35118. /**
  35119. * Sets wether the input of the processing is in Gamma or Linear Space.
  35120. */
  35121. fromLinearSpace: boolean;
  35122. /**
  35123. * Defines cache preventing GC.
  35124. */
  35125. private _defines;
  35126. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  35127. /**
  35128. * "ImageProcessingPostProcess"
  35129. * @returns "ImageProcessingPostProcess"
  35130. */
  35131. getClassName(): string;
  35132. protected _updateParameters(): void;
  35133. dispose(camera?: Camera): void;
  35134. }
  35135. }
  35136. declare module BABYLON {
  35137. /**
  35138. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  35139. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  35140. * As an example, all you have to do is to create the post-process:
  35141. * var mb = new BABYLON.MotionBlurPostProcess(
  35142. * 'mb', // The name of the effect.
  35143. * scene, // The scene containing the objects to blur according to their velocity.
  35144. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  35145. * camera // The camera to apply the render pass to.
  35146. * );
  35147. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  35148. */
  35149. class MotionBlurPostProcess extends PostProcess {
  35150. /**
  35151. * Defines how much the image is blurred by the movement. Default value is equal to 1
  35152. */
  35153. motionStrength: number;
  35154. /**
  35155. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  35156. */
  35157. /**
  35158. * Sets the number of iterations to be used for motion blur quality
  35159. */
  35160. motionBlurSamples: number;
  35161. private _motionBlurSamples;
  35162. private _geometryBufferRenderer;
  35163. /**
  35164. * Creates a new instance MotionBlurPostProcess
  35165. * @param name The name of the effect.
  35166. * @param scene The scene containing the objects to blur according to their velocity.
  35167. * @param options The required width/height ratio to downsize to before computing the render pass.
  35168. * @param camera The camera to apply the render pass to.
  35169. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35170. * @param engine The engine which the post process will be applied. (default: current engine)
  35171. * @param reusable If the post process can be reused on the same frame. (default: false)
  35172. * @param textureType Type of textures used when performing the post process. (default: 0)
  35173. * @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)
  35174. */
  35175. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35176. /**
  35177. * Disposes the post process.
  35178. * @param camera The camera to dispose the post process on.
  35179. */
  35180. dispose(camera?: Camera): void;
  35181. }
  35182. }
  35183. declare module BABYLON {
  35184. /**
  35185. * PassPostProcess which produces an output the same as it's input
  35186. */
  35187. class PassPostProcess extends PostProcess {
  35188. /**
  35189. * Creates the PassPostProcess
  35190. * @param name The name of the effect.
  35191. * @param options The required width/height ratio to downsize to before computing the render pass.
  35192. * @param camera The camera to apply the render pass to.
  35193. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35194. * @param engine The engine which the post process will be applied. (default: current engine)
  35195. * @param reusable If the post process can be reused on the same frame. (default: false)
  35196. * @param textureType The type of texture to be used when performing the post processing.
  35197. * @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)
  35198. */
  35199. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35200. }
  35201. /**
  35202. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  35203. */
  35204. class PassCubePostProcess extends PostProcess {
  35205. private _face;
  35206. /**
  35207. * Gets or sets the cube face to display.
  35208. * * 0 is +X
  35209. * * 1 is -X
  35210. * * 2 is +Y
  35211. * * 3 is -Y
  35212. * * 4 is +Z
  35213. * * 5 is -Z
  35214. */
  35215. face: number;
  35216. /**
  35217. * Creates the PassCubePostProcess
  35218. * @param name The name of the effect.
  35219. * @param options The required width/height ratio to downsize to before computing the render pass.
  35220. * @param camera The camera to apply the render pass to.
  35221. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35222. * @param engine The engine which the post process will be applied. (default: current engine)
  35223. * @param reusable If the post process can be reused on the same frame. (default: false)
  35224. * @param textureType The type of texture to be used when performing the post processing.
  35225. * @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)
  35226. */
  35227. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35228. }
  35229. }
  35230. declare module BABYLON {
  35231. /**
  35232. * Size options for a post process
  35233. */
  35234. type PostProcessOptions = {
  35235. width: number;
  35236. height: number;
  35237. };
  35238. /**
  35239. * PostProcess can be used to apply a shader to a texture after it has been rendered
  35240. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35241. */
  35242. class PostProcess {
  35243. /** Name of the PostProcess. */
  35244. name: string;
  35245. /**
  35246. * Width of the texture to apply the post process on
  35247. */
  35248. width: number;
  35249. /**
  35250. * Height of the texture to apply the post process on
  35251. */
  35252. height: number;
  35253. /**
  35254. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  35255. * @hidden
  35256. */
  35257. _outputTexture: Nullable<InternalTexture>;
  35258. /**
  35259. * Sampling mode used by the shader
  35260. * See https://doc.babylonjs.com/classes/3.1/texture
  35261. */
  35262. renderTargetSamplingMode: number;
  35263. /**
  35264. * Clear color to use when screen clearing
  35265. */
  35266. clearColor: Color4;
  35267. /**
  35268. * If the buffer needs to be cleared before applying the post process. (default: true)
  35269. * Should be set to false if shader will overwrite all previous pixels.
  35270. */
  35271. autoClear: boolean;
  35272. /**
  35273. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  35274. */
  35275. alphaMode: number;
  35276. /**
  35277. * Sets the setAlphaBlendConstants of the babylon engine
  35278. */
  35279. alphaConstants: Color4;
  35280. /**
  35281. * Animations to be used for the post processing
  35282. */
  35283. animations: Animation[];
  35284. /**
  35285. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  35286. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  35287. */
  35288. enablePixelPerfectMode: boolean;
  35289. /**
  35290. * Force the postprocess to be applied without taking in account viewport
  35291. */
  35292. forceFullscreenViewport: boolean;
  35293. /**
  35294. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  35295. *
  35296. * | Value | Type | Description |
  35297. * | ----- | ----------------------------------- | ----------- |
  35298. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  35299. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  35300. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  35301. *
  35302. */
  35303. scaleMode: number;
  35304. /**
  35305. * Force textures to be a power of two (default: false)
  35306. */
  35307. alwaysForcePOT: boolean;
  35308. private _samples;
  35309. /**
  35310. * Number of sample textures (default: 1)
  35311. */
  35312. samples: number;
  35313. /**
  35314. * Modify the scale of the post process to be the same as the viewport (default: false)
  35315. */
  35316. adaptScaleToCurrentViewport: boolean;
  35317. private _camera;
  35318. private _scene;
  35319. private _engine;
  35320. private _options;
  35321. private _reusable;
  35322. private _textureType;
  35323. /**
  35324. * Smart array of input and output textures for the post process.
  35325. * @hidden
  35326. */
  35327. _textures: SmartArray<InternalTexture>;
  35328. /**
  35329. * The index in _textures that corresponds to the output texture.
  35330. * @hidden
  35331. */
  35332. _currentRenderTextureInd: number;
  35333. private _effect;
  35334. private _samplers;
  35335. private _fragmentUrl;
  35336. private _vertexUrl;
  35337. private _parameters;
  35338. private _scaleRatio;
  35339. protected _indexParameters: any;
  35340. private _shareOutputWithPostProcess;
  35341. private _texelSize;
  35342. private _forcedOutputTexture;
  35343. /**
  35344. * An event triggered when the postprocess is activated.
  35345. */
  35346. onActivateObservable: Observable<Camera>;
  35347. private _onActivateObserver;
  35348. /**
  35349. * A function that is added to the onActivateObservable
  35350. */
  35351. onActivate: Nullable<(camera: Camera) => void>;
  35352. /**
  35353. * An event triggered when the postprocess changes its size.
  35354. */
  35355. onSizeChangedObservable: Observable<PostProcess>;
  35356. private _onSizeChangedObserver;
  35357. /**
  35358. * A function that is added to the onSizeChangedObservable
  35359. */
  35360. onSizeChanged: (postProcess: PostProcess) => void;
  35361. /**
  35362. * An event triggered when the postprocess applies its effect.
  35363. */
  35364. onApplyObservable: Observable<Effect>;
  35365. private _onApplyObserver;
  35366. /**
  35367. * A function that is added to the onApplyObservable
  35368. */
  35369. onApply: (effect: Effect) => void;
  35370. /**
  35371. * An event triggered before rendering the postprocess
  35372. */
  35373. onBeforeRenderObservable: Observable<Effect>;
  35374. private _onBeforeRenderObserver;
  35375. /**
  35376. * A function that is added to the onBeforeRenderObservable
  35377. */
  35378. onBeforeRender: (effect: Effect) => void;
  35379. /**
  35380. * An event triggered after rendering the postprocess
  35381. */
  35382. onAfterRenderObservable: Observable<Effect>;
  35383. private _onAfterRenderObserver;
  35384. /**
  35385. * A function that is added to the onAfterRenderObservable
  35386. */
  35387. onAfterRender: (efect: Effect) => void;
  35388. /**
  35389. * 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
  35390. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  35391. */
  35392. inputTexture: InternalTexture;
  35393. /**
  35394. * Gets the camera which post process is applied to.
  35395. * @returns The camera the post process is applied to.
  35396. */
  35397. getCamera(): Camera;
  35398. /**
  35399. * Gets the texel size of the postprocess.
  35400. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  35401. */
  35402. readonly texelSize: Vector2;
  35403. /**
  35404. * Creates a new instance PostProcess
  35405. * @param name The name of the PostProcess.
  35406. * @param fragmentUrl The url of the fragment shader to be used.
  35407. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  35408. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  35409. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35410. * @param camera The camera to apply the render pass to.
  35411. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35412. * @param engine The engine which the post process will be applied. (default: current engine)
  35413. * @param reusable If the post process can be reused on the same frame. (default: false)
  35414. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  35415. * @param textureType Type of textures used when performing the post process. (default: 0)
  35416. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  35417. * @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
  35418. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  35419. */
  35420. constructor(
  35421. /** Name of the PostProcess. */
  35422. 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);
  35423. /**
  35424. * Gets the engine which this post process belongs to.
  35425. * @returns The engine the post process was enabled with.
  35426. */
  35427. getEngine(): Engine;
  35428. /**
  35429. * The effect that is created when initializing the post process.
  35430. * @returns The created effect corrisponding the the postprocess.
  35431. */
  35432. getEffect(): Effect;
  35433. /**
  35434. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  35435. * @param postProcess The post process to share the output with.
  35436. * @returns This post process.
  35437. */
  35438. shareOutputWith(postProcess: PostProcess): PostProcess;
  35439. /**
  35440. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  35441. * This should be called if the post process that shares output with this post process is disabled/disposed.
  35442. */
  35443. useOwnOutput(): void;
  35444. /**
  35445. * Updates the effect with the current post process compile time values and recompiles the shader.
  35446. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35447. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35448. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35449. * @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
  35450. * @param onCompiled Called when the shader has been compiled.
  35451. * @param onError Called if there is an error when compiling a shader.
  35452. */
  35453. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35454. /**
  35455. * The post process is reusable if it can be used multiple times within one frame.
  35456. * @returns If the post process is reusable
  35457. */
  35458. isReusable(): boolean;
  35459. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  35460. markTextureDirty(): void;
  35461. /**
  35462. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  35463. * 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.
  35464. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  35465. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  35466. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  35467. * @returns The target texture that was bound to be written to.
  35468. */
  35469. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  35470. /**
  35471. * If the post process is supported.
  35472. */
  35473. readonly isSupported: boolean;
  35474. /**
  35475. * The aspect ratio of the output texture.
  35476. */
  35477. readonly aspectRatio: number;
  35478. /**
  35479. * Get a value indicating if the post-process is ready to be used
  35480. * @returns true if the post-process is ready (shader is compiled)
  35481. */
  35482. isReady(): boolean;
  35483. /**
  35484. * Binds all textures and uniforms to the shader, this will be run on every pass.
  35485. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  35486. */
  35487. apply(): Nullable<Effect>;
  35488. private _disposeTextures;
  35489. /**
  35490. * Disposes the post process.
  35491. * @param camera The camera to dispose the post process on.
  35492. */
  35493. dispose(camera?: Camera): void;
  35494. }
  35495. }
  35496. declare module BABYLON {
  35497. /**
  35498. * PostProcessManager is used to manage one or more post processes or post process pipelines
  35499. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35500. */
  35501. class PostProcessManager {
  35502. private _scene;
  35503. private _indexBuffer;
  35504. private _vertexBuffers;
  35505. /**
  35506. * Creates a new instance PostProcess
  35507. * @param scene The scene that the post process is associated with.
  35508. */
  35509. constructor(scene: Scene);
  35510. private _prepareBuffers;
  35511. private _buildIndexBuffer;
  35512. /**
  35513. * Rebuilds the vertex buffers of the manager.
  35514. * @hidden
  35515. */
  35516. _rebuild(): void;
  35517. /**
  35518. * Prepares a frame to be run through a post process.
  35519. * @param sourceTexture The input texture to the post procesess. (default: null)
  35520. * @param postProcesses An array of post processes to be run. (default: null)
  35521. * @returns True if the post processes were able to be run.
  35522. * @hidden
  35523. */
  35524. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  35525. /**
  35526. * Manually render a set of post processes to a texture.
  35527. * @param postProcesses An array of post processes to be run.
  35528. * @param targetTexture The target texture to render to.
  35529. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  35530. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  35531. * @param lodLevel defines which lod of the texture to render to
  35532. */
  35533. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  35534. /**
  35535. * Finalize the result of the output of the postprocesses.
  35536. * @param doNotPresent If true the result will not be displayed to the screen.
  35537. * @param targetTexture The target texture to render to.
  35538. * @param faceIndex The index of the face to bind the target texture to.
  35539. * @param postProcesses The array of post processes to render.
  35540. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  35541. * @hidden
  35542. */
  35543. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  35544. /**
  35545. * Disposes of the post process manager.
  35546. */
  35547. dispose(): void;
  35548. }
  35549. }
  35550. declare module BABYLON {
  35551. /**
  35552. * Post process which applies a refractin texture
  35553. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35554. */
  35555. class RefractionPostProcess extends PostProcess {
  35556. /** the base color of the refraction (used to taint the rendering) */
  35557. color: Color3;
  35558. /** simulated refraction depth */
  35559. depth: number;
  35560. /** the coefficient of the base color (0 to remove base color tainting) */
  35561. colorLevel: number;
  35562. private _refTexture;
  35563. private _ownRefractionTexture;
  35564. /**
  35565. * Gets or sets the refraction texture
  35566. * Please note that you are responsible for disposing the texture if you set it manually
  35567. */
  35568. refractionTexture: Texture;
  35569. /**
  35570. * Initializes the RefractionPostProcess
  35571. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35572. * @param name The name of the effect.
  35573. * @param refractionTextureUrl Url of the refraction texture to use
  35574. * @param color the base color of the refraction (used to taint the rendering)
  35575. * @param depth simulated refraction depth
  35576. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  35577. * @param camera The camera to apply the render pass to.
  35578. * @param options The required width/height ratio to downsize to before computing the render pass.
  35579. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35580. * @param engine The engine which the post process will be applied. (default: current engine)
  35581. * @param reusable If the post process can be reused on the same frame. (default: false)
  35582. */
  35583. constructor(name: string, refractionTextureUrl: string,
  35584. /** the base color of the refraction (used to taint the rendering) */
  35585. color: Color3,
  35586. /** simulated refraction depth */
  35587. depth: number,
  35588. /** the coefficient of the base color (0 to remove base color tainting) */
  35589. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35590. /**
  35591. * Disposes of the post process
  35592. * @param camera Camera to dispose post process on
  35593. */
  35594. dispose(camera: Camera): void;
  35595. }
  35596. }
  35597. declare module BABYLON {
  35598. /**
  35599. * The SharpenPostProcess applies a sharpen kernel to every pixel
  35600. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35601. */
  35602. class SharpenPostProcess extends PostProcess {
  35603. /**
  35604. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  35605. */
  35606. colorAmount: number;
  35607. /**
  35608. * How much sharpness should be applied (default: 0.3)
  35609. */
  35610. edgeAmount: number;
  35611. /**
  35612. * Creates a new instance ConvolutionPostProcess
  35613. * @param name The name of the effect.
  35614. * @param options The required width/height ratio to downsize to before computing the render pass.
  35615. * @param camera The camera to apply the render pass to.
  35616. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35617. * @param engine The engine which the post process will be applied. (default: current engine)
  35618. * @param reusable If the post process can be reused on the same frame. (default: false)
  35619. * @param textureType Type of textures used when performing the post process. (default: 0)
  35620. * @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)
  35621. */
  35622. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35623. }
  35624. }
  35625. declare module BABYLON {
  35626. /**
  35627. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  35628. */
  35629. class StereoscopicInterlacePostProcess extends PostProcess {
  35630. private _stepSize;
  35631. private _passedProcess;
  35632. /**
  35633. * Initializes a StereoscopicInterlacePostProcess
  35634. * @param name The name of the effect.
  35635. * @param rigCameras The rig cameras to be appled to the post process
  35636. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  35637. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35638. * @param engine The engine which the post process will be applied. (default: current engine)
  35639. * @param reusable If the post process can be reused on the same frame. (default: false)
  35640. */
  35641. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35642. }
  35643. }
  35644. declare module BABYLON {
  35645. /** Defines operator used for tonemapping */
  35646. enum TonemappingOperator {
  35647. /** Hable */
  35648. Hable = 0,
  35649. /** Reinhard */
  35650. Reinhard = 1,
  35651. /** HejiDawson */
  35652. HejiDawson = 2,
  35653. /** Photographic */
  35654. Photographic = 3
  35655. }
  35656. /**
  35657. * Defines a post process to apply tone mapping
  35658. */
  35659. class TonemapPostProcess extends PostProcess {
  35660. private _operator;
  35661. /** Defines the required exposure adjustement */
  35662. exposureAdjustment: number;
  35663. /**
  35664. * Creates a new TonemapPostProcess
  35665. * @param name defines the name of the postprocess
  35666. * @param _operator defines the operator to use
  35667. * @param exposureAdjustment defines the required exposure adjustement
  35668. * @param camera defines the camera to use (can be null)
  35669. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  35670. * @param engine defines the hosting engine (can be ignore if camera is set)
  35671. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  35672. */
  35673. constructor(name: string, _operator: TonemappingOperator,
  35674. /** Defines the required exposure adjustement */
  35675. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  35676. }
  35677. }
  35678. declare module BABYLON {
  35679. /**
  35680. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  35681. */
  35682. class VolumetricLightScatteringPostProcess extends PostProcess {
  35683. private _volumetricLightScatteringPass;
  35684. private _volumetricLightScatteringRTT;
  35685. private _viewPort;
  35686. private _screenCoordinates;
  35687. private _cachedDefines;
  35688. /**
  35689. * If not undefined, the mesh position is computed from the attached node position
  35690. */
  35691. attachedNode: {
  35692. position: Vector3;
  35693. };
  35694. /**
  35695. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  35696. */
  35697. customMeshPosition: Vector3;
  35698. /**
  35699. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  35700. */
  35701. useCustomMeshPosition: boolean;
  35702. /**
  35703. * If the post-process should inverse the light scattering direction
  35704. */
  35705. invert: boolean;
  35706. /**
  35707. * The internal mesh used by the post-process
  35708. */
  35709. mesh: Mesh;
  35710. /**
  35711. * @hidden
  35712. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  35713. */
  35714. useDiffuseColor: boolean;
  35715. /**
  35716. * Array containing the excluded meshes not rendered in the internal pass
  35717. */
  35718. excludedMeshes: AbstractMesh[];
  35719. /**
  35720. * Controls the overall intensity of the post-process
  35721. */
  35722. exposure: number;
  35723. /**
  35724. * Dissipates each sample's contribution in range [0, 1]
  35725. */
  35726. decay: number;
  35727. /**
  35728. * Controls the overall intensity of each sample
  35729. */
  35730. weight: number;
  35731. /**
  35732. * Controls the density of each sample
  35733. */
  35734. density: number;
  35735. /**
  35736. * @constructor
  35737. * @param name The post-process name
  35738. * @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)
  35739. * @param camera The camera that the post-process will be attached to
  35740. * @param mesh The mesh used to create the light scattering
  35741. * @param samples The post-process quality, default 100
  35742. * @param samplingModeThe post-process filtering mode
  35743. * @param engine The babylon engine
  35744. * @param reusable If the post-process is reusable
  35745. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  35746. */
  35747. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  35748. /**
  35749. * Returns the string "VolumetricLightScatteringPostProcess"
  35750. * @returns "VolumetricLightScatteringPostProcess"
  35751. */
  35752. getClassName(): string;
  35753. private _isReady;
  35754. /**
  35755. * Sets the new light position for light scattering effect
  35756. * @param position The new custom light position
  35757. */
  35758. setCustomMeshPosition(position: Vector3): void;
  35759. /**
  35760. * Returns the light position for light scattering effect
  35761. * @return Vector3 The custom light position
  35762. */
  35763. getCustomMeshPosition(): Vector3;
  35764. /**
  35765. * Disposes the internal assets and detaches the post-process from the camera
  35766. */
  35767. dispose(camera: Camera): void;
  35768. /**
  35769. * Returns the render target texture used by the post-process
  35770. * @return the render target texture used by the post-process
  35771. */
  35772. getPass(): RenderTargetTexture;
  35773. private _meshExcluded;
  35774. private _createPass;
  35775. private _updateMeshScreenCoordinates;
  35776. /**
  35777. * Creates a default mesh for the Volumeric Light Scattering post-process
  35778. * @param name The mesh name
  35779. * @param scene The scene where to create the mesh
  35780. * @return the default mesh
  35781. */
  35782. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  35783. }
  35784. }
  35785. declare module BABYLON {
  35786. /**
  35787. * VRDistortionCorrectionPostProcess used for mobile VR
  35788. */
  35789. class VRDistortionCorrectionPostProcess extends PostProcess {
  35790. private _isRightEye;
  35791. private _distortionFactors;
  35792. private _postProcessScaleFactor;
  35793. private _lensCenterOffset;
  35794. private _scaleIn;
  35795. private _scaleFactor;
  35796. private _lensCenter;
  35797. /**
  35798. * Initializes the VRDistortionCorrectionPostProcess
  35799. * @param name The name of the effect.
  35800. * @param camera The camera to apply the render pass to.
  35801. * @param isRightEye If this is for the right eye distortion
  35802. * @param vrMetrics All the required metrics for the VR camera
  35803. */
  35804. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  35805. }
  35806. }
  35807. declare module BABYLON {
  35808. interface Scene {
  35809. /** @hidden (Backing field) */
  35810. _boundingBoxRenderer: BoundingBoxRenderer;
  35811. /** @hidden (Backing field) */
  35812. _forceShowBoundingBoxes: boolean;
  35813. /**
  35814. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  35815. */
  35816. forceShowBoundingBoxes: boolean;
  35817. /**
  35818. * Gets the bounding box renderer associated with the scene
  35819. * @returns a BoundingBoxRenderer
  35820. */
  35821. getBoundingBoxRenderer(): BoundingBoxRenderer;
  35822. }
  35823. interface AbstractMesh {
  35824. /** @hidden (Backing field) */
  35825. _showBoundingBox: boolean;
  35826. /**
  35827. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  35828. */
  35829. showBoundingBox: boolean;
  35830. }
  35831. /**
  35832. * Component responsible of rendering the bounding box of the meshes in a scene.
  35833. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  35834. */
  35835. class BoundingBoxRenderer implements ISceneComponent {
  35836. /**
  35837. * The component name helpfull to identify the component in the list of scene components.
  35838. */
  35839. readonly name: string;
  35840. /**
  35841. * The scene the component belongs to.
  35842. */
  35843. scene: Scene;
  35844. /**
  35845. * Color of the bounding box lines placed in front of an object
  35846. */
  35847. frontColor: Color3;
  35848. /**
  35849. * Color of the bounding box lines placed behind an object
  35850. */
  35851. backColor: Color3;
  35852. /**
  35853. * Defines if the renderer should show the back lines or not
  35854. */
  35855. showBackLines: boolean;
  35856. /**
  35857. * @hidden
  35858. */
  35859. renderList: SmartArray<BoundingBox>;
  35860. private _colorShader;
  35861. private _vertexBuffers;
  35862. private _indexBuffer;
  35863. /**
  35864. * Instantiates a new bounding box renderer in a scene.
  35865. * @param scene the scene the renderer renders in
  35866. */
  35867. constructor(scene: Scene);
  35868. /**
  35869. * Registers the component in a given scene
  35870. */
  35871. register(): void;
  35872. private _evaluateSubMesh;
  35873. private _activeMesh;
  35874. private _prepareRessources;
  35875. private _createIndexBuffer;
  35876. /**
  35877. * Rebuilds the elements related to this component in case of
  35878. * context lost for instance.
  35879. */
  35880. rebuild(): void;
  35881. /**
  35882. * @hidden
  35883. */
  35884. reset(): void;
  35885. /**
  35886. * Render the bounding boxes of a specific rendering group
  35887. * @param renderingGroupId defines the rendering group to render
  35888. */
  35889. render(renderingGroupId: number): void;
  35890. /**
  35891. * In case of occlusion queries, we can render the occlusion bounding box through this method
  35892. * @param mesh Define the mesh to render the occlusion bounding box for
  35893. */
  35894. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  35895. /**
  35896. * Dispose and release the resources attached to this renderer.
  35897. */
  35898. dispose(): void;
  35899. }
  35900. }
  35901. declare module BABYLON {
  35902. /**
  35903. * This represents a depth renderer in Babylon.
  35904. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  35905. */
  35906. class DepthRenderer {
  35907. private _scene;
  35908. private _depthMap;
  35909. private _effect;
  35910. private _cachedDefines;
  35911. private _camera;
  35912. /**
  35913. * Specifiess that the depth renderer will only be used within
  35914. * the camera it is created for.
  35915. * This can help forcing its rendering during the camera processing.
  35916. */
  35917. useOnlyInActiveCamera: boolean;
  35918. /**
  35919. * Instantiates a depth renderer
  35920. * @param scene The scene the renderer belongs to
  35921. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  35922. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  35923. */
  35924. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  35925. /**
  35926. * Creates the depth rendering effect and checks if the effect is ready.
  35927. * @param subMesh The submesh to be used to render the depth map of
  35928. * @param useInstances If multiple world instances should be used
  35929. * @returns if the depth renderer is ready to render the depth map
  35930. */
  35931. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35932. /**
  35933. * Gets the texture which the depth map will be written to.
  35934. * @returns The depth map texture
  35935. */
  35936. getDepthMap(): RenderTargetTexture;
  35937. /**
  35938. * Disposes of the depth renderer.
  35939. */
  35940. dispose(): void;
  35941. }
  35942. }
  35943. declare module BABYLON {
  35944. interface Scene {
  35945. /** @hidden (Backing field) */
  35946. _depthRenderer: {
  35947. [id: string]: DepthRenderer;
  35948. };
  35949. /**
  35950. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  35951. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  35952. * @returns the created depth renderer
  35953. */
  35954. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  35955. /**
  35956. * Disables a depth renderer for a given camera
  35957. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  35958. */
  35959. disableDepthRenderer(camera?: Nullable<Camera>): void;
  35960. }
  35961. /**
  35962. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  35963. * in several rendering techniques.
  35964. */
  35965. class DepthRendererSceneComponent implements ISceneComponent {
  35966. /**
  35967. * The component name helpfull to identify the component in the list of scene components.
  35968. */
  35969. readonly name: string;
  35970. /**
  35971. * The scene the component belongs to.
  35972. */
  35973. scene: Scene;
  35974. /**
  35975. * Creates a new instance of the component for the given scene
  35976. * @param scene Defines the scene to register the component in
  35977. */
  35978. constructor(scene: Scene);
  35979. /**
  35980. * Registers the component in a given scene
  35981. */
  35982. register(): void;
  35983. /**
  35984. * Rebuilds the elements related to this component in case of
  35985. * context lost for instance.
  35986. */
  35987. rebuild(): void;
  35988. /**
  35989. * Disposes the component and the associated ressources
  35990. */
  35991. dispose(): void;
  35992. private _gatherRenderTargets;
  35993. private _gatherActiveCameraRenderTargets;
  35994. }
  35995. }
  35996. declare module BABYLON {
  35997. interface AbstractMesh {
  35998. /**
  35999. * Disables the mesh edge rendering mode
  36000. * @returns the currentAbstractMesh
  36001. */
  36002. disableEdgesRendering(): AbstractMesh;
  36003. /**
  36004. * Enables the edge rendering mode on the mesh.
  36005. * This mode makes the mesh edges visible
  36006. * @param epsilon defines the maximal distance between two angles to detect a face
  36007. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36008. * @returns the currentAbstractMesh
  36009. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36010. */
  36011. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  36012. /**
  36013. * Gets the edgesRenderer associated with the mesh
  36014. */
  36015. edgesRenderer: Nullable<EdgesRenderer>;
  36016. }
  36017. interface LinesMesh {
  36018. /**
  36019. * Enables the edge rendering mode on the mesh.
  36020. * This mode makes the mesh edges visible
  36021. * @param epsilon defines the maximal distance between two angles to detect a face
  36022. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36023. * @returns the currentAbstractMesh
  36024. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36025. */
  36026. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  36027. }
  36028. interface InstancedLinesMesh {
  36029. /**
  36030. * Enables the edge rendering mode on the mesh.
  36031. * This mode makes the mesh edges visible
  36032. * @param epsilon defines the maximal distance between two angles to detect a face
  36033. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36034. * @returns the current InstancedLinesMesh
  36035. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36036. */
  36037. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  36038. }
  36039. /**
  36040. * Defines the minimum contract an Edges renderer should follow.
  36041. */
  36042. interface IEdgesRenderer extends IDisposable {
  36043. /**
  36044. * Gets or sets a boolean indicating if the edgesRenderer is active
  36045. */
  36046. isEnabled: boolean;
  36047. /**
  36048. * Renders the edges of the attached mesh,
  36049. */
  36050. render(): void;
  36051. /**
  36052. * Checks wether or not the edges renderer is ready to render.
  36053. * @return true if ready, otherwise false.
  36054. */
  36055. isReady(): boolean;
  36056. }
  36057. /**
  36058. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  36059. */
  36060. class EdgesRenderer implements IEdgesRenderer {
  36061. /**
  36062. * Define the size of the edges with an orthographic camera
  36063. */
  36064. edgesWidthScalerForOrthographic: number;
  36065. /**
  36066. * Define the size of the edges with a perspective camera
  36067. */
  36068. edgesWidthScalerForPerspective: number;
  36069. protected _source: AbstractMesh;
  36070. protected _linesPositions: number[];
  36071. protected _linesNormals: number[];
  36072. protected _linesIndices: number[];
  36073. protected _epsilon: number;
  36074. protected _indicesCount: number;
  36075. protected _lineShader: ShaderMaterial;
  36076. protected _ib: WebGLBuffer;
  36077. protected _buffers: {
  36078. [key: string]: Nullable<VertexBuffer>;
  36079. };
  36080. protected _checkVerticesInsteadOfIndices: boolean;
  36081. private _meshRebuildObserver;
  36082. private _meshDisposeObserver;
  36083. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  36084. isEnabled: boolean;
  36085. /**
  36086. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  36087. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  36088. * @param source Mesh used to create edges
  36089. * @param epsilon sum of angles in adjacency to check for edge
  36090. * @param checkVerticesInsteadOfIndices
  36091. * @param generateEdgesLines - should generate Lines or only prepare resources.
  36092. */
  36093. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  36094. protected _prepareRessources(): void;
  36095. /** @hidden */
  36096. _rebuild(): void;
  36097. /**
  36098. * Releases the required resources for the edges renderer
  36099. */
  36100. dispose(): void;
  36101. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  36102. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  36103. /**
  36104. * Checks if the pair of p0 and p1 is en edge
  36105. * @param faceIndex
  36106. * @param edge
  36107. * @param faceNormals
  36108. * @param p0
  36109. * @param p1
  36110. * @private
  36111. */
  36112. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  36113. /**
  36114. * push line into the position, normal and index buffer
  36115. * @protected
  36116. */
  36117. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  36118. /**
  36119. * Generates lines edges from adjacencjes
  36120. * @private
  36121. */
  36122. _generateEdgesLines(): void;
  36123. /**
  36124. * Checks wether or not the edges renderer is ready to render.
  36125. * @return true if ready, otherwise false.
  36126. */
  36127. isReady(): boolean;
  36128. /**
  36129. * Renders the edges of the attached mesh,
  36130. */
  36131. render(): void;
  36132. }
  36133. }
  36134. declare module BABYLON {
  36135. /**
  36136. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  36137. */
  36138. class GeometryBufferRenderer {
  36139. /**
  36140. * Constant used to retrieve the position texture index in the G-Buffer textures array
  36141. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  36142. */
  36143. static readonly POSITION_TEXTURE_TYPE: number;
  36144. /**
  36145. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  36146. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  36147. */
  36148. static readonly VELOCITY_TEXTURE_TYPE: number;
  36149. /**
  36150. * Dictionary used to store the previous transformation matrices of each rendered mesh
  36151. * in order to compute objects velocities when enableVelocity is set to "true"
  36152. * @hidden
  36153. */
  36154. _previousTransformationMatrices: {
  36155. [index: number]: Matrix;
  36156. };
  36157. private _scene;
  36158. private _multiRenderTarget;
  36159. private _ratio;
  36160. private _enablePosition;
  36161. private _enableVelocity;
  36162. private _positionIndex;
  36163. private _velocityIndex;
  36164. protected _effect: Effect;
  36165. protected _cachedDefines: string;
  36166. /**
  36167. * Set the render list (meshes to be rendered) used in the G buffer.
  36168. */
  36169. renderList: Mesh[];
  36170. /**
  36171. * Gets wether or not G buffer are supported by the running hardware.
  36172. * This requires draw buffer supports
  36173. */
  36174. readonly isSupported: boolean;
  36175. /**
  36176. * Returns the index of the given texture type in the G-Buffer textures array
  36177. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  36178. * @returns the index of the given texture type in the G-Buffer textures array
  36179. */
  36180. getTextureIndex(textureType: number): number;
  36181. /**
  36182. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  36183. */
  36184. /**
  36185. * Sets whether or not objects positions are enabled for the G buffer.
  36186. */
  36187. enablePosition: boolean;
  36188. /**
  36189. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  36190. */
  36191. /**
  36192. * Sets wether or not objects velocities are enabled for the G buffer.
  36193. */
  36194. enableVelocity: boolean;
  36195. /**
  36196. * Gets the scene associated with the buffer.
  36197. */
  36198. readonly scene: Scene;
  36199. /**
  36200. * Gets the ratio used by the buffer during its creation.
  36201. * How big is the buffer related to the main canvas.
  36202. */
  36203. readonly ratio: number;
  36204. /**
  36205. * Creates a new G Buffer for the scene
  36206. * @param scene The scene the buffer belongs to
  36207. * @param ratio How big is the buffer related to the main canvas.
  36208. */
  36209. constructor(scene: Scene, ratio?: number);
  36210. /**
  36211. * Checks wether everything is ready to render a submesh to the G buffer.
  36212. * @param subMesh the submesh to check readiness for
  36213. * @param useInstances is the mesh drawn using instance or not
  36214. * @returns true if ready otherwise false
  36215. */
  36216. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36217. /**
  36218. * Gets the current underlying G Buffer.
  36219. * @returns the buffer
  36220. */
  36221. getGBuffer(): MultiRenderTarget;
  36222. /**
  36223. * Gets the number of samples used to render the buffer (anti aliasing).
  36224. */
  36225. /**
  36226. * Sets the number of samples used to render the buffer (anti aliasing).
  36227. */
  36228. samples: number;
  36229. /**
  36230. * Disposes the renderer and frees up associated resources.
  36231. */
  36232. dispose(): void;
  36233. protected _createRenderTargets(): void;
  36234. }
  36235. }
  36236. declare module BABYLON {
  36237. interface Scene {
  36238. /** @hidden (Backing field) */
  36239. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  36240. /**
  36241. * Gets or Sets the current geometry buffer associated to the scene.
  36242. */
  36243. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  36244. /**
  36245. * Enables a GeometryBufferRender and associates it with the scene
  36246. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  36247. * @returns the GeometryBufferRenderer
  36248. */
  36249. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  36250. /**
  36251. * Disables the GeometryBufferRender associated with the scene
  36252. */
  36253. disableGeometryBufferRenderer(): void;
  36254. }
  36255. /**
  36256. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  36257. * in several rendering techniques.
  36258. */
  36259. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  36260. /**
  36261. * The component name helpful to identify the component in the list of scene components.
  36262. */
  36263. readonly name: string;
  36264. /**
  36265. * The scene the component belongs to.
  36266. */
  36267. scene: Scene;
  36268. /**
  36269. * Creates a new instance of the component for the given scene
  36270. * @param scene Defines the scene to register the component in
  36271. */
  36272. constructor(scene: Scene);
  36273. /**
  36274. * Registers the component in a given scene
  36275. */
  36276. register(): void;
  36277. /**
  36278. * Rebuilds the elements related to this component in case of
  36279. * context lost for instance.
  36280. */
  36281. rebuild(): void;
  36282. /**
  36283. * Disposes the component and the associated ressources
  36284. */
  36285. dispose(): void;
  36286. private _gatherRenderTargets;
  36287. }
  36288. }
  36289. declare module BABYLON {
  36290. /**
  36291. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  36292. */
  36293. class LineEdgesRenderer extends EdgesRenderer {
  36294. /**
  36295. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  36296. * @param source LineMesh used to generate edges
  36297. * @param epsilon not important (specified angle for edge detection)
  36298. * @param checkVerticesInsteadOfIndices not important for LineMesh
  36299. */
  36300. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  36301. /**
  36302. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  36303. */
  36304. _generateEdgesLines(): void;
  36305. }
  36306. }
  36307. declare module BABYLON {
  36308. interface Scene {
  36309. /** @hidden */
  36310. _outlineRenderer: OutlineRenderer;
  36311. /**
  36312. * Gets the outline renderer associated with the scene
  36313. * @returns a OutlineRenderer
  36314. */
  36315. getOutlineRenderer(): OutlineRenderer;
  36316. }
  36317. interface AbstractMesh {
  36318. /** @hidden (Backing field) */
  36319. _renderOutline: boolean;
  36320. /**
  36321. * Gets or sets a boolean indicating if the outline must be rendered as well
  36322. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  36323. */
  36324. renderOutline: boolean;
  36325. /** @hidden (Backing field) */
  36326. _renderOverlay: boolean;
  36327. /**
  36328. * Gets or sets a boolean indicating if the overlay must be rendered as well
  36329. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  36330. */
  36331. renderOverlay: boolean;
  36332. }
  36333. /**
  36334. * This class is responsible to draw bothe outline/overlay of meshes.
  36335. * It should not be used directly but through the available method on mesh.
  36336. */
  36337. class OutlineRenderer implements ISceneComponent {
  36338. /**
  36339. * The name of the component. Each component must have a unique name.
  36340. */
  36341. name: string;
  36342. /**
  36343. * The scene the component belongs to.
  36344. */
  36345. scene: Scene;
  36346. /**
  36347. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  36348. */
  36349. zOffset: number;
  36350. private _engine;
  36351. private _effect;
  36352. private _cachedDefines;
  36353. private _savedDepthWrite;
  36354. /**
  36355. * Instantiates a new outline renderer. (There could be only one per scene).
  36356. * @param scene Defines the scene it belongs to
  36357. */
  36358. constructor(scene: Scene);
  36359. /**
  36360. * Register the component to one instance of a scene.
  36361. */
  36362. register(): void;
  36363. /**
  36364. * Rebuilds the elements related to this component in case of
  36365. * context lost for instance.
  36366. */
  36367. rebuild(): void;
  36368. /**
  36369. * Disposes the component and the associated ressources.
  36370. */
  36371. dispose(): void;
  36372. /**
  36373. * Renders the outline in the canvas.
  36374. * @param subMesh Defines the sumesh to render
  36375. * @param batch Defines the batch of meshes in case of instances
  36376. * @param useOverlay Defines if the rendering is for the overlay or the outline
  36377. */
  36378. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  36379. /**
  36380. * Returns whether or not the outline renderer is ready for a given submesh.
  36381. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  36382. * @param subMesh Defines the submesh to check readyness for
  36383. * @param useInstances Defines wheter wee are trying to render instances or not
  36384. * @returns true if ready otherwise false
  36385. */
  36386. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36387. private _beforeRenderingMesh;
  36388. private _afterRenderingMesh;
  36389. }
  36390. }
  36391. declare module BABYLON {
  36392. /**
  36393. * This represents the object necessary to create a rendering group.
  36394. * This is exclusively used and created by the rendering manager.
  36395. * To modify the behavior, you use the available helpers in your scene or meshes.
  36396. * @hidden
  36397. */
  36398. class RenderingGroup {
  36399. index: number;
  36400. private _scene;
  36401. private _opaqueSubMeshes;
  36402. private _transparentSubMeshes;
  36403. private _alphaTestSubMeshes;
  36404. private _depthOnlySubMeshes;
  36405. private _particleSystems;
  36406. private _spriteManagers;
  36407. private _opaqueSortCompareFn;
  36408. private _alphaTestSortCompareFn;
  36409. private _transparentSortCompareFn;
  36410. private _renderOpaque;
  36411. private _renderAlphaTest;
  36412. private _renderTransparent;
  36413. private _edgesRenderers;
  36414. onBeforeTransparentRendering: () => void;
  36415. /**
  36416. * Set the opaque sort comparison function.
  36417. * If null the sub meshes will be render in the order they were created
  36418. */
  36419. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36420. /**
  36421. * Set the alpha test sort comparison function.
  36422. * If null the sub meshes will be render in the order they were created
  36423. */
  36424. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36425. /**
  36426. * Set the transparent sort comparison function.
  36427. * If null the sub meshes will be render in the order they were created
  36428. */
  36429. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36430. /**
  36431. * Creates a new rendering group.
  36432. * @param index The rendering group index
  36433. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  36434. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  36435. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  36436. */
  36437. 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>);
  36438. /**
  36439. * Render all the sub meshes contained in the group.
  36440. * @param customRenderFunction Used to override the default render behaviour of the group.
  36441. * @returns true if rendered some submeshes.
  36442. */
  36443. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  36444. /**
  36445. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  36446. * @param subMeshes The submeshes to render
  36447. */
  36448. private renderOpaqueSorted;
  36449. /**
  36450. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  36451. * @param subMeshes The submeshes to render
  36452. */
  36453. private renderAlphaTestSorted;
  36454. /**
  36455. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  36456. * @param subMeshes The submeshes to render
  36457. */
  36458. private renderTransparentSorted;
  36459. /**
  36460. * Renders the submeshes in a specified order.
  36461. * @param subMeshes The submeshes to sort before render
  36462. * @param sortCompareFn The comparison function use to sort
  36463. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  36464. * @param transparent Specifies to activate blending if true
  36465. */
  36466. private static renderSorted;
  36467. /**
  36468. * Renders the submeshes in the order they were dispatched (no sort applied).
  36469. * @param subMeshes The submeshes to render
  36470. */
  36471. private static renderUnsorted;
  36472. /**
  36473. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36474. * are rendered back to front if in the same alpha index.
  36475. *
  36476. * @param a The first submesh
  36477. * @param b The second submesh
  36478. * @returns The result of the comparison
  36479. */
  36480. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  36481. /**
  36482. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36483. * are rendered back to front.
  36484. *
  36485. * @param a The first submesh
  36486. * @param b The second submesh
  36487. * @returns The result of the comparison
  36488. */
  36489. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  36490. /**
  36491. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36492. * are rendered front to back (prevent overdraw).
  36493. *
  36494. * @param a The first submesh
  36495. * @param b The second submesh
  36496. * @returns The result of the comparison
  36497. */
  36498. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  36499. /**
  36500. * Resets the different lists of submeshes to prepare a new frame.
  36501. */
  36502. prepare(): void;
  36503. dispose(): void;
  36504. /**
  36505. * Inserts the submesh in its correct queue depending on its material.
  36506. * @param subMesh The submesh to dispatch
  36507. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36508. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36509. */
  36510. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36511. dispatchSprites(spriteManager: ISpriteManager): void;
  36512. dispatchParticles(particleSystem: IParticleSystem): void;
  36513. private _renderParticles;
  36514. private _renderSprites;
  36515. }
  36516. }
  36517. declare module BABYLON {
  36518. /**
  36519. * Interface describing the different options available in the rendering manager
  36520. * regarding Auto Clear between groups.
  36521. */
  36522. interface IRenderingManagerAutoClearSetup {
  36523. /**
  36524. * Defines whether or not autoclear is enable.
  36525. */
  36526. autoClear: boolean;
  36527. /**
  36528. * Defines whether or not to autoclear the depth buffer.
  36529. */
  36530. depth: boolean;
  36531. /**
  36532. * Defines whether or not to autoclear the stencil buffer.
  36533. */
  36534. stencil: boolean;
  36535. }
  36536. /**
  36537. * This is the manager responsible of all the rendering for meshes sprites and particles.
  36538. * It is enable to manage the different groups as well as the different necessary sort functions.
  36539. * This should not be used directly aside of the few static configurations
  36540. */
  36541. class RenderingManager {
  36542. /**
  36543. * The max id used for rendering groups (not included)
  36544. */
  36545. static MAX_RENDERINGGROUPS: number;
  36546. /**
  36547. * The min id used for rendering groups (included)
  36548. */
  36549. static MIN_RENDERINGGROUPS: number;
  36550. /**
  36551. * Used to globally prevent autoclearing scenes.
  36552. */
  36553. static AUTOCLEAR: boolean;
  36554. /**
  36555. * @hidden
  36556. */
  36557. _useSceneAutoClearSetup: boolean;
  36558. private _scene;
  36559. private _renderingGroups;
  36560. private _depthStencilBufferAlreadyCleaned;
  36561. private _autoClearDepthStencil;
  36562. private _customOpaqueSortCompareFn;
  36563. private _customAlphaTestSortCompareFn;
  36564. private _customTransparentSortCompareFn;
  36565. private _renderingGroupInfo;
  36566. /**
  36567. * Instantiates a new rendering group for a particular scene
  36568. * @param scene Defines the scene the groups belongs to
  36569. */
  36570. constructor(scene: Scene);
  36571. private _clearDepthStencilBuffer;
  36572. /**
  36573. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  36574. * @hidden
  36575. */
  36576. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  36577. /**
  36578. * Resets the different information of the group to prepare a new frame
  36579. * @hidden
  36580. */
  36581. reset(): void;
  36582. /**
  36583. * Dispose and release the group and its associated resources.
  36584. * @hidden
  36585. */
  36586. dispose(): void;
  36587. /**
  36588. * Clear the info related to rendering groups preventing retention points during dispose.
  36589. */
  36590. freeRenderingGroups(): void;
  36591. private _prepareRenderingGroup;
  36592. /**
  36593. * Add a sprite manager to the rendering manager in order to render it this frame.
  36594. * @param spriteManager Define the sprite manager to render
  36595. */
  36596. dispatchSprites(spriteManager: ISpriteManager): void;
  36597. /**
  36598. * Add a particle system to the rendering manager in order to render it this frame.
  36599. * @param particleSystem Define the particle system to render
  36600. */
  36601. dispatchParticles(particleSystem: IParticleSystem): void;
  36602. /**
  36603. * Add a submesh to the manager in order to render it this frame
  36604. * @param subMesh The submesh to dispatch
  36605. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36606. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36607. */
  36608. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36609. /**
  36610. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36611. * This allowed control for front to back rendering or reversly depending of the special needs.
  36612. *
  36613. * @param renderingGroupId The rendering group id corresponding to its index
  36614. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36615. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36616. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36617. */
  36618. 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;
  36619. /**
  36620. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36621. *
  36622. * @param renderingGroupId The rendering group id corresponding to its index
  36623. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36624. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36625. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36626. */
  36627. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36628. /**
  36629. * Gets the current auto clear configuration for one rendering group of the rendering
  36630. * manager.
  36631. * @param index the rendering group index to get the information for
  36632. * @returns The auto clear setup for the requested rendering group
  36633. */
  36634. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36635. }
  36636. }
  36637. declare module BABYLON {
  36638. /**
  36639. * Renders a layer on top of an existing scene
  36640. */
  36641. class UtilityLayerRenderer implements IDisposable {
  36642. /** the original scene that will be rendered on top of */
  36643. originalScene: Scene;
  36644. private _pointerCaptures;
  36645. private _lastPointerEvents;
  36646. private static _DefaultUtilityLayer;
  36647. private static _DefaultKeepDepthUtilityLayer;
  36648. /**
  36649. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  36650. */
  36651. pickUtilitySceneFirst: boolean;
  36652. /**
  36653. * 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)
  36654. */
  36655. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  36656. /**
  36657. * 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)
  36658. */
  36659. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  36660. /**
  36661. * The scene that is rendered on top of the original scene
  36662. */
  36663. utilityLayerScene: Scene;
  36664. /**
  36665. * If the utility layer should automatically be rendered on top of existing scene
  36666. */
  36667. shouldRender: boolean;
  36668. /**
  36669. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  36670. */
  36671. onlyCheckPointerDownEvents: boolean;
  36672. /**
  36673. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  36674. */
  36675. processAllEvents: boolean;
  36676. /**
  36677. * Observable raised when the pointer move from the utility layer scene to the main scene
  36678. */
  36679. onPointerOutObservable: Observable<number>;
  36680. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  36681. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  36682. private _afterRenderObserver;
  36683. private _sceneDisposeObserver;
  36684. private _originalPointerObserver;
  36685. /**
  36686. * Instantiates a UtilityLayerRenderer
  36687. * @param originalScene the original scene that will be rendered on top of
  36688. */
  36689. constructor(
  36690. /** the original scene that will be rendered on top of */
  36691. originalScene: Scene);
  36692. private _notifyObservers;
  36693. /**
  36694. * Renders the utility layers scene on top of the original scene
  36695. */
  36696. render(): void;
  36697. /**
  36698. * Disposes of the renderer
  36699. */
  36700. dispose(): void;
  36701. private _updateCamera;
  36702. }
  36703. }
  36704. declare module BABYLON {
  36705. /**
  36706. * Class used to represent a sprite
  36707. * @see http://doc.babylonjs.com/babylon101/sprites
  36708. */
  36709. class Sprite {
  36710. /** defines the name */
  36711. name: string;
  36712. /** Gets or sets the current world position */
  36713. position: Vector3;
  36714. /** Gets or sets the main color */
  36715. color: Color4;
  36716. /** Gets or sets the width */
  36717. width: number;
  36718. /** Gets or sets the height */
  36719. height: number;
  36720. /** Gets or sets rotation angle */
  36721. angle: number;
  36722. /** Gets or sets the cell index in the sprite sheet */
  36723. cellIndex: number;
  36724. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  36725. invertU: number;
  36726. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  36727. invertV: number;
  36728. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  36729. disposeWhenFinishedAnimating: boolean;
  36730. /** Gets the list of attached animations */
  36731. animations: Animation[];
  36732. /** Gets or sets a boolean indicating if the sprite can be picked */
  36733. isPickable: boolean;
  36734. /**
  36735. * Gets or sets the associated action manager
  36736. */
  36737. actionManager: Nullable<ActionManager>;
  36738. private _animationStarted;
  36739. private _loopAnimation;
  36740. private _fromIndex;
  36741. private _toIndex;
  36742. private _delay;
  36743. private _direction;
  36744. private _manager;
  36745. private _time;
  36746. private _onAnimationEnd;
  36747. /**
  36748. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  36749. */
  36750. isVisible: boolean;
  36751. /**
  36752. * Gets or sets the sprite size
  36753. */
  36754. size: number;
  36755. /**
  36756. * Creates a new Sprite
  36757. * @param name defines the name
  36758. * @param manager defines the manager
  36759. */
  36760. constructor(
  36761. /** defines the name */
  36762. name: string, manager: ISpriteManager);
  36763. /**
  36764. * Starts an animation
  36765. * @param from defines the initial key
  36766. * @param to defines the end key
  36767. * @param loop defines if the animation must loop
  36768. * @param delay defines the start delay (in ms)
  36769. * @param onAnimationEnd defines a callback to call when animation ends
  36770. */
  36771. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  36772. /** Stops current animation (if any) */
  36773. stopAnimation(): void;
  36774. /** @hidden */
  36775. _animate(deltaTime: number): void;
  36776. /** Release associated resources */
  36777. dispose(): void;
  36778. }
  36779. }
  36780. declare module BABYLON {
  36781. /**
  36782. * Defines the minimum interface to fullfil in order to be a sprite manager.
  36783. */
  36784. interface ISpriteManager extends IDisposable {
  36785. /**
  36786. * Restricts the camera to viewing objects with the same layerMask.
  36787. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  36788. */
  36789. layerMask: number;
  36790. /**
  36791. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36792. */
  36793. isPickable: boolean;
  36794. /**
  36795. * Specifies the rendering group id for this mesh (0 by default)
  36796. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36797. */
  36798. renderingGroupId: number;
  36799. /**
  36800. * Defines the list of sprites managed by the manager.
  36801. */
  36802. sprites: Array<Sprite>;
  36803. /**
  36804. * Tests the intersection of a sprite with a specific ray.
  36805. * @param ray The ray we are sending to test the collision
  36806. * @param camera The camera space we are sending rays in
  36807. * @param predicate A predicate allowing excluding sprites from the list of object to test
  36808. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  36809. * @returns picking info or null.
  36810. */
  36811. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36812. /**
  36813. * Renders the list of sprites on screen.
  36814. */
  36815. render(): void;
  36816. }
  36817. /**
  36818. * Class used to manage multiple sprites on the same spritesheet
  36819. * @see http://doc.babylonjs.com/babylon101/sprites
  36820. */
  36821. class SpriteManager implements ISpriteManager {
  36822. /** defines the manager's name */
  36823. name: string;
  36824. /** Gets the list of sprites */
  36825. sprites: Sprite[];
  36826. /** Gets or sets the rendering group id (0 by default) */
  36827. renderingGroupId: number;
  36828. /** Gets or sets camera layer mask */
  36829. layerMask: number;
  36830. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  36831. fogEnabled: boolean;
  36832. /** Gets or sets a boolean indicating if the sprites are pickable */
  36833. isPickable: boolean;
  36834. /** Defines the default width of a cell in the spritesheet */
  36835. cellWidth: number;
  36836. /** Defines the default height of a cell in the spritesheet */
  36837. cellHeight: number;
  36838. /**
  36839. * An event triggered when the manager is disposed.
  36840. */
  36841. onDisposeObservable: Observable<SpriteManager>;
  36842. private _onDisposeObserver;
  36843. /**
  36844. * Callback called when the manager is disposed
  36845. */
  36846. onDispose: () => void;
  36847. private _capacity;
  36848. private _spriteTexture;
  36849. private _epsilon;
  36850. private _scene;
  36851. private _vertexData;
  36852. private _buffer;
  36853. private _vertexBuffers;
  36854. private _indexBuffer;
  36855. private _effectBase;
  36856. private _effectFog;
  36857. /**
  36858. * Gets or sets the spritesheet texture
  36859. */
  36860. texture: Texture;
  36861. /**
  36862. * Creates a new sprite manager
  36863. * @param name defines the manager's name
  36864. * @param imgUrl defines the sprite sheet url
  36865. * @param capacity defines the maximum allowed number of sprites
  36866. * @param cellSize defines the size of a sprite cell
  36867. * @param scene defines the hosting scene
  36868. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  36869. * @param samplingMode defines the smapling mode to use with spritesheet
  36870. */
  36871. constructor(
  36872. /** defines the manager's name */
  36873. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  36874. private _appendSpriteVertex;
  36875. /**
  36876. * Intersects the sprites with a ray
  36877. * @param ray defines the ray to intersect with
  36878. * @param camera defines the current active camera
  36879. * @param predicate defines a predicate used to select candidate sprites
  36880. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  36881. * @returns null if no hit or a PickingInfo
  36882. */
  36883. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36884. /**
  36885. * Render all child sprites
  36886. */
  36887. render(): void;
  36888. /**
  36889. * Release associated resources
  36890. */
  36891. dispose(): void;
  36892. }
  36893. }
  36894. declare module BABYLON {
  36895. interface Scene {
  36896. /** @hidden */
  36897. _pointerOverSprite: Nullable<Sprite>;
  36898. /** @hidden */
  36899. _pickedDownSprite: Nullable<Sprite>;
  36900. /** @hidden */
  36901. _tempSpritePickingRay: Nullable<Ray>;
  36902. /**
  36903. * All of the sprite managers added to this scene
  36904. * @see http://doc.babylonjs.com/babylon101/sprites
  36905. */
  36906. spriteManagers: Array<ISpriteManager>;
  36907. /**
  36908. * An event triggered when sprites rendering is about to start
  36909. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  36910. */
  36911. onBeforeSpritesRenderingObservable: Observable<Scene>;
  36912. /**
  36913. * An event triggered when sprites rendering is done
  36914. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  36915. */
  36916. onAfterSpritesRenderingObservable: Observable<Scene>;
  36917. /** @hidden */
  36918. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36919. /** Launch a ray to try to pick a sprite in the scene
  36920. * @param x position on screen
  36921. * @param y position on screen
  36922. * @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
  36923. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36924. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36925. * @returns a PickingInfo
  36926. */
  36927. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36928. /** Use the given ray to pick a sprite in the scene
  36929. * @param ray The ray (in world space) to use to pick meshes
  36930. * @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
  36931. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36932. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  36933. * @returns a PickingInfo
  36934. */
  36935. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36936. /**
  36937. * Force the sprite under the pointer
  36938. * @param sprite defines the sprite to use
  36939. */
  36940. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  36941. /**
  36942. * Gets the sprite under the pointer
  36943. * @returns a Sprite or null if no sprite is under the pointer
  36944. */
  36945. getPointerOverSprite(): Nullable<Sprite>;
  36946. }
  36947. /**
  36948. * Defines the sprite scene component responsible to manage sprites
  36949. * in a given scene.
  36950. */
  36951. class SpriteSceneComponent implements ISceneComponent {
  36952. /**
  36953. * The component name helpfull to identify the component in the list of scene components.
  36954. */
  36955. readonly name: string;
  36956. /**
  36957. * The scene the component belongs to.
  36958. */
  36959. scene: Scene;
  36960. /** @hidden */
  36961. private _spritePredicate;
  36962. /**
  36963. * Creates a new instance of the component for the given scene
  36964. * @param scene Defines the scene to register the component in
  36965. */
  36966. constructor(scene: Scene);
  36967. /**
  36968. * Registers the component in a given scene
  36969. */
  36970. register(): void;
  36971. /**
  36972. * Rebuilds the elements related to this component in case of
  36973. * context lost for instance.
  36974. */
  36975. rebuild(): void;
  36976. /**
  36977. * Disposes the component and the associated ressources.
  36978. */
  36979. dispose(): void;
  36980. private _pickSpriteButKeepRay;
  36981. private _pointerMove;
  36982. private _pointerDown;
  36983. private _pointerUp;
  36984. }
  36985. }
  36986. declare module BABYLON {
  36987. /**
  36988. * @hidden
  36989. **/
  36990. class _AlphaState {
  36991. private _isAlphaBlendDirty;
  36992. private _isBlendFunctionParametersDirty;
  36993. private _isBlendEquationParametersDirty;
  36994. private _isBlendConstantsDirty;
  36995. private _alphaBlend;
  36996. private _blendFunctionParameters;
  36997. private _blendEquationParameters;
  36998. private _blendConstants;
  36999. /**
  37000. * Initializes the state.
  37001. */
  37002. constructor();
  37003. readonly isDirty: boolean;
  37004. alphaBlend: boolean;
  37005. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  37006. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  37007. setAlphaEquationParameters(rgb: number, alpha: number): void;
  37008. reset(): void;
  37009. apply(gl: WebGLRenderingContext): void;
  37010. }
  37011. }
  37012. declare module BABYLON {
  37013. /**
  37014. * @hidden
  37015. **/
  37016. class _DepthCullingState {
  37017. private _isDepthTestDirty;
  37018. private _isDepthMaskDirty;
  37019. private _isDepthFuncDirty;
  37020. private _isCullFaceDirty;
  37021. private _isCullDirty;
  37022. private _isZOffsetDirty;
  37023. private _isFrontFaceDirty;
  37024. private _depthTest;
  37025. private _depthMask;
  37026. private _depthFunc;
  37027. private _cull;
  37028. private _cullFace;
  37029. private _zOffset;
  37030. private _frontFace;
  37031. /**
  37032. * Initializes the state.
  37033. */
  37034. constructor();
  37035. readonly isDirty: boolean;
  37036. zOffset: number;
  37037. cullFace: Nullable<number>;
  37038. cull: Nullable<boolean>;
  37039. depthFunc: Nullable<number>;
  37040. depthMask: boolean;
  37041. depthTest: boolean;
  37042. frontFace: Nullable<number>;
  37043. reset(): void;
  37044. apply(gl: WebGLRenderingContext): void;
  37045. }
  37046. }
  37047. declare module BABYLON {
  37048. /**
  37049. * @hidden
  37050. **/
  37051. class _StencilState {
  37052. private _isStencilTestDirty;
  37053. private _isStencilMaskDirty;
  37054. private _isStencilFuncDirty;
  37055. private _isStencilOpDirty;
  37056. private _stencilTest;
  37057. private _stencilMask;
  37058. private _stencilFunc;
  37059. private _stencilFuncRef;
  37060. private _stencilFuncMask;
  37061. private _stencilOpStencilFail;
  37062. private _stencilOpDepthFail;
  37063. private _stencilOpStencilDepthPass;
  37064. readonly isDirty: boolean;
  37065. stencilFunc: number;
  37066. stencilFuncRef: number;
  37067. stencilFuncMask: number;
  37068. stencilOpStencilFail: number;
  37069. stencilOpDepthFail: number;
  37070. stencilOpStencilDepthPass: number;
  37071. stencilMask: number;
  37072. stencilTest: boolean;
  37073. constructor();
  37074. reset(): void;
  37075. apply(gl: WebGLRenderingContext): void;
  37076. }
  37077. }
  37078. declare module BABYLON {
  37079. /**
  37080. * Class used to evalaute queries containing `and` and `or` operators
  37081. */
  37082. class AndOrNotEvaluator {
  37083. /**
  37084. * Evaluate a query
  37085. * @param query defines the query to evaluate
  37086. * @param evaluateCallback defines the callback used to filter result
  37087. * @returns true if the query matches
  37088. */
  37089. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  37090. private static _HandleParenthesisContent;
  37091. private static _SimplifyNegation;
  37092. }
  37093. }
  37094. declare module BABYLON {
  37095. /**
  37096. * Defines the list of states available for a task inside a AssetsManager
  37097. */
  37098. enum AssetTaskState {
  37099. /**
  37100. * Initialization
  37101. */
  37102. INIT = 0,
  37103. /**
  37104. * Running
  37105. */
  37106. RUNNING = 1,
  37107. /**
  37108. * Done
  37109. */
  37110. DONE = 2,
  37111. /**
  37112. * Error
  37113. */
  37114. ERROR = 3
  37115. }
  37116. /**
  37117. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  37118. */
  37119. abstract class AbstractAssetTask {
  37120. /**
  37121. * Task name
  37122. */ name: string;
  37123. /**
  37124. * Callback called when the task is successful
  37125. */
  37126. onSuccess: (task: any) => void;
  37127. /**
  37128. * Callback called when the task is not successful
  37129. */
  37130. onError: (task: any, message?: string, exception?: any) => void;
  37131. /**
  37132. * Creates a new AssetsManager
  37133. * @param name defines the name of the task
  37134. */
  37135. constructor(
  37136. /**
  37137. * Task name
  37138. */ name: string);
  37139. private _isCompleted;
  37140. private _taskState;
  37141. private _errorObject;
  37142. /**
  37143. * Get if the task is completed
  37144. */
  37145. readonly isCompleted: boolean;
  37146. /**
  37147. * Gets the current state of the task
  37148. */
  37149. readonly taskState: AssetTaskState;
  37150. /**
  37151. * Gets the current error object (if task is in error)
  37152. */
  37153. readonly errorObject: {
  37154. message?: string;
  37155. exception?: any;
  37156. };
  37157. /**
  37158. * Internal only
  37159. * @hidden
  37160. */
  37161. _setErrorObject(message?: string, exception?: any): void;
  37162. /**
  37163. * Execute the current task
  37164. * @param scene defines the scene where you want your assets to be loaded
  37165. * @param onSuccess is a callback called when the task is successfully executed
  37166. * @param onError is a callback called if an error occurs
  37167. */
  37168. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37169. /**
  37170. * Execute the current task
  37171. * @param scene defines the scene where you want your assets to be loaded
  37172. * @param onSuccess is a callback called when the task is successfully executed
  37173. * @param onError is a callback called if an error occurs
  37174. */
  37175. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37176. /**
  37177. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  37178. * This can be used with failed tasks that have the reason for failure fixed.
  37179. */
  37180. reset(): void;
  37181. private onErrorCallback;
  37182. private onDoneCallback;
  37183. }
  37184. /**
  37185. * Define the interface used by progress events raised during assets loading
  37186. */
  37187. interface IAssetsProgressEvent {
  37188. /**
  37189. * Defines the number of remaining tasks to process
  37190. */
  37191. remainingCount: number;
  37192. /**
  37193. * Defines the total number of tasks
  37194. */
  37195. totalCount: number;
  37196. /**
  37197. * Defines the task that was just processed
  37198. */
  37199. task: AbstractAssetTask;
  37200. }
  37201. /**
  37202. * Class used to share progress information about assets loading
  37203. */
  37204. class AssetsProgressEvent implements IAssetsProgressEvent {
  37205. /**
  37206. * Defines the number of remaining tasks to process
  37207. */
  37208. remainingCount: number;
  37209. /**
  37210. * Defines the total number of tasks
  37211. */
  37212. totalCount: number;
  37213. /**
  37214. * Defines the task that was just processed
  37215. */
  37216. task: AbstractAssetTask;
  37217. /**
  37218. * Creates a AssetsProgressEvent
  37219. * @param remainingCount defines the number of remaining tasks to process
  37220. * @param totalCount defines the total number of tasks
  37221. * @param task defines the task that was just processed
  37222. */
  37223. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  37224. }
  37225. /**
  37226. * Define a task used by AssetsManager to load meshes
  37227. */
  37228. class MeshAssetTask extends AbstractAssetTask {
  37229. /**
  37230. * Defines the name of the task
  37231. */
  37232. name: string;
  37233. /**
  37234. * Defines the list of mesh's names you want to load
  37235. */
  37236. meshesNames: any;
  37237. /**
  37238. * Defines the root url to use as a base to load your meshes and associated resources
  37239. */
  37240. rootUrl: string;
  37241. /**
  37242. * Defines the filename of the scene to load from
  37243. */
  37244. sceneFilename: string;
  37245. /**
  37246. * Gets the list of loaded meshes
  37247. */
  37248. loadedMeshes: Array<AbstractMesh>;
  37249. /**
  37250. * Gets the list of loaded particle systems
  37251. */
  37252. loadedParticleSystems: Array<IParticleSystem>;
  37253. /**
  37254. * Gets the list of loaded skeletons
  37255. */
  37256. loadedSkeletons: Array<Skeleton>;
  37257. /**
  37258. * Callback called when the task is successful
  37259. */
  37260. onSuccess: (task: MeshAssetTask) => void;
  37261. /**
  37262. * Callback called when the task is successful
  37263. */
  37264. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  37265. /**
  37266. * Creates a new MeshAssetTask
  37267. * @param name defines the name of the task
  37268. * @param meshesNames defines the list of mesh's names you want to load
  37269. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  37270. * @param sceneFilename defines the filename of the scene to load from
  37271. */
  37272. constructor(
  37273. /**
  37274. * Defines the name of the task
  37275. */
  37276. name: string,
  37277. /**
  37278. * Defines the list of mesh's names you want to load
  37279. */
  37280. meshesNames: any,
  37281. /**
  37282. * Defines the root url to use as a base to load your meshes and associated resources
  37283. */
  37284. rootUrl: string,
  37285. /**
  37286. * Defines the filename of the scene to load from
  37287. */
  37288. sceneFilename: string);
  37289. /**
  37290. * Execute the current task
  37291. * @param scene defines the scene where you want your assets to be loaded
  37292. * @param onSuccess is a callback called when the task is successfully executed
  37293. * @param onError is a callback called if an error occurs
  37294. */
  37295. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37296. }
  37297. /**
  37298. * Define a task used by AssetsManager to load text content
  37299. */
  37300. class TextFileAssetTask extends AbstractAssetTask {
  37301. /**
  37302. * Defines the name of the task
  37303. */
  37304. name: string;
  37305. /**
  37306. * Defines the location of the file to load
  37307. */
  37308. url: string;
  37309. /**
  37310. * Gets the loaded text string
  37311. */
  37312. text: string;
  37313. /**
  37314. * Callback called when the task is successful
  37315. */
  37316. onSuccess: (task: TextFileAssetTask) => void;
  37317. /**
  37318. * Callback called when the task is successful
  37319. */
  37320. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  37321. /**
  37322. * Creates a new TextFileAssetTask object
  37323. * @param name defines the name of the task
  37324. * @param url defines the location of the file to load
  37325. */
  37326. constructor(
  37327. /**
  37328. * Defines the name of the task
  37329. */
  37330. name: string,
  37331. /**
  37332. * Defines the location of the file to load
  37333. */
  37334. url: string);
  37335. /**
  37336. * Execute the current task
  37337. * @param scene defines the scene where you want your assets to be loaded
  37338. * @param onSuccess is a callback called when the task is successfully executed
  37339. * @param onError is a callback called if an error occurs
  37340. */
  37341. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37342. }
  37343. /**
  37344. * Define a task used by AssetsManager to load binary data
  37345. */
  37346. class BinaryFileAssetTask extends AbstractAssetTask {
  37347. /**
  37348. * Defines the name of the task
  37349. */
  37350. name: string;
  37351. /**
  37352. * Defines the location of the file to load
  37353. */
  37354. url: string;
  37355. /**
  37356. * Gets the lodaded data (as an array buffer)
  37357. */
  37358. data: ArrayBuffer;
  37359. /**
  37360. * Callback called when the task is successful
  37361. */
  37362. onSuccess: (task: BinaryFileAssetTask) => void;
  37363. /**
  37364. * Callback called when the task is successful
  37365. */
  37366. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  37367. /**
  37368. * Creates a new BinaryFileAssetTask object
  37369. * @param name defines the name of the new task
  37370. * @param url defines the location of the file to load
  37371. */
  37372. constructor(
  37373. /**
  37374. * Defines the name of the task
  37375. */
  37376. name: string,
  37377. /**
  37378. * Defines the location of the file to load
  37379. */
  37380. url: string);
  37381. /**
  37382. * Execute the current task
  37383. * @param scene defines the scene where you want your assets to be loaded
  37384. * @param onSuccess is a callback called when the task is successfully executed
  37385. * @param onError is a callback called if an error occurs
  37386. */
  37387. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37388. }
  37389. /**
  37390. * Define a task used by AssetsManager to load images
  37391. */
  37392. class ImageAssetTask extends AbstractAssetTask {
  37393. /**
  37394. * Defines the name of the task
  37395. */
  37396. name: string;
  37397. /**
  37398. * Defines the location of the image to load
  37399. */
  37400. url: string;
  37401. /**
  37402. * Gets the loaded images
  37403. */
  37404. image: HTMLImageElement;
  37405. /**
  37406. * Callback called when the task is successful
  37407. */
  37408. onSuccess: (task: ImageAssetTask) => void;
  37409. /**
  37410. * Callback called when the task is successful
  37411. */
  37412. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  37413. /**
  37414. * Creates a new ImageAssetTask
  37415. * @param name defines the name of the task
  37416. * @param url defines the location of the image to load
  37417. */
  37418. constructor(
  37419. /**
  37420. * Defines the name of the task
  37421. */
  37422. name: string,
  37423. /**
  37424. * Defines the location of the image to load
  37425. */
  37426. url: string);
  37427. /**
  37428. * Execute the current task
  37429. * @param scene defines the scene where you want your assets to be loaded
  37430. * @param onSuccess is a callback called when the task is successfully executed
  37431. * @param onError is a callback called if an error occurs
  37432. */
  37433. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37434. }
  37435. /**
  37436. * Defines the interface used by texture loading tasks
  37437. */
  37438. interface ITextureAssetTask<TEX extends BaseTexture> {
  37439. /**
  37440. * Gets the loaded texture
  37441. */
  37442. texture: TEX;
  37443. }
  37444. /**
  37445. * Define a task used by AssetsManager to load 2D textures
  37446. */
  37447. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  37448. /**
  37449. * Defines the name of the task
  37450. */
  37451. name: string;
  37452. /**
  37453. * Defines the location of the file to load
  37454. */
  37455. url: string;
  37456. /**
  37457. * Defines if mipmap should not be generated (default is false)
  37458. */
  37459. noMipmap?: boolean | undefined;
  37460. /**
  37461. * Defines if texture must be inverted on Y axis (default is false)
  37462. */
  37463. invertY?: boolean | undefined;
  37464. /**
  37465. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37466. */
  37467. samplingMode: number;
  37468. /**
  37469. * Gets the loaded texture
  37470. */
  37471. texture: Texture;
  37472. /**
  37473. * Callback called when the task is successful
  37474. */
  37475. onSuccess: (task: TextureAssetTask) => void;
  37476. /**
  37477. * Callback called when the task is successful
  37478. */
  37479. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  37480. /**
  37481. * Creates a new TextureAssetTask object
  37482. * @param name defines the name of the task
  37483. * @param url defines the location of the file to load
  37484. * @param noMipmap defines if mipmap should not be generated (default is false)
  37485. * @param invertY defines if texture must be inverted on Y axis (default is false)
  37486. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  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. * Defines if mipmap should not be generated (default is false)
  37499. */
  37500. noMipmap?: boolean | undefined,
  37501. /**
  37502. * Defines if texture must be inverted on Y axis (default is false)
  37503. */
  37504. invertY?: boolean | undefined,
  37505. /**
  37506. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37507. */
  37508. samplingMode?: number);
  37509. /**
  37510. * Execute the current task
  37511. * @param scene defines the scene where you want your assets to be loaded
  37512. * @param onSuccess is a callback called when the task is successfully executed
  37513. * @param onError is a callback called if an error occurs
  37514. */
  37515. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37516. }
  37517. /**
  37518. * Define a task used by AssetsManager to load cube textures
  37519. */
  37520. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37521. /**
  37522. * Defines the name of the task
  37523. */
  37524. name: string;
  37525. /**
  37526. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37527. */
  37528. url: string;
  37529. /**
  37530. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37531. */
  37532. extensions?: string[] | undefined;
  37533. /**
  37534. * Defines if mipmaps should not be generated (default is false)
  37535. */
  37536. noMipmap?: boolean | undefined;
  37537. /**
  37538. * Defines the explicit list of files (undefined by default)
  37539. */
  37540. files?: string[] | undefined;
  37541. /**
  37542. * Gets the loaded texture
  37543. */
  37544. texture: CubeTexture;
  37545. /**
  37546. * Callback called when the task is successful
  37547. */
  37548. onSuccess: (task: CubeTextureAssetTask) => void;
  37549. /**
  37550. * Callback called when the task is successful
  37551. */
  37552. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37553. /**
  37554. * Creates a new CubeTextureAssetTask
  37555. * @param name defines the name of the task
  37556. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37557. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37558. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37559. * @param files defines the explicit list of files (undefined by default)
  37560. */
  37561. constructor(
  37562. /**
  37563. * Defines the name of the task
  37564. */
  37565. name: string,
  37566. /**
  37567. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37568. */
  37569. url: string,
  37570. /**
  37571. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37572. */
  37573. extensions?: string[] | undefined,
  37574. /**
  37575. * Defines if mipmaps should not be generated (default is false)
  37576. */
  37577. noMipmap?: boolean | undefined,
  37578. /**
  37579. * Defines the explicit list of files (undefined by default)
  37580. */
  37581. files?: string[] | undefined);
  37582. /**
  37583. * Execute the current task
  37584. * @param scene defines the scene where you want your assets to be loaded
  37585. * @param onSuccess is a callback called when the task is successfully executed
  37586. * @param onError is a callback called if an error occurs
  37587. */
  37588. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37589. }
  37590. /**
  37591. * Define a task used by AssetsManager to load HDR cube textures
  37592. */
  37593. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37594. /**
  37595. * Defines the name of the task
  37596. */
  37597. name: string;
  37598. /**
  37599. * Defines the location of the file to load
  37600. */
  37601. url: string;
  37602. /**
  37603. * Defines the desired size (the more it increases the longer the generation will be)
  37604. */
  37605. size: number;
  37606. /**
  37607. * Defines if mipmaps should not be generated (default is false)
  37608. */
  37609. noMipmap: boolean;
  37610. /**
  37611. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37612. */
  37613. generateHarmonics: boolean;
  37614. /**
  37615. * 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)
  37616. */
  37617. gammaSpace: boolean;
  37618. /**
  37619. * Internal Use Only
  37620. */
  37621. reserved: boolean;
  37622. /**
  37623. * Gets the loaded texture
  37624. */
  37625. texture: HDRCubeTexture;
  37626. /**
  37627. * Callback called when the task is successful
  37628. */
  37629. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37630. /**
  37631. * Callback called when the task is successful
  37632. */
  37633. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37634. /**
  37635. * Creates a new HDRCubeTextureAssetTask object
  37636. * @param name defines the name of the task
  37637. * @param url defines the location of the file to load
  37638. * @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.
  37639. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37640. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37641. * @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)
  37642. * @param reserved Internal use only
  37643. */
  37644. constructor(
  37645. /**
  37646. * Defines the name of the task
  37647. */
  37648. name: string,
  37649. /**
  37650. * Defines the location of the file to load
  37651. */
  37652. url: string,
  37653. /**
  37654. * Defines the desired size (the more it increases the longer the generation will be)
  37655. */
  37656. size: number,
  37657. /**
  37658. * Defines if mipmaps should not be generated (default is false)
  37659. */
  37660. noMipmap?: boolean,
  37661. /**
  37662. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37663. */
  37664. generateHarmonics?: boolean,
  37665. /**
  37666. * 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)
  37667. */
  37668. gammaSpace?: boolean,
  37669. /**
  37670. * Internal Use Only
  37671. */
  37672. reserved?: boolean);
  37673. /**
  37674. * Execute the current task
  37675. * @param scene defines the scene where you want your assets to be loaded
  37676. * @param onSuccess is a callback called when the task is successfully executed
  37677. * @param onError is a callback called if an error occurs
  37678. */
  37679. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37680. }
  37681. /**
  37682. * This class can be used to easily import assets into a scene
  37683. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37684. */
  37685. class AssetsManager {
  37686. private _scene;
  37687. private _isLoading;
  37688. protected _tasks: AbstractAssetTask[];
  37689. protected _waitingTasksCount: number;
  37690. protected _totalTasksCount: number;
  37691. /**
  37692. * Callback called when all tasks are processed
  37693. */
  37694. onFinish: (tasks: AbstractAssetTask[]) => void;
  37695. /**
  37696. * Callback called when a task is successful
  37697. */
  37698. onTaskSuccess: (task: AbstractAssetTask) => void;
  37699. /**
  37700. * Callback called when a task had an error
  37701. */
  37702. onTaskError: (task: AbstractAssetTask) => void;
  37703. /**
  37704. * Callback called when a task is done (whatever the result is)
  37705. */
  37706. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37707. /**
  37708. * Observable called when all tasks are processed
  37709. */
  37710. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37711. /**
  37712. * Observable called when a task had an error
  37713. */
  37714. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37715. /**
  37716. * Observable called when a task is successful
  37717. */
  37718. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37719. /**
  37720. * Observable called when a task is done (whatever the result is)
  37721. */
  37722. onProgressObservable: Observable<IAssetsProgressEvent>;
  37723. /**
  37724. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37725. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37726. */
  37727. useDefaultLoadingScreen: boolean;
  37728. /**
  37729. * Creates a new AssetsManager
  37730. * @param scene defines the scene to work on
  37731. */
  37732. constructor(scene: Scene);
  37733. /**
  37734. * Add a MeshAssetTask to the list of active tasks
  37735. * @param taskName defines the name of the new task
  37736. * @param meshesNames defines the name of meshes to load
  37737. * @param rootUrl defines the root url to use to locate files
  37738. * @param sceneFilename defines the filename of the scene file
  37739. * @returns a new MeshAssetTask object
  37740. */
  37741. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37742. /**
  37743. * Add a TextFileAssetTask to the list of active tasks
  37744. * @param taskName defines the name of the new task
  37745. * @param url defines the url of the file to load
  37746. * @returns a new TextFileAssetTask object
  37747. */
  37748. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37749. /**
  37750. * Add a BinaryFileAssetTask to the list of active tasks
  37751. * @param taskName defines the name of the new task
  37752. * @param url defines the url of the file to load
  37753. * @returns a new BinaryFileAssetTask object
  37754. */
  37755. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37756. /**
  37757. * Add a ImageAssetTask to the list of active tasks
  37758. * @param taskName defines the name of the new task
  37759. * @param url defines the url of the file to load
  37760. * @returns a new ImageAssetTask object
  37761. */
  37762. addImageTask(taskName: string, url: string): ImageAssetTask;
  37763. /**
  37764. * Add a TextureAssetTask to the list of active tasks
  37765. * @param taskName defines the name of the new task
  37766. * @param url defines the url of the file to load
  37767. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37768. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37769. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37770. * @returns a new TextureAssetTask object
  37771. */
  37772. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  37773. /**
  37774. * Add a CubeTextureAssetTask to the list of active tasks
  37775. * @param taskName defines the name of the new task
  37776. * @param url defines the url of the file to load
  37777. * @param extensions defines the extension to use to load the cube map (can be null)
  37778. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37779. * @param files defines the list of files to load (can be null)
  37780. * @returns a new CubeTextureAssetTask object
  37781. */
  37782. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  37783. /**
  37784. *
  37785. * Add a HDRCubeTextureAssetTask to the list of active tasks
  37786. * @param taskName defines the name of the new task
  37787. * @param url defines the url of the file to load
  37788. * @param size defines the size you want for the cubemap (can be null)
  37789. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37790. * @param generateHarmonics defines if you want to automatically generate (true by default)
  37791. * @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)
  37792. * @param reserved Internal use only
  37793. * @returns a new HDRCubeTextureAssetTask object
  37794. */
  37795. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  37796. /**
  37797. * Remove a task from the assets manager.
  37798. * @param task the task to remove
  37799. */
  37800. removeTask(task: AbstractAssetTask): void;
  37801. private _decreaseWaitingTasksCount;
  37802. private _runTask;
  37803. /**
  37804. * Reset the AssetsManager and remove all tasks
  37805. * @return the current instance of the AssetsManager
  37806. */
  37807. reset(): AssetsManager;
  37808. /**
  37809. * Start the loading process
  37810. * @return the current instance of the AssetsManager
  37811. */
  37812. load(): AssetsManager;
  37813. }
  37814. }
  37815. declare module BABYLON {
  37816. /**
  37817. * Direct draw surface info
  37818. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  37819. */
  37820. interface DDSInfo {
  37821. /**
  37822. * Width of the texture
  37823. */
  37824. width: number;
  37825. /**
  37826. * Width of the texture
  37827. */
  37828. height: number;
  37829. /**
  37830. * Number of Mipmaps for the texture
  37831. * @see https://en.wikipedia.org/wiki/Mipmap
  37832. */
  37833. mipmapCount: number;
  37834. /**
  37835. * If the textures format is a known fourCC format
  37836. * @see https://www.fourcc.org/
  37837. */
  37838. isFourCC: boolean;
  37839. /**
  37840. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  37841. */
  37842. isRGB: boolean;
  37843. /**
  37844. * If the texture is a lumincance format
  37845. */
  37846. isLuminance: boolean;
  37847. /**
  37848. * If this is a cube texture
  37849. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  37850. */
  37851. isCube: boolean;
  37852. /**
  37853. * If the texture is a compressed format eg. FOURCC_DXT1
  37854. */
  37855. isCompressed: boolean;
  37856. /**
  37857. * The dxgiFormat of the texture
  37858. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  37859. */
  37860. dxgiFormat: number;
  37861. /**
  37862. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  37863. */
  37864. textureType: number;
  37865. /**
  37866. * Sphericle polynomial created for the dds texture
  37867. */
  37868. sphericalPolynomial?: SphericalPolynomial;
  37869. }
  37870. /**
  37871. * Class used to provide DDS decompression tools
  37872. */
  37873. class DDSTools {
  37874. /**
  37875. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  37876. */
  37877. static StoreLODInAlphaChannel: boolean;
  37878. /**
  37879. * Gets DDS information from an array buffer
  37880. * @param arrayBuffer defines the array buffer to read data from
  37881. * @returns the DDS information
  37882. */
  37883. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  37884. private static _FloatView;
  37885. private static _Int32View;
  37886. private static _ToHalfFloat;
  37887. private static _FromHalfFloat;
  37888. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  37889. private static _GetHalfFloatRGBAArrayBuffer;
  37890. private static _GetFloatRGBAArrayBuffer;
  37891. private static _GetFloatAsUIntRGBAArrayBuffer;
  37892. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  37893. private static _GetRGBAArrayBuffer;
  37894. private static _ExtractLongWordOrder;
  37895. private static _GetRGBArrayBuffer;
  37896. private static _GetLuminanceArrayBuffer;
  37897. /**
  37898. * Uploads DDS Levels to a Babylon Texture
  37899. * @hidden
  37900. */
  37901. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  37902. }
  37903. }
  37904. declare module BABYLON {
  37905. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37906. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37907. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37908. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37909. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37910. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37911. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37912. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37913. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37914. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37915. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37916. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37917. /**
  37918. * Decorator used to define property that can be serialized as reference to a camera
  37919. * @param sourceName defines the name of the property to decorate
  37920. */
  37921. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37922. /**
  37923. * Class used to help serialization objects
  37924. */
  37925. class SerializationHelper {
  37926. /**
  37927. * Static function used to serialized a specific entity
  37928. * @param entity defines the entity to serialize
  37929. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37930. * @returns a JSON compatible object representing the serialization of the entity
  37931. */
  37932. static Serialize<T>(entity: T, serializationObject?: any): any;
  37933. /**
  37934. * Creates a new entity from a serialization data object
  37935. * @param creationFunction defines a function used to instanciated the new entity
  37936. * @param source defines the source serialization data
  37937. * @param scene defines the hosting scene
  37938. * @param rootUrl defines the root url for resources
  37939. * @returns a new entity
  37940. */
  37941. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37942. /**
  37943. * Clones an object
  37944. * @param creationFunction defines the function used to instanciate the new object
  37945. * @param source defines the source object
  37946. * @returns the cloned object
  37947. */
  37948. static Clone<T>(creationFunction: () => T, source: T): T;
  37949. /**
  37950. * Instanciates a new object based on a source one (some data will be shared between both object)
  37951. * @param creationFunction defines the function used to instanciate the new object
  37952. * @param source defines the source object
  37953. * @returns the new object
  37954. */
  37955. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37956. }
  37957. }
  37958. declare module BABYLON {
  37959. /**
  37960. * Wrapper class for promise with external resolve and reject.
  37961. */
  37962. class Deferred<T> {
  37963. /**
  37964. * The promise associated with this deferred object.
  37965. */
  37966. readonly promise: Promise<T>;
  37967. private _resolve;
  37968. private _reject;
  37969. /**
  37970. * The resolve method of the promise associated with this deferred object.
  37971. */
  37972. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  37973. /**
  37974. * The reject method of the promise associated with this deferred object.
  37975. */
  37976. readonly reject: (reason?: any) => void;
  37977. /**
  37978. * Constructor for this deferred object.
  37979. */
  37980. constructor();
  37981. }
  37982. }
  37983. declare module BABYLON {
  37984. /**
  37985. * Raw texture data and descriptor sufficient for WebGL texture upload
  37986. */
  37987. interface EnvironmentTextureInfo {
  37988. /**
  37989. * Version of the environment map
  37990. */
  37991. version: number;
  37992. /**
  37993. * Width of image
  37994. */
  37995. width: number;
  37996. /**
  37997. * Irradiance information stored in the file.
  37998. */
  37999. irradiance: any;
  38000. /**
  38001. * Specular information stored in the file.
  38002. */
  38003. specular: any;
  38004. }
  38005. /**
  38006. * Sets of helpers addressing the serialization and deserialization of environment texture
  38007. * stored in a BabylonJS env file.
  38008. * Those files are usually stored as .env files.
  38009. */
  38010. class EnvironmentTextureTools {
  38011. /**
  38012. * Magic number identifying the env file.
  38013. */
  38014. private static _MagicBytes;
  38015. /**
  38016. * Gets the environment info from an env file.
  38017. * @param data The array buffer containing the .env bytes.
  38018. * @returns the environment file info (the json header) if successfully parsed.
  38019. */
  38020. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  38021. /**
  38022. * Creates an environment texture from a loaded cube texture.
  38023. * @param texture defines the cube texture to convert in env file
  38024. * @return a promise containing the environment data if succesfull.
  38025. */
  38026. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  38027. /**
  38028. * Creates a JSON representation of the spherical data.
  38029. * @param texture defines the texture containing the polynomials
  38030. * @return the JSON representation of the spherical info
  38031. */
  38032. private static _CreateEnvTextureIrradiance;
  38033. /**
  38034. * Uploads the texture info contained in the env file to the GPU.
  38035. * @param texture defines the internal texture to upload to
  38036. * @param arrayBuffer defines the buffer cotaining the data to load
  38037. * @param info defines the texture info retrieved through the GetEnvInfo method
  38038. * @returns a promise
  38039. */
  38040. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  38041. /**
  38042. * Uploads the levels of image data to the GPU.
  38043. * @param texture defines the internal texture to upload to
  38044. * @param imageData defines the array buffer views of image data [mipmap][face]
  38045. * @returns a promise
  38046. */
  38047. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  38048. /**
  38049. * Uploads spherical polynomials information to the texture.
  38050. * @param texture defines the texture we are trying to upload the information to
  38051. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  38052. */
  38053. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  38054. }
  38055. }
  38056. declare module BABYLON {
  38057. /**
  38058. * Class used to help managing file picking and drag'n'drop
  38059. */
  38060. class FilesInput {
  38061. /**
  38062. * List of files ready to be loaded
  38063. */
  38064. static FilesToLoad: {
  38065. [key: string]: File;
  38066. };
  38067. /**
  38068. * Callback called when a file is processed
  38069. */
  38070. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  38071. private _engine;
  38072. private _currentScene;
  38073. private _sceneLoadedCallback;
  38074. private _progressCallback;
  38075. private _additionalRenderLoopLogicCallback;
  38076. private _textureLoadingCallback;
  38077. private _startingProcessingFilesCallback;
  38078. private _onReloadCallback;
  38079. private _errorCallback;
  38080. private _elementToMonitor;
  38081. private _sceneFileToLoad;
  38082. private _filesToLoad;
  38083. /**
  38084. * Creates a new FilesInput
  38085. * @param engine defines the rendering engine
  38086. * @param scene defines the hosting scene
  38087. * @param sceneLoadedCallback callback called when scene is loaded
  38088. * @param progressCallback callback called to track progress
  38089. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  38090. * @param textureLoadingCallback callback called when a texture is loading
  38091. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  38092. * @param onReloadCallback callback called when a reload is requested
  38093. * @param errorCallback callback call if an error occurs
  38094. */
  38095. 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);
  38096. private _dragEnterHandler;
  38097. private _dragOverHandler;
  38098. private _dropHandler;
  38099. /**
  38100. * Calls this function to listen to drag'n'drop events on a specific DOM element
  38101. * @param elementToMonitor defines the DOM element to track
  38102. */
  38103. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  38104. /**
  38105. * Release all associated resources
  38106. */
  38107. dispose(): void;
  38108. private renderFunction;
  38109. private drag;
  38110. private drop;
  38111. private _traverseFolder;
  38112. private _processFiles;
  38113. /**
  38114. * Load files from a drop event
  38115. * @param event defines the drop event to use as source
  38116. */
  38117. loadFiles(event: any): void;
  38118. private _processReload;
  38119. /**
  38120. * Reload the current scene from the loaded files
  38121. */
  38122. reload(): void;
  38123. }
  38124. }
  38125. declare module BABYLON {
  38126. /**
  38127. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  38128. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  38129. */
  38130. class KhronosTextureContainer {
  38131. /** contents of the KTX container file */
  38132. arrayBuffer: any;
  38133. private static HEADER_LEN;
  38134. private static COMPRESSED_2D;
  38135. private static COMPRESSED_3D;
  38136. private static TEX_2D;
  38137. private static TEX_3D;
  38138. /**
  38139. * Gets the openGL type
  38140. */
  38141. glType: number;
  38142. /**
  38143. * Gets the openGL type size
  38144. */
  38145. glTypeSize: number;
  38146. /**
  38147. * Gets the openGL format
  38148. */
  38149. glFormat: number;
  38150. /**
  38151. * Gets the openGL internal format
  38152. */
  38153. glInternalFormat: number;
  38154. /**
  38155. * Gets the base internal format
  38156. */
  38157. glBaseInternalFormat: number;
  38158. /**
  38159. * Gets image width in pixel
  38160. */
  38161. pixelWidth: number;
  38162. /**
  38163. * Gets image height in pixel
  38164. */
  38165. pixelHeight: number;
  38166. /**
  38167. * Gets image depth in pixels
  38168. */
  38169. pixelDepth: number;
  38170. /**
  38171. * Gets the number of array elements
  38172. */
  38173. numberOfArrayElements: number;
  38174. /**
  38175. * Gets the number of faces
  38176. */
  38177. numberOfFaces: number;
  38178. /**
  38179. * Gets the number of mipmap levels
  38180. */
  38181. numberOfMipmapLevels: number;
  38182. /**
  38183. * Gets the bytes of key value data
  38184. */
  38185. bytesOfKeyValueData: number;
  38186. /**
  38187. * Gets the load type
  38188. */
  38189. loadType: number;
  38190. /**
  38191. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  38192. */
  38193. isInvalid: boolean;
  38194. /**
  38195. * Creates a new KhronosTextureContainer
  38196. * @param arrayBuffer contents of the KTX container file
  38197. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  38198. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  38199. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  38200. */
  38201. constructor(
  38202. /** contents of the KTX container file */
  38203. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  38204. /**
  38205. * Revert the endianness of a value.
  38206. * Not as fast hardware based, but will probably never need to use
  38207. * @param val defines the value to convert
  38208. * @returns the new value
  38209. */
  38210. switchEndianness(val: number): number;
  38211. /**
  38212. * Uploads KTX content to a Babylon Texture.
  38213. * It is assumed that the texture has already been created & is currently bound
  38214. * @hidden
  38215. */
  38216. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  38217. private _upload2DCompressedLevels;
  38218. }
  38219. }
  38220. declare module BABYLON {
  38221. /**
  38222. * A class serves as a medium between the observable and its observers
  38223. */
  38224. class EventState {
  38225. /**
  38226. * Create a new EventState
  38227. * @param mask defines the mask associated with this state
  38228. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38229. * @param target defines the original target of the state
  38230. * @param currentTarget defines the current target of the state
  38231. */
  38232. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  38233. /**
  38234. * Initialize the current event state
  38235. * @param mask defines the mask associated with this state
  38236. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38237. * @param target defines the original target of the state
  38238. * @param currentTarget defines the current target of the state
  38239. * @returns the current event state
  38240. */
  38241. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  38242. /**
  38243. * An Observer can set this property to true to prevent subsequent observers of being notified
  38244. */
  38245. skipNextObservers: boolean;
  38246. /**
  38247. * Get the mask value that were used to trigger the event corresponding to this EventState object
  38248. */
  38249. mask: number;
  38250. /**
  38251. * The object that originally notified the event
  38252. */
  38253. target?: any;
  38254. /**
  38255. * The current object in the bubbling phase
  38256. */
  38257. currentTarget?: any;
  38258. /**
  38259. * This will be populated with the return value of the last function that was executed.
  38260. * If it is the first function in the callback chain it will be the event data.
  38261. */
  38262. lastReturnValue?: any;
  38263. }
  38264. /**
  38265. * Represent an Observer registered to a given Observable object.
  38266. */
  38267. class Observer<T> {
  38268. /**
  38269. * Defines the callback to call when the observer is notified
  38270. */
  38271. callback: (eventData: T, eventState: EventState) => void;
  38272. /**
  38273. * Defines the mask of the observer (used to filter notifications)
  38274. */
  38275. mask: number;
  38276. /**
  38277. * Defines the current scope used to restore the JS context
  38278. */
  38279. scope: any;
  38280. /** @hidden */
  38281. _willBeUnregistered: boolean;
  38282. /**
  38283. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  38284. */
  38285. unregisterOnNextCall: boolean;
  38286. /**
  38287. * Creates a new observer
  38288. * @param callback defines the callback to call when the observer is notified
  38289. * @param mask defines the mask of the observer (used to filter notifications)
  38290. * @param scope defines the current scope used to restore the JS context
  38291. */
  38292. constructor(
  38293. /**
  38294. * Defines the callback to call when the observer is notified
  38295. */
  38296. callback: (eventData: T, eventState: EventState) => void,
  38297. /**
  38298. * Defines the mask of the observer (used to filter notifications)
  38299. */
  38300. mask: number,
  38301. /**
  38302. * Defines the current scope used to restore the JS context
  38303. */
  38304. scope?: any);
  38305. }
  38306. /**
  38307. * Represent a list of observers registered to multiple Observables object.
  38308. */
  38309. class MultiObserver<T> {
  38310. private _observers;
  38311. private _observables;
  38312. /**
  38313. * Release associated resources
  38314. */
  38315. dispose(): void;
  38316. /**
  38317. * Raise a callback when one of the observable will notify
  38318. * @param observables defines a list of observables to watch
  38319. * @param callback defines the callback to call on notification
  38320. * @param mask defines the mask used to filter notifications
  38321. * @param scope defines the current scope used to restore the JS context
  38322. * @returns the new MultiObserver
  38323. */
  38324. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  38325. }
  38326. /**
  38327. * The Observable class is a simple implementation of the Observable pattern.
  38328. *
  38329. * 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.
  38330. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  38331. * 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).
  38332. * 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.
  38333. */
  38334. class Observable<T> {
  38335. private _observers;
  38336. private _eventState;
  38337. private _onObserverAdded;
  38338. /**
  38339. * Creates a new observable
  38340. * @param onObserverAdded defines a callback to call when a new observer is added
  38341. */
  38342. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  38343. /**
  38344. * Create a new Observer with the specified callback
  38345. * @param callback the callback that will be executed for that Observer
  38346. * @param mask the mask used to filter observers
  38347. * @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.
  38348. * @param scope optional scope for the callback to be called from
  38349. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  38350. * @returns the new observer created for the callback
  38351. */
  38352. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  38353. /**
  38354. * Create a new Observer with the specified callback and unregisters after the next notification
  38355. * @param callback the callback that will be executed for that Observer
  38356. * @returns the new observer created for the callback
  38357. */
  38358. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  38359. /**
  38360. * Remove an Observer from the Observable object
  38361. * @param observer the instance of the Observer to remove
  38362. * @returns false if it doesn't belong to this Observable
  38363. */
  38364. remove(observer: Nullable<Observer<T>>): boolean;
  38365. /**
  38366. * Remove a callback from the Observable object
  38367. * @param callback the callback to remove
  38368. * @param scope optional scope. If used only the callbacks with this scope will be removed
  38369. * @returns false if it doesn't belong to this Observable
  38370. */
  38371. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  38372. private _deferUnregister;
  38373. private _remove;
  38374. /**
  38375. * Notify all Observers by calling their respective callback with the given data
  38376. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  38377. * @param eventData defines the data to send to all observers
  38378. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  38379. * @param target defines the original target of the state
  38380. * @param currentTarget defines the current target of the state
  38381. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  38382. */
  38383. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  38384. /**
  38385. * Calling this will execute each callback, expecting it to be a promise or return a value.
  38386. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  38387. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  38388. * and it is crucial that all callbacks will be executed.
  38389. * The order of the callbacks is kept, callbacks are not executed parallel.
  38390. *
  38391. * @param eventData The data to be sent to each callback
  38392. * @param mask is used to filter observers defaults to -1
  38393. * @param target defines the callback target (see EventState)
  38394. * @param currentTarget defines he current object in the bubbling phase
  38395. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  38396. */
  38397. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  38398. /**
  38399. * Notify a specific observer
  38400. * @param observer defines the observer to notify
  38401. * @param eventData defines the data to be sent to each callback
  38402. * @param mask is used to filter observers defaults to -1
  38403. */
  38404. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  38405. /**
  38406. * Gets a boolean indicating if the observable has at least one observer
  38407. * @returns true is the Observable has at least one Observer registered
  38408. */
  38409. hasObservers(): boolean;
  38410. /**
  38411. * Clear the list of observers
  38412. */
  38413. clear(): void;
  38414. /**
  38415. * Clone the current observable
  38416. * @returns a new observable
  38417. */
  38418. clone(): Observable<T>;
  38419. /**
  38420. * Does this observable handles observer registered with a given mask
  38421. * @param mask defines the mask to be tested
  38422. * @return whether or not one observer registered with the given mask is handeled
  38423. **/
  38424. hasSpecificMask(mask?: number): boolean;
  38425. }
  38426. }
  38427. declare module BABYLON {
  38428. /**
  38429. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38430. */
  38431. class PerformanceMonitor {
  38432. private _enabled;
  38433. private _rollingFrameTime;
  38434. private _lastFrameTimeMs;
  38435. /**
  38436. * constructor
  38437. * @param frameSampleSize The number of samples required to saturate the sliding window
  38438. */
  38439. constructor(frameSampleSize?: number);
  38440. /**
  38441. * Samples current frame
  38442. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38443. */
  38444. sampleFrame(timeMs?: number): void;
  38445. /**
  38446. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38447. */
  38448. readonly averageFrameTime: number;
  38449. /**
  38450. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38451. */
  38452. readonly averageFrameTimeVariance: number;
  38453. /**
  38454. * Returns the frame time of the most recent frame
  38455. */
  38456. readonly instantaneousFrameTime: number;
  38457. /**
  38458. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38459. */
  38460. readonly averageFPS: number;
  38461. /**
  38462. * Returns the average framerate in frames per second using the most recent frame time
  38463. */
  38464. readonly instantaneousFPS: number;
  38465. /**
  38466. * Returns true if enough samples have been taken to completely fill the sliding window
  38467. */
  38468. readonly isSaturated: boolean;
  38469. /**
  38470. * Enables contributions to the sliding window sample set
  38471. */
  38472. enable(): void;
  38473. /**
  38474. * Disables contributions to the sliding window sample set
  38475. * Samples will not be interpolated over the disabled period
  38476. */
  38477. disable(): void;
  38478. /**
  38479. * Returns true if sampling is enabled
  38480. */
  38481. readonly isEnabled: boolean;
  38482. /**
  38483. * Resets performance monitor
  38484. */
  38485. reset(): void;
  38486. }
  38487. /**
  38488. * RollingAverage
  38489. *
  38490. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38491. */
  38492. class RollingAverage {
  38493. /**
  38494. * Current average
  38495. */
  38496. average: number;
  38497. /**
  38498. * Current variance
  38499. */
  38500. variance: number;
  38501. protected _samples: Array<number>;
  38502. protected _sampleCount: number;
  38503. protected _pos: number;
  38504. protected _m2: number;
  38505. /**
  38506. * constructor
  38507. * @param length The number of samples required to saturate the sliding window
  38508. */
  38509. constructor(length: number);
  38510. /**
  38511. * Adds a sample to the sample set
  38512. * @param v The sample value
  38513. */
  38514. add(v: number): void;
  38515. /**
  38516. * Returns previously added values or null if outside of history or outside the sliding window domain
  38517. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38518. * @return Value previously recorded with add() or null if outside of range
  38519. */
  38520. history(i: number): number;
  38521. /**
  38522. * Returns true if enough samples have been taken to completely fill the sliding window
  38523. * @return true if sample-set saturated
  38524. */
  38525. isSaturated(): boolean;
  38526. /**
  38527. * Resets the rolling average (equivalent to 0 samples taken so far)
  38528. */
  38529. reset(): void;
  38530. /**
  38531. * Wraps a value around the sample range boundaries
  38532. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38533. * @return Wrapped position in sample range
  38534. */
  38535. protected _wrapPosition(i: number): number;
  38536. }
  38537. }
  38538. declare module BABYLON {
  38539. /**
  38540. * Helper class that provides a small promise polyfill
  38541. */
  38542. class PromisePolyfill {
  38543. /**
  38544. * Static function used to check if the polyfill is required
  38545. * If this is the case then the function will inject the polyfill to window.Promise
  38546. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38547. */
  38548. static Apply(force?: boolean): void;
  38549. }
  38550. }
  38551. declare module BABYLON {
  38552. /**
  38553. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38554. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38555. */
  38556. class SceneOptimization {
  38557. /**
  38558. * Defines the priority of this optimization (0 by default which means first in the list)
  38559. */
  38560. priority: number;
  38561. /**
  38562. * Gets a string describing the action executed by the current optimization
  38563. * @returns description string
  38564. */
  38565. getDescription(): string;
  38566. /**
  38567. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38568. * @param scene defines the current scene where to apply this optimization
  38569. * @param optimizer defines the current optimizer
  38570. * @returns true if everything that can be done was applied
  38571. */
  38572. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38573. /**
  38574. * Creates the SceneOptimization object
  38575. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38576. * @param desc defines the description associated with the optimization
  38577. */
  38578. constructor(
  38579. /**
  38580. * Defines the priority of this optimization (0 by default which means first in the list)
  38581. */
  38582. priority?: number);
  38583. }
  38584. /**
  38585. * Defines an optimization used to reduce the size of render target textures
  38586. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38587. */
  38588. class TextureOptimization extends SceneOptimization {
  38589. /**
  38590. * Defines the priority of this optimization (0 by default which means first in the list)
  38591. */
  38592. priority: number;
  38593. /**
  38594. * 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
  38595. */
  38596. maximumSize: number;
  38597. /**
  38598. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38599. */
  38600. step: number;
  38601. /**
  38602. * Gets a string describing the action executed by the current optimization
  38603. * @returns description string
  38604. */
  38605. getDescription(): string;
  38606. /**
  38607. * Creates the TextureOptimization object
  38608. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38609. * @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
  38610. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38611. */
  38612. constructor(
  38613. /**
  38614. * Defines the priority of this optimization (0 by default which means first in the list)
  38615. */
  38616. priority?: number,
  38617. /**
  38618. * 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
  38619. */
  38620. maximumSize?: number,
  38621. /**
  38622. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38623. */
  38624. step?: number);
  38625. /**
  38626. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38627. * @param scene defines the current scene where to apply this optimization
  38628. * @param optimizer defines the current optimizer
  38629. * @returns true if everything that can be done was applied
  38630. */
  38631. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38632. }
  38633. /**
  38634. * Defines an optimization used to increase or decrease the rendering resolution
  38635. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38636. */
  38637. class HardwareScalingOptimization extends SceneOptimization {
  38638. /**
  38639. * Defines the priority of this optimization (0 by default which means first in the list)
  38640. */
  38641. priority: number;
  38642. /**
  38643. * Defines the maximum scale to use (2 by default)
  38644. */
  38645. maximumScale: number;
  38646. /**
  38647. * Defines the step to use between two passes (0.5 by default)
  38648. */
  38649. step: number;
  38650. private _currentScale;
  38651. private _directionOffset;
  38652. /**
  38653. * Gets a string describing the action executed by the current optimization
  38654. * @return description string
  38655. */
  38656. getDescription(): string;
  38657. /**
  38658. * Creates the HardwareScalingOptimization object
  38659. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38660. * @param maximumScale defines the maximum scale to use (2 by default)
  38661. * @param step defines the step to use between two passes (0.5 by default)
  38662. */
  38663. constructor(
  38664. /**
  38665. * Defines the priority of this optimization (0 by default which means first in the list)
  38666. */
  38667. priority?: number,
  38668. /**
  38669. * Defines the maximum scale to use (2 by default)
  38670. */
  38671. maximumScale?: number,
  38672. /**
  38673. * Defines the step to use between two passes (0.5 by default)
  38674. */
  38675. step?: number);
  38676. /**
  38677. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38678. * @param scene defines the current scene where to apply this optimization
  38679. * @param optimizer defines the current optimizer
  38680. * @returns true if everything that can be done was applied
  38681. */
  38682. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38683. }
  38684. /**
  38685. * Defines an optimization used to remove shadows
  38686. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38687. */
  38688. class ShadowsOptimization extends SceneOptimization {
  38689. /**
  38690. * Gets a string describing the action executed by the current optimization
  38691. * @return description string
  38692. */
  38693. getDescription(): string;
  38694. /**
  38695. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38696. * @param scene defines the current scene where to apply this optimization
  38697. * @param optimizer defines the current optimizer
  38698. * @returns true if everything that can be done was applied
  38699. */
  38700. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38701. }
  38702. /**
  38703. * Defines an optimization used to turn post-processes off
  38704. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38705. */
  38706. class PostProcessesOptimization extends SceneOptimization {
  38707. /**
  38708. * Gets a string describing the action executed by the current optimization
  38709. * @return description string
  38710. */
  38711. getDescription(): string;
  38712. /**
  38713. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38714. * @param scene defines the current scene where to apply this optimization
  38715. * @param optimizer defines the current optimizer
  38716. * @returns true if everything that can be done was applied
  38717. */
  38718. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38719. }
  38720. /**
  38721. * Defines an optimization used to turn lens flares off
  38722. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38723. */
  38724. class LensFlaresOptimization extends SceneOptimization {
  38725. /**
  38726. * Gets a string describing the action executed by the current optimization
  38727. * @return description string
  38728. */
  38729. getDescription(): string;
  38730. /**
  38731. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38732. * @param scene defines the current scene where to apply this optimization
  38733. * @param optimizer defines the current optimizer
  38734. * @returns true if everything that can be done was applied
  38735. */
  38736. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38737. }
  38738. /**
  38739. * Defines an optimization based on user defined callback.
  38740. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38741. */
  38742. class CustomOptimization extends SceneOptimization {
  38743. /**
  38744. * Callback called to apply the custom optimization.
  38745. */
  38746. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38747. /**
  38748. * Callback called to get custom description
  38749. */
  38750. onGetDescription: () => string;
  38751. /**
  38752. * Gets a string describing the action executed by the current optimization
  38753. * @returns description string
  38754. */
  38755. getDescription(): string;
  38756. /**
  38757. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38758. * @param scene defines the current scene where to apply this optimization
  38759. * @param optimizer defines the current optimizer
  38760. * @returns true if everything that can be done was applied
  38761. */
  38762. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38763. }
  38764. /**
  38765. * Defines an optimization used to turn particles off
  38766. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38767. */
  38768. class ParticlesOptimization extends SceneOptimization {
  38769. /**
  38770. * Gets a string describing the action executed by the current optimization
  38771. * @return description string
  38772. */
  38773. getDescription(): string;
  38774. /**
  38775. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38776. * @param scene defines the current scene where to apply this optimization
  38777. * @param optimizer defines the current optimizer
  38778. * @returns true if everything that can be done was applied
  38779. */
  38780. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38781. }
  38782. /**
  38783. * Defines an optimization used to turn render targets off
  38784. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38785. */
  38786. class RenderTargetsOptimization extends SceneOptimization {
  38787. /**
  38788. * Gets a string describing the action executed by the current optimization
  38789. * @return description string
  38790. */
  38791. getDescription(): string;
  38792. /**
  38793. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38794. * @param scene defines the current scene where to apply this optimization
  38795. * @param optimizer defines the current optimizer
  38796. * @returns true if everything that can be done was applied
  38797. */
  38798. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38799. }
  38800. /**
  38801. * Defines an optimization used to merge meshes with compatible materials
  38802. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38803. */
  38804. class MergeMeshesOptimization extends SceneOptimization {
  38805. private static _UpdateSelectionTree;
  38806. /**
  38807. * Gets or sets a boolean which defines if optimization octree has to be updated
  38808. */
  38809. /**
  38810. * Gets or sets a boolean which defines if optimization octree has to be updated
  38811. */
  38812. static UpdateSelectionTree: boolean;
  38813. /**
  38814. * Gets a string describing the action executed by the current optimization
  38815. * @return description string
  38816. */
  38817. getDescription(): string;
  38818. private _canBeMerged;
  38819. /**
  38820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38821. * @param scene defines the current scene where to apply this optimization
  38822. * @param optimizer defines the current optimizer
  38823. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  38824. * @returns true if everything that can be done was applied
  38825. */
  38826. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  38827. }
  38828. /**
  38829. * Defines a list of options used by SceneOptimizer
  38830. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38831. */
  38832. class SceneOptimizerOptions {
  38833. /**
  38834. * Defines the target frame rate to reach (60 by default)
  38835. */
  38836. targetFrameRate: number;
  38837. /**
  38838. * Defines the interval between two checkes (2000ms by default)
  38839. */
  38840. trackerDuration: number;
  38841. /**
  38842. * Gets the list of optimizations to apply
  38843. */
  38844. optimizations: SceneOptimization[];
  38845. /**
  38846. * Creates a new list of options used by SceneOptimizer
  38847. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  38848. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  38849. */
  38850. constructor(
  38851. /**
  38852. * Defines the target frame rate to reach (60 by default)
  38853. */
  38854. targetFrameRate?: number,
  38855. /**
  38856. * Defines the interval between two checkes (2000ms by default)
  38857. */
  38858. trackerDuration?: number);
  38859. /**
  38860. * Add a new optimization
  38861. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  38862. * @returns the current SceneOptimizerOptions
  38863. */
  38864. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  38865. /**
  38866. * Add a new custom optimization
  38867. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  38868. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  38869. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38870. * @returns the current SceneOptimizerOptions
  38871. */
  38872. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  38873. /**
  38874. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  38875. * @param targetFrameRate defines the target frame rate (60 by default)
  38876. * @returns a SceneOptimizerOptions object
  38877. */
  38878. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38879. /**
  38880. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  38881. * @param targetFrameRate defines the target frame rate (60 by default)
  38882. * @returns a SceneOptimizerOptions object
  38883. */
  38884. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38885. /**
  38886. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  38887. * @param targetFrameRate defines the target frame rate (60 by default)
  38888. * @returns a SceneOptimizerOptions object
  38889. */
  38890. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38891. }
  38892. /**
  38893. * Class used to run optimizations in order to reach a target frame rate
  38894. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38895. */
  38896. class SceneOptimizer implements IDisposable {
  38897. private _isRunning;
  38898. private _options;
  38899. private _scene;
  38900. private _currentPriorityLevel;
  38901. private _targetFrameRate;
  38902. private _trackerDuration;
  38903. private _currentFrameRate;
  38904. private _sceneDisposeObserver;
  38905. private _improvementMode;
  38906. /**
  38907. * Defines an observable called when the optimizer reaches the target frame rate
  38908. */
  38909. onSuccessObservable: Observable<SceneOptimizer>;
  38910. /**
  38911. * Defines an observable called when the optimizer enables an optimization
  38912. */
  38913. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  38914. /**
  38915. * Defines an observable called when the optimizer is not able to reach the target frame rate
  38916. */
  38917. onFailureObservable: Observable<SceneOptimizer>;
  38918. /**
  38919. * Gets a boolean indicating if the optimizer is in improvement mode
  38920. */
  38921. readonly isInImprovementMode: boolean;
  38922. /**
  38923. * Gets the current priority level (0 at start)
  38924. */
  38925. readonly currentPriorityLevel: number;
  38926. /**
  38927. * Gets the current frame rate checked by the SceneOptimizer
  38928. */
  38929. readonly currentFrameRate: number;
  38930. /**
  38931. * Gets or sets the current target frame rate (60 by default)
  38932. */
  38933. /**
  38934. * Gets or sets the current target frame rate (60 by default)
  38935. */
  38936. targetFrameRate: number;
  38937. /**
  38938. * Gets or sets the current interval between two checks (every 2000ms by default)
  38939. */
  38940. /**
  38941. * Gets or sets the current interval between two checks (every 2000ms by default)
  38942. */
  38943. trackerDuration: number;
  38944. /**
  38945. * Gets the list of active optimizations
  38946. */
  38947. readonly optimizations: SceneOptimization[];
  38948. /**
  38949. * Creates a new SceneOptimizer
  38950. * @param scene defines the scene to work on
  38951. * @param options defines the options to use with the SceneOptimizer
  38952. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  38953. * @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)
  38954. */
  38955. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  38956. /**
  38957. * Stops the current optimizer
  38958. */
  38959. stop(): void;
  38960. /**
  38961. * Reset the optimizer to initial step (current priority level = 0)
  38962. */
  38963. reset(): void;
  38964. /**
  38965. * Start the optimizer. By default it will try to reach a specific framerate
  38966. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  38967. */
  38968. start(): void;
  38969. private _checkCurrentState;
  38970. /**
  38971. * Release all resources
  38972. */
  38973. dispose(): void;
  38974. /**
  38975. * Helper function to create a SceneOptimizer with one single line of code
  38976. * @param scene defines the scene to work on
  38977. * @param options defines the options to use with the SceneOptimizer
  38978. * @param onSuccess defines a callback to call on success
  38979. * @param onFailure defines a callback to call on failure
  38980. * @returns the new SceneOptimizer object
  38981. */
  38982. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  38983. }
  38984. }
  38985. declare module BABYLON {
  38986. /**
  38987. * Class used to serialize a scene into a string
  38988. */
  38989. class SceneSerializer {
  38990. /**
  38991. * Clear cache used by a previous serialization
  38992. */
  38993. static ClearCache(): void;
  38994. /**
  38995. * Serialize a scene into a JSON compatible object
  38996. * @param scene defines the scene to serialize
  38997. * @returns a JSON compatible object
  38998. */
  38999. static Serialize(scene: Scene): any;
  39000. /**
  39001. * Serialize a mesh into a JSON compatible object
  39002. * @param toSerialize defines the mesh to serialize
  39003. * @param withParents defines if parents must be serialized as well
  39004. * @param withChildren defines if children must be serialized as well
  39005. * @returns a JSON compatible object
  39006. */
  39007. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  39008. }
  39009. }
  39010. declare module BABYLON {
  39011. /**
  39012. * Defines an array and its length.
  39013. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  39014. */
  39015. interface ISmartArrayLike<T> {
  39016. /**
  39017. * The data of the array.
  39018. */
  39019. data: Array<T>;
  39020. /**
  39021. * The active length of the array.
  39022. */
  39023. length: number;
  39024. }
  39025. /**
  39026. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39027. */
  39028. class SmartArray<T> implements ISmartArrayLike<T> {
  39029. /**
  39030. * The full set of data from the array.
  39031. */
  39032. data: Array<T>;
  39033. /**
  39034. * The active length of the array.
  39035. */
  39036. length: number;
  39037. protected _id: number;
  39038. /**
  39039. * Instantiates a Smart Array.
  39040. * @param capacity defines the default capacity of the array.
  39041. */
  39042. constructor(capacity: number);
  39043. /**
  39044. * Pushes a value at the end of the active data.
  39045. * @param value defines the object to push in the array.
  39046. */
  39047. push(value: T): void;
  39048. /**
  39049. * Iterates over the active data and apply the lambda to them.
  39050. * @param func defines the action to apply on each value.
  39051. */
  39052. forEach(func: (content: T) => void): void;
  39053. /**
  39054. * Sorts the full sets of data.
  39055. * @param compareFn defines the comparison function to apply.
  39056. */
  39057. sort(compareFn: (a: T, b: T) => number): void;
  39058. /**
  39059. * Resets the active data to an empty array.
  39060. */
  39061. reset(): void;
  39062. /**
  39063. * Releases all the data from the array as well as the array.
  39064. */
  39065. dispose(): void;
  39066. /**
  39067. * Concats the active data with a given array.
  39068. * @param array defines the data to concatenate with.
  39069. */
  39070. concat(array: any): void;
  39071. /**
  39072. * Returns the position of a value in the active data.
  39073. * @param value defines the value to find the index for
  39074. * @returns the index if found in the active data otherwise -1
  39075. */
  39076. indexOf(value: T): number;
  39077. /**
  39078. * Returns whether an element is part of the active data.
  39079. * @param value defines the value to look for
  39080. * @returns true if found in the active data otherwise false
  39081. */
  39082. contains(value: T): boolean;
  39083. private static _GlobalId;
  39084. }
  39085. /**
  39086. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39087. * The data in this array can only be present once
  39088. */
  39089. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  39090. private _duplicateId;
  39091. /**
  39092. * Pushes a value at the end of the active data.
  39093. * THIS DOES NOT PREVENT DUPPLICATE DATA
  39094. * @param value defines the object to push in the array.
  39095. */
  39096. push(value: T): void;
  39097. /**
  39098. * Pushes a value at the end of the active data.
  39099. * If the data is already present, it won t be added again
  39100. * @param value defines the object to push in the array.
  39101. * @returns true if added false if it was already present
  39102. */
  39103. pushNoDuplicate(value: T): boolean;
  39104. /**
  39105. * Resets the active data to an empty array.
  39106. */
  39107. reset(): void;
  39108. /**
  39109. * Concats the active data with a given array.
  39110. * This ensures no dupplicate will be present in the result.
  39111. * @param array defines the data to concatenate with.
  39112. */
  39113. concatWithNoDuplicate(array: any): void;
  39114. }
  39115. }
  39116. declare module BABYLON {
  39117. /**
  39118. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39119. * The underlying implementation relies on an associative array to ensure the best performances.
  39120. * The value can be anything including 'null' but except 'undefined'
  39121. */
  39122. class StringDictionary<T> {
  39123. /**
  39124. * This will clear this dictionary and copy the content from the 'source' one.
  39125. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39126. * @param source the dictionary to take the content from and copy to this dictionary
  39127. */
  39128. copyFrom(source: StringDictionary<T>): void;
  39129. /**
  39130. * Get a value based from its key
  39131. * @param key the given key to get the matching value from
  39132. * @return the value if found, otherwise undefined is returned
  39133. */
  39134. get(key: string): T | undefined;
  39135. /**
  39136. * Get a value from its key or add it if it doesn't exist.
  39137. * This method will ensure you that a given key/data will be present in the dictionary.
  39138. * @param key the given key to get the matching value from
  39139. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39140. * The factory will only be invoked if there's no data for the given key.
  39141. * @return the value corresponding to the key.
  39142. */
  39143. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39144. /**
  39145. * Get a value from its key if present in the dictionary otherwise add it
  39146. * @param key the key to get the value from
  39147. * @param val if there's no such key/value pair in the dictionary add it with this value
  39148. * @return the value corresponding to the key
  39149. */
  39150. getOrAdd(key: string, val: T): T;
  39151. /**
  39152. * Check if there's a given key in the dictionary
  39153. * @param key the key to check for
  39154. * @return true if the key is present, false otherwise
  39155. */
  39156. contains(key: string): boolean;
  39157. /**
  39158. * Add a new key and its corresponding value
  39159. * @param key the key to add
  39160. * @param value the value corresponding to the key
  39161. * @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
  39162. */
  39163. add(key: string, value: T): boolean;
  39164. /**
  39165. * Update a specific value associated to a key
  39166. * @param key defines the key to use
  39167. * @param value defines the value to store
  39168. * @returns true if the value was updated (or false if the key was not found)
  39169. */
  39170. set(key: string, value: T): boolean;
  39171. /**
  39172. * Get the element of the given key and remove it from the dictionary
  39173. * @param key defines the key to search
  39174. * @returns the value associated with the key or null if not found
  39175. */
  39176. getAndRemove(key: string): Nullable<T>;
  39177. /**
  39178. * Remove a key/value from the dictionary.
  39179. * @param key the key to remove
  39180. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39181. */
  39182. remove(key: string): boolean;
  39183. /**
  39184. * Clear the whole content of the dictionary
  39185. */
  39186. clear(): void;
  39187. /**
  39188. * Gets the current count
  39189. */
  39190. readonly count: number;
  39191. /**
  39192. * Execute a callback on each key/val of the dictionary.
  39193. * Note that you can remove any element in this dictionary in the callback implementation
  39194. * @param callback the callback to execute on a given key/value pair
  39195. */
  39196. forEach(callback: (key: string, val: T) => void): void;
  39197. /**
  39198. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39199. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39200. * Note that you can remove any element in this dictionary in the callback implementation
  39201. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39202. * @returns the first item
  39203. */
  39204. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39205. private _count;
  39206. private _data;
  39207. }
  39208. }
  39209. declare module BABYLON {
  39210. /**
  39211. * Class used to store custom tags
  39212. */
  39213. class Tags {
  39214. /**
  39215. * Adds support for tags on the given object
  39216. * @param obj defines the object to use
  39217. */
  39218. static EnableFor(obj: any): void;
  39219. /**
  39220. * Removes tags support
  39221. * @param obj defines the object to use
  39222. */
  39223. static DisableFor(obj: any): void;
  39224. /**
  39225. * Gets a boolean indicating if the given object has tags
  39226. * @param obj defines the object to use
  39227. * @returns a boolean
  39228. */
  39229. static HasTags(obj: any): boolean;
  39230. /**
  39231. * Gets the tags available on a given object
  39232. * @param obj defines the object to use
  39233. * @param asString defines if the tags must be returned as a string instead of an array of strings
  39234. * @returns the tags
  39235. */
  39236. static GetTags(obj: any, asString?: boolean): any;
  39237. /**
  39238. * Adds tags to an object
  39239. * @param obj defines the object to use
  39240. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  39241. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  39242. */
  39243. static AddTagsTo(obj: any, tagsString: string): void;
  39244. /**
  39245. * @hidden
  39246. */
  39247. static _AddTagTo(obj: any, tag: string): void;
  39248. /**
  39249. * Removes specific tags from a specific object
  39250. * @param obj defines the object to use
  39251. * @param tagsString defines the tags to remove
  39252. */
  39253. static RemoveTagsFrom(obj: any, tagsString: string): void;
  39254. /**
  39255. * @hidden
  39256. */
  39257. static _RemoveTagFrom(obj: any, tag: string): void;
  39258. /**
  39259. * Defines if tags hosted on an object match a given query
  39260. * @param obj defines the object to use
  39261. * @param tagsQuery defines the tag query
  39262. * @returns a boolean
  39263. */
  39264. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  39265. }
  39266. }
  39267. declare module BABYLON {
  39268. /**
  39269. * Class used to host texture specific utilities
  39270. */
  39271. class TextureTools {
  39272. /**
  39273. * Uses the GPU to create a copy texture rescaled at a given size
  39274. * @param texture Texture to copy from
  39275. * @param width defines the desired width
  39276. * @param height defines the desired height
  39277. * @param useBilinearMode defines if bilinear mode has to be used
  39278. * @return the generated texture
  39279. */
  39280. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  39281. /**
  39282. * Gets an environment BRDF texture for a given scene
  39283. * @param scene defines the hosting scene
  39284. * @returns the environment BRDF texture
  39285. */
  39286. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  39287. private static _environmentBRDFBase64Texture;
  39288. }
  39289. }
  39290. declare module BABYLON {
  39291. /**
  39292. * Based on jsTGALoader - Javascript loader for TGA file
  39293. * By Vincent Thibault
  39294. * @see http://blog.robrowser.com/javascript-tga-loader.html
  39295. */
  39296. class TGATools {
  39297. private static _TYPE_INDEXED;
  39298. private static _TYPE_RGB;
  39299. private static _TYPE_GREY;
  39300. private static _TYPE_RLE_INDEXED;
  39301. private static _TYPE_RLE_RGB;
  39302. private static _TYPE_RLE_GREY;
  39303. private static _ORIGIN_MASK;
  39304. private static _ORIGIN_SHIFT;
  39305. private static _ORIGIN_BL;
  39306. private static _ORIGIN_BR;
  39307. private static _ORIGIN_UL;
  39308. private static _ORIGIN_UR;
  39309. /**
  39310. * Gets the header of a TGA file
  39311. * @param data defines the TGA data
  39312. * @returns the header
  39313. */
  39314. static GetTGAHeader(data: Uint8Array): any;
  39315. /**
  39316. * Uploads TGA content to a Babylon Texture
  39317. * @hidden
  39318. */
  39319. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  39320. /** @hidden */
  39321. 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;
  39322. /** @hidden */
  39323. 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;
  39324. /** @hidden */
  39325. 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;
  39326. /** @hidden */
  39327. 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;
  39328. /** @hidden */
  39329. 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;
  39330. /** @hidden */
  39331. 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;
  39332. }
  39333. }
  39334. declare module BABYLON {
  39335. /**
  39336. * Interface for any object that can request an animation frame
  39337. */
  39338. interface ICustomAnimationFrameRequester {
  39339. /**
  39340. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  39341. */
  39342. renderFunction?: Function;
  39343. /**
  39344. * Called to request the next frame to render to
  39345. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  39346. */
  39347. requestAnimationFrame: Function;
  39348. /**
  39349. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  39350. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  39351. */
  39352. requestID?: number;
  39353. }
  39354. /**
  39355. * Interface containing an array of animations
  39356. */
  39357. interface IAnimatable {
  39358. /**
  39359. * Array of animations
  39360. */
  39361. animations: Array<Animation>;
  39362. }
  39363. /** Interface used by value gradients (color, factor, ...) */
  39364. interface IValueGradient {
  39365. /**
  39366. * Gets or sets the gradient value (between 0 and 1)
  39367. */
  39368. gradient: number;
  39369. }
  39370. /** Class used to store color4 gradient */
  39371. class ColorGradient implements IValueGradient {
  39372. /**
  39373. * Gets or sets the gradient value (between 0 and 1)
  39374. */
  39375. gradient: number;
  39376. /**
  39377. * Gets or sets first associated color
  39378. */
  39379. color1: Color4;
  39380. /**
  39381. * Gets or sets second associated color
  39382. */
  39383. color2?: Color4;
  39384. /**
  39385. * Will get a color picked randomly between color1 and color2.
  39386. * If color2 is undefined then color1 will be used
  39387. * @param result defines the target Color4 to store the result in
  39388. */
  39389. getColorToRef(result: Color4): void;
  39390. }
  39391. /** Class used to store color 3 gradient */
  39392. class Color3Gradient implements IValueGradient {
  39393. /**
  39394. * Gets or sets the gradient value (between 0 and 1)
  39395. */
  39396. gradient: number;
  39397. /**
  39398. * Gets or sets the associated color
  39399. */
  39400. color: Color3;
  39401. }
  39402. /** Class used to store factor gradient */
  39403. class FactorGradient implements IValueGradient {
  39404. /**
  39405. * Gets or sets the gradient value (between 0 and 1)
  39406. */
  39407. gradient: number;
  39408. /**
  39409. * Gets or sets first associated factor
  39410. */
  39411. factor1: number;
  39412. /**
  39413. * Gets or sets second associated factor
  39414. */
  39415. factor2?: number;
  39416. /**
  39417. * Will get a number picked randomly between factor1 and factor2.
  39418. * If factor2 is undefined then factor1 will be used
  39419. * @returns the picked number
  39420. */
  39421. getFactor(): number;
  39422. }
  39423. /**
  39424. * @ignore
  39425. * Application error to support additional information when loading a file
  39426. */
  39427. class LoadFileError extends Error {
  39428. /** defines the optional XHR request */
  39429. request?: XMLHttpRequest | undefined;
  39430. private static _setPrototypeOf;
  39431. /**
  39432. * Creates a new LoadFileError
  39433. * @param message defines the message of the error
  39434. * @param request defines the optional XHR request
  39435. */
  39436. constructor(message: string,
  39437. /** defines the optional XHR request */
  39438. request?: XMLHttpRequest | undefined);
  39439. }
  39440. /**
  39441. * Class used to define a retry strategy when error happens while loading assets
  39442. */
  39443. class RetryStrategy {
  39444. /**
  39445. * Function used to defines an exponential back off strategy
  39446. * @param maxRetries defines the maximum number of retries (3 by default)
  39447. * @param baseInterval defines the interval between retries
  39448. * @returns the strategy function to use
  39449. */
  39450. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39451. }
  39452. /**
  39453. * File request interface
  39454. */
  39455. interface IFileRequest {
  39456. /**
  39457. * Raised when the request is complete (success or error).
  39458. */
  39459. onCompleteObservable: Observable<IFileRequest>;
  39460. /**
  39461. * Aborts the request for a file.
  39462. */
  39463. abort: () => void;
  39464. }
  39465. /**
  39466. * Class containing a set of static utilities functions
  39467. */
  39468. class Tools {
  39469. /**
  39470. * Gets or sets the base URL to use to load assets
  39471. */
  39472. static BaseUrl: string;
  39473. /**
  39474. * Enable/Disable Custom HTTP Request Headers globally.
  39475. * default = false
  39476. * @see CustomRequestHeaders
  39477. */
  39478. static UseCustomRequestHeaders: boolean;
  39479. /**
  39480. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39481. * i.e. when loading files, where the server/service expects an Authorization header.
  39482. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  39483. */
  39484. static CustomRequestHeaders: {
  39485. [key: string]: string;
  39486. };
  39487. /**
  39488. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39489. */
  39490. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39491. /**
  39492. * Default behaviour for cors in the application.
  39493. * It can be a string if the expected behavior is identical in the entire app.
  39494. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39495. */
  39496. static CorsBehavior: string | ((url: string | string[]) => string);
  39497. /**
  39498. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39499. * @ignorenaming
  39500. */
  39501. static UseFallbackTexture: boolean;
  39502. /**
  39503. * Use this object to register external classes like custom textures or material
  39504. * to allow the laoders to instantiate them
  39505. */
  39506. static RegisteredExternalClasses: {
  39507. [key: string]: Object;
  39508. };
  39509. /**
  39510. * Texture content used if a texture cannot loaded
  39511. * @ignorenaming
  39512. */
  39513. static fallbackTexture: string;
  39514. /**
  39515. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39516. * @param u defines the coordinate on X axis
  39517. * @param v defines the coordinate on Y axis
  39518. * @param width defines the width of the source data
  39519. * @param height defines the height of the source data
  39520. * @param pixels defines the source byte array
  39521. * @param color defines the output color
  39522. */
  39523. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39524. /**
  39525. * Interpolates between a and b via alpha
  39526. * @param a The lower value (returned when alpha = 0)
  39527. * @param b The upper value (returned when alpha = 1)
  39528. * @param alpha The interpolation-factor
  39529. * @return The mixed value
  39530. */
  39531. static Mix(a: number, b: number, alpha: number): number;
  39532. /**
  39533. * Tries to instantiate a new object from a given class name
  39534. * @param className defines the class name to instantiate
  39535. * @returns the new object or null if the system was not able to do the instantiation
  39536. */
  39537. static Instantiate(className: string): any;
  39538. /**
  39539. * Provides a slice function that will work even on IE
  39540. * @param data defines the array to slice
  39541. * @param start defines the start of the data (optional)
  39542. * @param end defines the end of the data (optional)
  39543. * @returns the new sliced array
  39544. */
  39545. static Slice<T>(data: T, start?: number, end?: number): T;
  39546. /**
  39547. * Polyfill for setImmediate
  39548. * @param action defines the action to execute after the current execution block
  39549. */
  39550. static SetImmediate(action: () => void): void;
  39551. /**
  39552. * Function indicating if a number is an exponent of 2
  39553. * @param value defines the value to test
  39554. * @returns true if the value is an exponent of 2
  39555. */
  39556. static IsExponentOfTwo(value: number): boolean;
  39557. private static _tmpFloatArray;
  39558. /**
  39559. * Returns the nearest 32-bit single precision float representation of a Number
  39560. * @param value A Number. If the parameter is of a different type, it will get converted
  39561. * to a number or to NaN if it cannot be converted
  39562. * @returns number
  39563. */
  39564. static FloatRound(value: number): number;
  39565. /**
  39566. * Find the next highest power of two.
  39567. * @param x Number to start search from.
  39568. * @return Next highest power of two.
  39569. */
  39570. static CeilingPOT(x: number): number;
  39571. /**
  39572. * Find the next lowest power of two.
  39573. * @param x Number to start search from.
  39574. * @return Next lowest power of two.
  39575. */
  39576. static FloorPOT(x: number): number;
  39577. /**
  39578. * Find the nearest power of two.
  39579. * @param x Number to start search from.
  39580. * @return Next nearest power of two.
  39581. */
  39582. static NearestPOT(x: number): number;
  39583. /**
  39584. * Get the closest exponent of two
  39585. * @param value defines the value to approximate
  39586. * @param max defines the maximum value to return
  39587. * @param mode defines how to define the closest value
  39588. * @returns closest exponent of two of the given value
  39589. */
  39590. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39591. /**
  39592. * Extracts the filename from a path
  39593. * @param path defines the path to use
  39594. * @returns the filename
  39595. */
  39596. static GetFilename(path: string): string;
  39597. /**
  39598. * Extracts the "folder" part of a path (everything before the filename).
  39599. * @param uri The URI to extract the info from
  39600. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39601. * @returns The "folder" part of the path
  39602. */
  39603. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39604. /**
  39605. * Extracts text content from a DOM element hierarchy
  39606. * @param element defines the root element
  39607. * @returns a string
  39608. */
  39609. static GetDOMTextContent(element: HTMLElement): string;
  39610. /**
  39611. * Convert an angle in radians to degrees
  39612. * @param angle defines the angle to convert
  39613. * @returns the angle in degrees
  39614. */
  39615. static ToDegrees(angle: number): number;
  39616. /**
  39617. * Convert an angle in degrees to radians
  39618. * @param angle defines the angle to convert
  39619. * @returns the angle in radians
  39620. */
  39621. static ToRadians(angle: number): number;
  39622. /**
  39623. * Encode a buffer to a base64 string
  39624. * @param buffer defines the buffer to encode
  39625. * @returns the encoded string
  39626. */
  39627. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39628. /**
  39629. * Extracts minimum and maximum values from a list of indexed positions
  39630. * @param positions defines the positions to use
  39631. * @param indices defines the indices to the positions
  39632. * @param indexStart defines the start index
  39633. * @param indexCount defines the end index
  39634. * @param bias defines bias value to add to the result
  39635. * @return minimum and maximum values
  39636. */
  39637. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39638. minimum: Vector3;
  39639. maximum: Vector3;
  39640. };
  39641. /**
  39642. * Extracts minimum and maximum values from a list of positions
  39643. * @param positions defines the positions to use
  39644. * @param start defines the start index in the positions array
  39645. * @param count defines the number of positions to handle
  39646. * @param bias defines bias value to add to the result
  39647. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39648. * @return minimum and maximum values
  39649. */
  39650. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39651. minimum: Vector3;
  39652. maximum: Vector3;
  39653. };
  39654. /**
  39655. * Returns an array if obj is not an array
  39656. * @param obj defines the object to evaluate as an array
  39657. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39658. * @returns either obj directly if obj is an array or a new array containing obj
  39659. */
  39660. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39661. /**
  39662. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39663. * @param size the number of element to construct and put in the array
  39664. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39665. * @returns a new array filled with new objects
  39666. */
  39667. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39668. /**
  39669. * Gets the pointer prefix to use
  39670. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39671. */
  39672. static GetPointerPrefix(): string;
  39673. /**
  39674. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39675. * @param func - the function to be called
  39676. * @param requester - the object that will request the next frame. Falls back to window.
  39677. * @returns frame number
  39678. */
  39679. static QueueNewFrame(func: () => void, requester?: any): number;
  39680. /**
  39681. * Ask the browser to promote the current element to fullscreen rendering mode
  39682. * @param element defines the DOM element to promote
  39683. */
  39684. static RequestFullscreen(element: HTMLElement): void;
  39685. /**
  39686. * Asks the browser to exit fullscreen mode
  39687. */
  39688. static ExitFullscreen(): void;
  39689. /**
  39690. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39691. * @param url define the url we are trying
  39692. * @param element define the dom element where to configure the cors policy
  39693. */
  39694. static SetCorsBehavior(url: string | string[], element: {
  39695. crossOrigin: string | null;
  39696. }): void;
  39697. /**
  39698. * Removes unwanted characters from an url
  39699. * @param url defines the url to clean
  39700. * @returns the cleaned url
  39701. */
  39702. static CleanUrl(url: string): string;
  39703. /**
  39704. * Gets or sets a function used to pre-process url before using them to load assets
  39705. */
  39706. static PreprocessUrl: (url: string) => string;
  39707. /**
  39708. * Loads an image as an HTMLImageElement.
  39709. * @param input url string, ArrayBuffer, or Blob to load
  39710. * @param onLoad callback called when the image successfully loads
  39711. * @param onError callback called when the image fails to load
  39712. * @param offlineProvider offline provider for caching
  39713. * @returns the HTMLImageElement of the loaded image
  39714. */
  39715. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39716. /**
  39717. * Loads a file
  39718. * @param url url string, ArrayBuffer, or Blob to load
  39719. * @param onSuccess callback called when the file successfully loads
  39720. * @param onProgress callback called while file is loading (if the server supports this mode)
  39721. * @param offlineProvider defines the offline provider for caching
  39722. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39723. * @param onError callback called when the file fails to load
  39724. * @returns a file request object
  39725. */
  39726. 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;
  39727. /**
  39728. * Load a script (identified by an url). When the url returns, the
  39729. * content of this file is added into a new script element, attached to the DOM (body element)
  39730. * @param scriptUrl defines the url of the script to laod
  39731. * @param onSuccess defines the callback called when the script is loaded
  39732. * @param onError defines the callback to call if an error occurs
  39733. */
  39734. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39735. /**
  39736. * Loads a file from a blob
  39737. * @param fileToLoad defines the blob to use
  39738. * @param callback defines the callback to call when data is loaded
  39739. * @param progressCallback defines the callback to call during loading process
  39740. * @returns a file request object
  39741. */
  39742. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39743. /**
  39744. * Loads a file
  39745. * @param fileToLoad defines the file to load
  39746. * @param callback defines the callback to call when data is loaded
  39747. * @param progressCallBack defines the callback to call during loading process
  39748. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39749. * @returns a file request object
  39750. */
  39751. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39752. /**
  39753. * Creates a data url from a given string content
  39754. * @param content defines the content to convert
  39755. * @returns the new data url link
  39756. */
  39757. static FileAsURL(content: string): string;
  39758. /**
  39759. * Format the given number to a specific decimal format
  39760. * @param value defines the number to format
  39761. * @param decimals defines the number of decimals to use
  39762. * @returns the formatted string
  39763. */
  39764. static Format(value: number, decimals?: number): string;
  39765. /**
  39766. * Checks if a given vector is inside a specific range
  39767. * @param v defines the vector to test
  39768. * @param min defines the minimum range
  39769. * @param max defines the maximum range
  39770. */
  39771. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39772. /**
  39773. * Tries to copy an object by duplicating every property
  39774. * @param source defines the source object
  39775. * @param destination defines the target object
  39776. * @param doNotCopyList defines a list of properties to avoid
  39777. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39778. */
  39779. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39780. /**
  39781. * Gets a boolean indicating if the given object has no own property
  39782. * @param obj defines the object to test
  39783. * @returns true if object has no own property
  39784. */
  39785. static IsEmpty(obj: any): boolean;
  39786. /**
  39787. * Function used to register events at window level
  39788. * @param events defines the events to register
  39789. */
  39790. static RegisterTopRootEvents(events: {
  39791. name: string;
  39792. handler: Nullable<(e: FocusEvent) => any>;
  39793. }[]): void;
  39794. /**
  39795. * Function used to unregister events from window level
  39796. * @param events defines the events to unregister
  39797. */
  39798. static UnregisterTopRootEvents(events: {
  39799. name: string;
  39800. handler: Nullable<(e: FocusEvent) => any>;
  39801. }[]): void;
  39802. /**
  39803. * Dumps the current bound framebuffer
  39804. * @param width defines the rendering width
  39805. * @param height defines the rendering height
  39806. * @param engine defines the hosting engine
  39807. * @param successCallback defines the callback triggered once the data are available
  39808. * @param mimeType defines the mime type of the result
  39809. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39810. */
  39811. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39812. /**
  39813. * Converts the canvas data to blob.
  39814. * This acts as a polyfill for browsers not supporting the to blob function.
  39815. * @param canvas Defines the canvas to extract the data from
  39816. * @param successCallback Defines the callback triggered once the data are available
  39817. * @param mimeType Defines the mime type of the result
  39818. */
  39819. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39820. /**
  39821. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39822. * @param successCallback defines the callback triggered once the data are available
  39823. * @param mimeType defines the mime type of the result
  39824. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39825. */
  39826. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39827. /**
  39828. * Downloads a blob in the browser
  39829. * @param blob defines the blob to download
  39830. * @param fileName defines the name of the downloaded file
  39831. */
  39832. static Download(blob: Blob, fileName: string): void;
  39833. /**
  39834. * Captures a screenshot of the current rendering
  39835. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39836. * @param engine defines the rendering engine
  39837. * @param camera defines the source camera
  39838. * @param size This parameter can be set to a single number or to an object with the
  39839. * following (optional) properties: precision, width, height. If a single number is passed,
  39840. * it will be used for both width and height. If an object is passed, the screenshot size
  39841. * will be derived from the parameters. The precision property is a multiplier allowing
  39842. * rendering at a higher or lower resolution
  39843. * @param successCallback defines the callback receives a single parameter which contains the
  39844. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39845. * src parameter of an <img> to display it
  39846. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39847. * Check your browser for supported MIME types
  39848. */
  39849. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  39850. /**
  39851. * Generates an image screenshot from the specified camera.
  39852. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39853. * @param engine The engine to use for rendering
  39854. * @param camera The camera to use for rendering
  39855. * @param size This parameter can be set to a single number or to an object with the
  39856. * following (optional) properties: precision, width, height. If a single number is passed,
  39857. * it will be used for both width and height. If an object is passed, the screenshot size
  39858. * will be derived from the parameters. The precision property is a multiplier allowing
  39859. * rendering at a higher or lower resolution
  39860. * @param successCallback The callback receives a single parameter which contains the
  39861. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39862. * src parameter of an <img> to display it
  39863. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39864. * Check your browser for supported MIME types
  39865. * @param samples Texture samples (default: 1)
  39866. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39867. * @param fileName A name for for the downloaded file.
  39868. */
  39869. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39870. /**
  39871. * Validates if xhr data is correct
  39872. * @param xhr defines the request to validate
  39873. * @param dataType defines the expected data type
  39874. * @returns true if data is correct
  39875. */
  39876. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  39877. /**
  39878. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39879. * Be aware Math.random() could cause collisions, but:
  39880. * "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"
  39881. * @returns a pseudo random id
  39882. */
  39883. static RandomId(): string;
  39884. /**
  39885. * Test if the given uri is a base64 string
  39886. * @param uri The uri to test
  39887. * @return True if the uri is a base64 string or false otherwise
  39888. */
  39889. static IsBase64(uri: string): boolean;
  39890. /**
  39891. * Decode the given base64 uri.
  39892. * @param uri The uri to decode
  39893. * @return The decoded base64 data.
  39894. */
  39895. static DecodeBase64(uri: string): ArrayBuffer;
  39896. /**
  39897. * No log
  39898. */
  39899. static readonly NoneLogLevel: number;
  39900. /**
  39901. * Only message logs
  39902. */
  39903. static readonly MessageLogLevel: number;
  39904. /**
  39905. * Only warning logs
  39906. */
  39907. static readonly WarningLogLevel: number;
  39908. /**
  39909. * Only error logs
  39910. */
  39911. static readonly ErrorLogLevel: number;
  39912. /**
  39913. * All logs
  39914. */
  39915. static readonly AllLogLevel: number;
  39916. private static _LogCache;
  39917. /**
  39918. * Gets a value indicating the number of loading errors
  39919. * @ignorenaming
  39920. */
  39921. static errorsCount: number;
  39922. /**
  39923. * Callback called when a new log is added
  39924. */
  39925. static OnNewCacheEntry: (entry: string) => void;
  39926. private static _AddLogEntry;
  39927. private static _FormatMessage;
  39928. private static _LogDisabled;
  39929. private static _LogEnabled;
  39930. private static _WarnDisabled;
  39931. private static _WarnEnabled;
  39932. private static _ErrorDisabled;
  39933. private static _ErrorEnabled;
  39934. /**
  39935. * Log a message to the console
  39936. */
  39937. static Log: (message: string) => void;
  39938. /**
  39939. * Write a warning message to the console
  39940. */
  39941. static Warn: (message: string) => void;
  39942. /**
  39943. * Write an error message to the console
  39944. */
  39945. static Error: (message: string) => void;
  39946. /**
  39947. * Gets current log cache (list of logs)
  39948. */
  39949. static readonly LogCache: string;
  39950. /**
  39951. * Clears the log cache
  39952. */
  39953. static ClearLogCache(): void;
  39954. /**
  39955. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39956. */
  39957. static LogLevels: number;
  39958. /**
  39959. * Checks if the loaded document was accessed via `file:`-Protocol.
  39960. * @returns boolean
  39961. */
  39962. static IsFileURL(): boolean;
  39963. /**
  39964. * Checks if the window object exists
  39965. * @returns true if the window object exists
  39966. */
  39967. static IsWindowObjectExist(): boolean;
  39968. /**
  39969. * No performance log
  39970. */
  39971. static readonly PerformanceNoneLogLevel: number;
  39972. /**
  39973. * Use user marks to log performance
  39974. */
  39975. static readonly PerformanceUserMarkLogLevel: number;
  39976. /**
  39977. * Log performance to the console
  39978. */
  39979. static readonly PerformanceConsoleLogLevel: number;
  39980. private static _performance;
  39981. /**
  39982. * Sets the current performance log level
  39983. */
  39984. static PerformanceLogLevel: number;
  39985. private static _StartPerformanceCounterDisabled;
  39986. private static _EndPerformanceCounterDisabled;
  39987. private static _StartUserMark;
  39988. private static _EndUserMark;
  39989. private static _StartPerformanceConsole;
  39990. private static _EndPerformanceConsole;
  39991. /**
  39992. * Injects the @see CustomRequestHeaders into the given request
  39993. * @param request the request that should be used for injection
  39994. */
  39995. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  39996. /**
  39997. * Starts a performance counter
  39998. */
  39999. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40000. /**
  40001. * Ends a specific performance coutner
  40002. */
  40003. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40004. /**
  40005. * Gets either window.performance.now() if supported or Date.now() else
  40006. */
  40007. static readonly Now: number;
  40008. /**
  40009. * This method will return the name of the class used to create the instance of the given object.
  40010. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40011. * @param object the object to get the class name from
  40012. * @param isType defines if the object is actually a type
  40013. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40014. */
  40015. static GetClassName(object: any, isType?: boolean): string;
  40016. /**
  40017. * Gets the first element of an array satisfying a given predicate
  40018. * @param array defines the array to browse
  40019. * @param predicate defines the predicate to use
  40020. * @returns null if not found or the element
  40021. */
  40022. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40023. /**
  40024. * This method will return the name of the full name of the class, including its owning module (if any).
  40025. * 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).
  40026. * @param object the object to get the class name from
  40027. * @param isType defines if the object is actually a type
  40028. * @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.
  40029. * @ignorenaming
  40030. */
  40031. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40032. /**
  40033. * Returns a promise that resolves after the given amount of time.
  40034. * @param delay Number of milliseconds to delay
  40035. * @returns Promise that resolves after the given amount of time
  40036. */
  40037. static DelayAsync(delay: number): Promise<void>;
  40038. /**
  40039. * Gets the current gradient from an array of IValueGradient
  40040. * @param ratio defines the current ratio to get
  40041. * @param gradients defines the array of IValueGradient
  40042. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  40043. */
  40044. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  40045. }
  40046. /**
  40047. * This class is used to track a performance counter which is number based.
  40048. * The user has access to many properties which give statistics of different nature.
  40049. *
  40050. * The implementer can track two kinds of Performance Counter: time and count.
  40051. * 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.
  40052. * 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.
  40053. */
  40054. class PerfCounter {
  40055. /**
  40056. * Gets or sets a global boolean to turn on and off all the counters
  40057. */
  40058. static Enabled: boolean;
  40059. /**
  40060. * Returns the smallest value ever
  40061. */
  40062. readonly min: number;
  40063. /**
  40064. * Returns the biggest value ever
  40065. */
  40066. readonly max: number;
  40067. /**
  40068. * Returns the average value since the performance counter is running
  40069. */
  40070. readonly average: number;
  40071. /**
  40072. * Returns the average value of the last second the counter was monitored
  40073. */
  40074. readonly lastSecAverage: number;
  40075. /**
  40076. * Returns the current value
  40077. */
  40078. readonly current: number;
  40079. /**
  40080. * Gets the accumulated total
  40081. */
  40082. readonly total: number;
  40083. /**
  40084. * Gets the total value count
  40085. */
  40086. readonly count: number;
  40087. /**
  40088. * Creates a new counter
  40089. */
  40090. constructor();
  40091. /**
  40092. * Call this method to start monitoring a new frame.
  40093. * 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.
  40094. */
  40095. fetchNewFrame(): void;
  40096. /**
  40097. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40098. * @param newCount the count value to add to the monitored count
  40099. * @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.
  40100. */
  40101. addCount(newCount: number, fetchResult: boolean): void;
  40102. /**
  40103. * Start monitoring this performance counter
  40104. */
  40105. beginMonitoring(): void;
  40106. /**
  40107. * Compute the time lapsed since the previous beginMonitoring() call.
  40108. * @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
  40109. */
  40110. endMonitoring(newFrame?: boolean): void;
  40111. private _fetchResult;
  40112. private _startMonitoringTime;
  40113. private _min;
  40114. private _max;
  40115. private _average;
  40116. private _current;
  40117. private _totalValueCount;
  40118. private _totalAccumulated;
  40119. private _lastSecAverage;
  40120. private _lastSecAccumulated;
  40121. private _lastSecTime;
  40122. private _lastSecValueCount;
  40123. }
  40124. /**
  40125. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40126. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40127. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40128. * @param name The name of the class, case should be preserved
  40129. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40130. */
  40131. function className(name: string, module?: string): (target: Object) => void;
  40132. /**
  40133. * An implementation of a loop for asynchronous functions.
  40134. */
  40135. class AsyncLoop {
  40136. /**
  40137. * Defines the number of iterations for the loop
  40138. */
  40139. iterations: number;
  40140. /**
  40141. * Defines the current index of the loop.
  40142. */
  40143. index: number;
  40144. private _done;
  40145. private _fn;
  40146. private _successCallback;
  40147. /**
  40148. * Constructor.
  40149. * @param iterations the number of iterations.
  40150. * @param func the function to run each iteration
  40151. * @param successCallback the callback that will be called upon succesful execution
  40152. * @param offset starting offset.
  40153. */
  40154. constructor(
  40155. /**
  40156. * Defines the number of iterations for the loop
  40157. */
  40158. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40159. /**
  40160. * Execute the next iteration. Must be called after the last iteration was finished.
  40161. */
  40162. executeNext(): void;
  40163. /**
  40164. * Break the loop and run the success callback.
  40165. */
  40166. breakLoop(): void;
  40167. /**
  40168. * Create and run an async loop.
  40169. * @param iterations the number of iterations.
  40170. * @param fn the function to run each iteration
  40171. * @param successCallback the callback that will be called upon succesful execution
  40172. * @param offset starting offset.
  40173. * @returns the created async loop object
  40174. */
  40175. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40176. /**
  40177. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40178. * @param iterations total number of iterations
  40179. * @param syncedIterations number of synchronous iterations in each async iteration.
  40180. * @param fn the function to call each iteration.
  40181. * @param callback a success call back that will be called when iterating stops.
  40182. * @param breakFunction a break condition (optional)
  40183. * @param timeout timeout settings for the setTimeout function. default - 0.
  40184. * @returns the created async loop object
  40185. */
  40186. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40187. }
  40188. }
  40189. interface HTMLCanvasElement {
  40190. /** Track wether a record is in progress */
  40191. isRecording: boolean;
  40192. /** Capture Stream method defined by some browsers */
  40193. captureStream(fps?: number): MediaStream;
  40194. }
  40195. interface MediaRecorder {
  40196. /** Starts recording */
  40197. start(timeSlice: number): void;
  40198. /** Stops recording */
  40199. stop(): void;
  40200. /** Event raised when an error arised. */
  40201. onerror: (event: ErrorEvent) => void;
  40202. /** Event raised when the recording stops. */
  40203. onstop: (event: Event) => void;
  40204. /** Event raised when a new chunk of data is available and should be tracked. */
  40205. ondataavailable: (event: Event) => void;
  40206. }
  40207. interface MediaRecorderOptions {
  40208. /** The mime type you want to use as the recording container for the new MediaRecorder */
  40209. mimeType?: string;
  40210. /** The chosen bitrate for the audio component of the media. */
  40211. audioBitsPerSecond?: number;
  40212. /** The chosen bitrate for the video component of the media. */
  40213. videoBitsPerSecond?: number;
  40214. /** 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. */
  40215. bitsPerSecond?: number;
  40216. }
  40217. interface MediaRecorderConstructor {
  40218. /**
  40219. * A reference to the prototype.
  40220. */
  40221. readonly prototype: MediaRecorder;
  40222. /**
  40223. * Creates a new MediaRecorder.
  40224. * @param stream Defines the stream to record.
  40225. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  40226. */
  40227. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  40228. }
  40229. /**
  40230. * MediaRecoreder object available in some browsers.
  40231. */
  40232. declare var MediaRecorder: MediaRecorderConstructor;
  40233. declare module BABYLON {
  40234. /**
  40235. * This represents the different options avilable for the video capture.
  40236. */
  40237. interface VideoRecorderOptions {
  40238. /** Defines the mime type of the video */
  40239. mimeType: string;
  40240. /** Defines the video the video should be recorded at */
  40241. fps: number;
  40242. /** Defines the chunk size for the recording data */
  40243. recordChunckSize: number;
  40244. }
  40245. /**
  40246. * This can helps recording videos from BabylonJS.
  40247. * This is based on the available WebRTC functionalities of the browser.
  40248. *
  40249. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  40250. */
  40251. class VideoRecorder {
  40252. private static readonly _defaultOptions;
  40253. /**
  40254. * Returns wehther or not the VideoRecorder is available in your browser.
  40255. * @param engine Defines the Babylon Engine to check the support for
  40256. * @returns true if supported otherwise false
  40257. */
  40258. static IsSupported(engine: Engine): boolean;
  40259. private readonly _options;
  40260. private _canvas;
  40261. private _mediaRecorder;
  40262. private _recordedChunks;
  40263. private _fileName;
  40264. private _resolve;
  40265. private _reject;
  40266. /**
  40267. * True wether a recording is already in progress.
  40268. */
  40269. readonly isRecording: boolean;
  40270. /**
  40271. * Create a new VideoCapture object which can help converting what you see in Babylon to
  40272. * a video file.
  40273. * @param engine Defines the BabylonJS Engine you wish to record
  40274. * @param options Defines options that can be used to customized the capture
  40275. */
  40276. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  40277. /**
  40278. * Stops the current recording before the default capture timeout passed in the startRecording
  40279. * functions.
  40280. */
  40281. stopRecording(): void;
  40282. /**
  40283. * Starts recording the canvas for a max duration specified in parameters.
  40284. * @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.
  40285. * @param maxDuration Defines the maximum recording time in seconds.
  40286. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  40287. * @return a promise callback at the end of the recording with the video data in Blob.
  40288. */
  40289. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  40290. /**
  40291. * Releases internal resources used during the recording.
  40292. */
  40293. dispose(): void;
  40294. private _handleDataAvailable;
  40295. private _handleError;
  40296. private _handleStop;
  40297. }
  40298. }
  40299. declare module BABYLON {
  40300. /**
  40301. * Defines the potential axis of a Joystick
  40302. */
  40303. enum JoystickAxis {
  40304. /** X axis */
  40305. X = 0,
  40306. /** Y axis */
  40307. Y = 1,
  40308. /** Z axis */
  40309. Z = 2
  40310. }
  40311. /**
  40312. * Class used to define virtual joystick (used in touch mode)
  40313. */
  40314. class VirtualJoystick {
  40315. /**
  40316. * Gets or sets a boolean indicating that left and right values must be inverted
  40317. */
  40318. reverseLeftRight: boolean;
  40319. /**
  40320. * Gets or sets a boolean indicating that up and down values must be inverted
  40321. */
  40322. reverseUpDown: boolean;
  40323. /**
  40324. * Gets the offset value for the position (ie. the change of the position value)
  40325. */
  40326. deltaPosition: Vector3;
  40327. /**
  40328. * Gets a boolean indicating if the virtual joystick was pressed
  40329. */
  40330. pressed: boolean;
  40331. /**
  40332. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40333. */
  40334. static Canvas: Nullable<HTMLCanvasElement>;
  40335. private static _globalJoystickIndex;
  40336. private static vjCanvasContext;
  40337. private static vjCanvasWidth;
  40338. private static vjCanvasHeight;
  40339. private static halfWidth;
  40340. private _action;
  40341. private _axisTargetedByLeftAndRight;
  40342. private _axisTargetedByUpAndDown;
  40343. private _joystickSensibility;
  40344. private _inversedSensibility;
  40345. private _joystickPointerID;
  40346. private _joystickColor;
  40347. private _joystickPointerPos;
  40348. private _joystickPreviousPointerPos;
  40349. private _joystickPointerStartPos;
  40350. private _deltaJoystickVector;
  40351. private _leftJoystick;
  40352. private _touches;
  40353. private _onPointerDownHandlerRef;
  40354. private _onPointerMoveHandlerRef;
  40355. private _onPointerUpHandlerRef;
  40356. private _onResize;
  40357. /**
  40358. * Creates a new virtual joystick
  40359. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40360. */
  40361. constructor(leftJoystick?: boolean);
  40362. /**
  40363. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40364. * @param newJoystickSensibility defines the new sensibility
  40365. */
  40366. setJoystickSensibility(newJoystickSensibility: number): void;
  40367. private _onPointerDown;
  40368. private _onPointerMove;
  40369. private _onPointerUp;
  40370. /**
  40371. * Change the color of the virtual joystick
  40372. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40373. */
  40374. setJoystickColor(newColor: string): void;
  40375. /**
  40376. * Defines a callback to call when the joystick is touched
  40377. * @param action defines the callback
  40378. */
  40379. setActionOnTouch(action: () => any): void;
  40380. /**
  40381. * Defines which axis you'd like to control for left & right
  40382. * @param axis defines the axis to use
  40383. */
  40384. setAxisForLeftRight(axis: JoystickAxis): void;
  40385. /**
  40386. * Defines which axis you'd like to control for up & down
  40387. * @param axis defines the axis to use
  40388. */
  40389. setAxisForUpDown(axis: JoystickAxis): void;
  40390. private _drawVirtualJoystick;
  40391. /**
  40392. * Release internal HTML canvas
  40393. */
  40394. releaseCanvas(): void;
  40395. }
  40396. }
  40397. declare module BABYLON {
  40398. /**
  40399. * Helper class to push actions to a pool of workers.
  40400. */
  40401. class WorkerPool implements IDisposable {
  40402. private _workerInfos;
  40403. private _pendingActions;
  40404. /**
  40405. * Constructor
  40406. * @param workers Array of workers to use for actions
  40407. */
  40408. constructor(workers: Array<Worker>);
  40409. /**
  40410. * Terminates all workers and clears any pending actions.
  40411. */
  40412. dispose(): void;
  40413. /**
  40414. * Pushes an action to the worker pool. If all the workers are active, the action will be
  40415. * pended until a worker has completed its action.
  40416. * @param action The action to perform. Call onComplete when the action is complete.
  40417. */
  40418. push(action: (worker: Worker, onComplete: () => void) => void): void;
  40419. private _execute;
  40420. }
  40421. }
  40422. declare module BABYLON {
  40423. /**
  40424. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40425. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40426. */
  40427. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40428. /**
  40429. * Gets the name of the behavior.
  40430. */
  40431. readonly name: string;
  40432. private _zoomStopsAnimation;
  40433. private _idleRotationSpeed;
  40434. private _idleRotationWaitTime;
  40435. private _idleRotationSpinupTime;
  40436. /**
  40437. * Sets the flag that indicates if user zooming should stop animation.
  40438. */
  40439. /**
  40440. * Gets the flag that indicates if user zooming should stop animation.
  40441. */
  40442. zoomStopsAnimation: boolean;
  40443. /**
  40444. * Sets the default speed at which the camera rotates around the model.
  40445. */
  40446. /**
  40447. * Gets the default speed at which the camera rotates around the model.
  40448. */
  40449. idleRotationSpeed: number;
  40450. /**
  40451. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40452. */
  40453. /**
  40454. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40455. */
  40456. idleRotationWaitTime: number;
  40457. /**
  40458. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40459. */
  40460. /**
  40461. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40462. */
  40463. idleRotationSpinupTime: number;
  40464. /**
  40465. * Gets a value indicating if the camera is currently rotating because of this behavior
  40466. */
  40467. readonly rotationInProgress: boolean;
  40468. private _onPrePointerObservableObserver;
  40469. private _onAfterCheckInputsObserver;
  40470. private _attachedCamera;
  40471. private _isPointerDown;
  40472. private _lastFrameTime;
  40473. private _lastInteractionTime;
  40474. private _cameraRotationSpeed;
  40475. /**
  40476. * Initializes the behavior.
  40477. */
  40478. init(): void;
  40479. /**
  40480. * Attaches the behavior to its arc rotate camera.
  40481. * @param camera Defines the camera to attach the behavior to
  40482. */
  40483. attach(camera: ArcRotateCamera): void;
  40484. /**
  40485. * Detaches the behavior from its current arc rotate camera.
  40486. */
  40487. detach(): void;
  40488. /**
  40489. * Returns true if user is scrolling.
  40490. * @return true if user is scrolling.
  40491. */
  40492. private _userIsZooming;
  40493. private _lastFrameRadius;
  40494. private _shouldAnimationStopForInteraction;
  40495. /**
  40496. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40497. */
  40498. private _applyUserInteraction;
  40499. private _userIsMoving;
  40500. }
  40501. }
  40502. declare module BABYLON {
  40503. /**
  40504. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40505. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40506. */
  40507. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40508. /**
  40509. * Gets the name of the behavior.
  40510. */
  40511. readonly name: string;
  40512. /**
  40513. * The easing function used by animations
  40514. */
  40515. static EasingFunction: BackEase;
  40516. /**
  40517. * The easing mode used by animations
  40518. */
  40519. static EasingMode: number;
  40520. /**
  40521. * The duration of the animation, in milliseconds
  40522. */
  40523. transitionDuration: number;
  40524. /**
  40525. * Length of the distance animated by the transition when lower radius is reached
  40526. */
  40527. lowerRadiusTransitionRange: number;
  40528. /**
  40529. * Length of the distance animated by the transition when upper radius is reached
  40530. */
  40531. upperRadiusTransitionRange: number;
  40532. private _autoTransitionRange;
  40533. /**
  40534. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40535. */
  40536. /**
  40537. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40538. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40539. */
  40540. autoTransitionRange: boolean;
  40541. private _attachedCamera;
  40542. private _onAfterCheckInputsObserver;
  40543. private _onMeshTargetChangedObserver;
  40544. /**
  40545. * Initializes the behavior.
  40546. */
  40547. init(): void;
  40548. /**
  40549. * Attaches the behavior to its arc rotate camera.
  40550. * @param camera Defines the camera to attach the behavior to
  40551. */
  40552. attach(camera: ArcRotateCamera): void;
  40553. /**
  40554. * Detaches the behavior from its current arc rotate camera.
  40555. */
  40556. detach(): void;
  40557. private _radiusIsAnimating;
  40558. private _radiusBounceTransition;
  40559. private _animatables;
  40560. private _cachedWheelPrecision;
  40561. /**
  40562. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40563. * @param radiusLimit The limit to check against.
  40564. * @return Bool to indicate if at limit.
  40565. */
  40566. private _isRadiusAtLimit;
  40567. /**
  40568. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40569. * @param radiusDelta The delta by which to animate to. Can be negative.
  40570. */
  40571. private _applyBoundRadiusAnimation;
  40572. /**
  40573. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40574. */
  40575. protected _clearAnimationLocks(): void;
  40576. /**
  40577. * Stops and removes all animations that have been applied to the camera
  40578. */
  40579. stopAllAnimations(): void;
  40580. }
  40581. }
  40582. declare module BABYLON {
  40583. /**
  40584. * 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.
  40585. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40586. */
  40587. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40588. /**
  40589. * Gets the name of the behavior.
  40590. */
  40591. readonly name: string;
  40592. private _mode;
  40593. private _radiusScale;
  40594. private _positionScale;
  40595. private _defaultElevation;
  40596. private _elevationReturnTime;
  40597. private _elevationReturnWaitTime;
  40598. private _zoomStopsAnimation;
  40599. private _framingTime;
  40600. /**
  40601. * The easing function used by animations
  40602. */
  40603. static EasingFunction: ExponentialEase;
  40604. /**
  40605. * The easing mode used by animations
  40606. */
  40607. static EasingMode: number;
  40608. /**
  40609. * Sets the current mode used by the behavior
  40610. */
  40611. /**
  40612. * Gets current mode used by the behavior.
  40613. */
  40614. mode: number;
  40615. /**
  40616. * Sets the scale applied to the radius (1 by default)
  40617. */
  40618. /**
  40619. * Gets the scale applied to the radius
  40620. */
  40621. radiusScale: number;
  40622. /**
  40623. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40624. */
  40625. /**
  40626. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40627. */
  40628. positionScale: number;
  40629. /**
  40630. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40631. * behaviour is triggered, in radians.
  40632. */
  40633. /**
  40634. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40635. * behaviour is triggered, in radians.
  40636. */
  40637. defaultElevation: number;
  40638. /**
  40639. * Sets the time (in milliseconds) taken to return to the default beta position.
  40640. * Negative value indicates camera should not return to default.
  40641. */
  40642. /**
  40643. * Gets the time (in milliseconds) taken to return to the default beta position.
  40644. * Negative value indicates camera should not return to default.
  40645. */
  40646. elevationReturnTime: number;
  40647. /**
  40648. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40649. */
  40650. /**
  40651. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40652. */
  40653. elevationReturnWaitTime: number;
  40654. /**
  40655. * Sets the flag that indicates if user zooming should stop animation.
  40656. */
  40657. /**
  40658. * Gets the flag that indicates if user zooming should stop animation.
  40659. */
  40660. zoomStopsAnimation: boolean;
  40661. /**
  40662. * Sets the transition time when framing the mesh, in milliseconds
  40663. */
  40664. /**
  40665. * Gets the transition time when framing the mesh, in milliseconds
  40666. */
  40667. framingTime: number;
  40668. /**
  40669. * Define if the behavior should automatically change the configured
  40670. * camera limits and sensibilities.
  40671. */
  40672. autoCorrectCameraLimitsAndSensibility: boolean;
  40673. private _onPrePointerObservableObserver;
  40674. private _onAfterCheckInputsObserver;
  40675. private _onMeshTargetChangedObserver;
  40676. private _attachedCamera;
  40677. private _isPointerDown;
  40678. private _lastInteractionTime;
  40679. /**
  40680. * Initializes the behavior.
  40681. */
  40682. init(): void;
  40683. /**
  40684. * Attaches the behavior to its arc rotate camera.
  40685. * @param camera Defines the camera to attach the behavior to
  40686. */
  40687. attach(camera: ArcRotateCamera): void;
  40688. /**
  40689. * Detaches the behavior from its current arc rotate camera.
  40690. */
  40691. detach(): void;
  40692. private _animatables;
  40693. private _betaIsAnimating;
  40694. private _betaTransition;
  40695. private _radiusTransition;
  40696. private _vectorTransition;
  40697. /**
  40698. * Targets the given mesh and updates zoom level accordingly.
  40699. * @param mesh The mesh to target.
  40700. * @param radius Optional. If a cached radius position already exists, overrides default.
  40701. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40702. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40703. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40704. */
  40705. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40706. /**
  40707. * Targets the given mesh with its children and updates zoom level accordingly.
  40708. * @param mesh The mesh to target.
  40709. * @param radius Optional. If a cached radius position already exists, overrides default.
  40710. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40711. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40712. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40713. */
  40714. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40715. /**
  40716. * Targets the given meshes with their children and updates zoom level accordingly.
  40717. * @param meshes The mesh to target.
  40718. * @param radius Optional. If a cached radius position already exists, overrides default.
  40719. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40720. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40721. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40722. */
  40723. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40724. /**
  40725. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40726. * @param minimumWorld Determines the smaller position of the bounding box extend
  40727. * @param maximumWorld Determines the bigger position of the bounding box extend
  40728. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40729. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40730. */
  40731. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40732. /**
  40733. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40734. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40735. * frustum width.
  40736. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40737. * to fully enclose the mesh in the viewing frustum.
  40738. */
  40739. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40740. /**
  40741. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40742. * is automatically returned to its default position (expected to be above ground plane).
  40743. */
  40744. private _maintainCameraAboveGround;
  40745. /**
  40746. * Returns the frustum slope based on the canvas ratio and camera FOV
  40747. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40748. */
  40749. private _getFrustumSlope;
  40750. /**
  40751. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40752. */
  40753. private _clearAnimationLocks;
  40754. /**
  40755. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40756. */
  40757. private _applyUserInteraction;
  40758. /**
  40759. * Stops and removes all animations that have been applied to the camera
  40760. */
  40761. stopAllAnimations(): void;
  40762. /**
  40763. * Gets a value indicating if the user is moving the camera
  40764. */
  40765. readonly isUserIsMoving: boolean;
  40766. /**
  40767. * The camera can move all the way towards the mesh.
  40768. */
  40769. static IgnoreBoundsSizeMode: number;
  40770. /**
  40771. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40772. */
  40773. static FitFrustumSidesMode: number;
  40774. }
  40775. }
  40776. declare module BABYLON {
  40777. /**
  40778. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40779. */
  40780. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  40781. private ui;
  40782. /**
  40783. * The name of the behavior
  40784. */
  40785. name: string;
  40786. /**
  40787. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40788. */
  40789. distanceAwayFromFace: number;
  40790. /**
  40791. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40792. */
  40793. distanceAwayFromBottomOfFace: number;
  40794. private _faceVectors;
  40795. private _target;
  40796. private _scene;
  40797. private _onRenderObserver;
  40798. private _tmpMatrix;
  40799. private _tmpVector;
  40800. /**
  40801. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40802. * @param ui The transform node that should be attched to the mesh
  40803. */
  40804. constructor(ui: BABYLON.TransformNode);
  40805. /**
  40806. * Initializes the behavior
  40807. */
  40808. init(): void;
  40809. private _closestFace;
  40810. private _zeroVector;
  40811. private _lookAtTmpMatrix;
  40812. private _lookAtToRef;
  40813. /**
  40814. * Attaches the AttachToBoxBehavior to the passed in mesh
  40815. * @param target The mesh that the specified node will be attached to
  40816. */
  40817. attach(target: BABYLON.Mesh): void;
  40818. /**
  40819. * Detaches the behavior from the mesh
  40820. */
  40821. detach(): void;
  40822. }
  40823. }
  40824. declare module BABYLON {
  40825. /**
  40826. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40827. */
  40828. class FadeInOutBehavior implements Behavior<Mesh> {
  40829. /**
  40830. * Time in milliseconds to delay before fading in (Default: 0)
  40831. */
  40832. delay: number;
  40833. /**
  40834. * Time in milliseconds for the mesh to fade in (Default: 300)
  40835. */
  40836. fadeInTime: number;
  40837. private _millisecondsPerFrame;
  40838. private _hovered;
  40839. private _hoverValue;
  40840. private _ownerNode;
  40841. /**
  40842. * Instatiates the FadeInOutBehavior
  40843. */
  40844. constructor();
  40845. /**
  40846. * The name of the behavior
  40847. */
  40848. readonly name: string;
  40849. /**
  40850. * Initializes the behavior
  40851. */
  40852. init(): void;
  40853. /**
  40854. * Attaches the fade behavior on the passed in mesh
  40855. * @param ownerNode The mesh that will be faded in/out once attached
  40856. */
  40857. attach(ownerNode: Mesh): void;
  40858. /**
  40859. * Detaches the behavior from the mesh
  40860. */
  40861. detach(): void;
  40862. /**
  40863. * Triggers the mesh to begin fading in or out
  40864. * @param value if the object should fade in or out (true to fade in)
  40865. */
  40866. fadeIn(value: boolean): void;
  40867. private _update;
  40868. private _setAllVisibility;
  40869. }
  40870. }
  40871. declare module BABYLON {
  40872. /**
  40873. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40874. */
  40875. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40876. private _dragBehaviorA;
  40877. private _dragBehaviorB;
  40878. private _startDistance;
  40879. private _initialScale;
  40880. private _targetScale;
  40881. private _ownerNode;
  40882. private _sceneRenderObserver;
  40883. /**
  40884. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40885. */
  40886. constructor();
  40887. /**
  40888. * The name of the behavior
  40889. */
  40890. readonly name: string;
  40891. /**
  40892. * Initializes the behavior
  40893. */
  40894. init(): void;
  40895. private _getCurrentDistance;
  40896. /**
  40897. * Attaches the scale behavior the passed in mesh
  40898. * @param ownerNode The mesh that will be scaled around once attached
  40899. */
  40900. attach(ownerNode: Mesh): void;
  40901. /**
  40902. * Detaches the behavior from the mesh
  40903. */
  40904. detach(): void;
  40905. }
  40906. }
  40907. declare module BABYLON {
  40908. /**
  40909. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40910. */
  40911. class PointerDragBehavior implements Behavior<AbstractMesh> {
  40912. private static _AnyMouseID;
  40913. private _attachedNode;
  40914. private _dragPlane;
  40915. private _scene;
  40916. private _pointerObserver;
  40917. private _beforeRenderObserver;
  40918. private static _planeScene;
  40919. /**
  40920. * 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)
  40921. */
  40922. maxDragAngle: number;
  40923. /**
  40924. * @hidden
  40925. */
  40926. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40927. /**
  40928. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40929. */
  40930. currentDraggingPointerID: number;
  40931. /**
  40932. * The last position where the pointer hit the drag plane in world space
  40933. */
  40934. lastDragPosition: Vector3;
  40935. /**
  40936. * If the behavior is currently in a dragging state
  40937. */
  40938. dragging: boolean;
  40939. /**
  40940. * 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)
  40941. */
  40942. dragDeltaRatio: number;
  40943. /**
  40944. * If the drag plane orientation should be updated during the dragging (Default: true)
  40945. */
  40946. updateDragPlane: boolean;
  40947. private _debugMode;
  40948. private _moving;
  40949. /**
  40950. * Fires each time the attached mesh is dragged with the pointer
  40951. * * delta between last drag position and current drag position in world space
  40952. * * dragDistance along the drag axis
  40953. * * dragPlaneNormal normal of the current drag plane used during the drag
  40954. * * dragPlanePoint in world space where the drag intersects the drag plane
  40955. */
  40956. onDragObservable: Observable<{
  40957. delta: Vector3;
  40958. dragPlanePoint: Vector3;
  40959. dragPlaneNormal: Vector3;
  40960. dragDistance: number;
  40961. pointerId: number;
  40962. }>;
  40963. /**
  40964. * Fires each time a drag begins (eg. mouse down on mesh)
  40965. */
  40966. onDragStartObservable: Observable<{
  40967. dragPlanePoint: Vector3;
  40968. pointerId: number;
  40969. }>;
  40970. /**
  40971. * Fires each time a drag ends (eg. mouse release after drag)
  40972. */
  40973. onDragEndObservable: Observable<{
  40974. dragPlanePoint: Vector3;
  40975. pointerId: number;
  40976. }>;
  40977. /**
  40978. * If the attached mesh should be moved when dragged
  40979. */
  40980. moveAttached: boolean;
  40981. /**
  40982. * If the drag behavior will react to drag events (Default: true)
  40983. */
  40984. enabled: boolean;
  40985. /**
  40986. * If camera controls should be detached during the drag
  40987. */
  40988. detachCameraControls: boolean;
  40989. /**
  40990. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40991. */
  40992. useObjectOrienationForDragging: boolean;
  40993. private _options;
  40994. /**
  40995. * Creates a pointer drag behavior that can be attached to a mesh
  40996. * @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)
  40997. */
  40998. constructor(options?: {
  40999. dragAxis?: Vector3;
  41000. dragPlaneNormal?: Vector3;
  41001. });
  41002. /**
  41003. * The name of the behavior
  41004. */
  41005. readonly name: string;
  41006. /**
  41007. * Initializes the behavior
  41008. */
  41009. init(): void;
  41010. private _tmpVector;
  41011. private _alternatePickedPoint;
  41012. private _worldDragAxis;
  41013. private _targetPosition;
  41014. private _attachedElement;
  41015. /**
  41016. * Attaches the drag behavior the passed in mesh
  41017. * @param ownerNode The mesh that will be dragged around once attached
  41018. */
  41019. attach(ownerNode: AbstractMesh): void;
  41020. /**
  41021. * Force relase the drag action by code.
  41022. */
  41023. releaseDrag(): void;
  41024. private _startDragRay;
  41025. private _lastPointerRay;
  41026. /**
  41027. * Simulates the start of a pointer drag event on the behavior
  41028. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41029. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41030. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41031. */
  41032. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41033. private _startDrag;
  41034. private _dragDelta;
  41035. private _moveDrag;
  41036. private _pickWithRayOnDragPlane;
  41037. private _pointA;
  41038. private _pointB;
  41039. private _pointC;
  41040. private _lineA;
  41041. private _lineB;
  41042. private _localAxis;
  41043. private _lookAt;
  41044. private _updateDragPlanePosition;
  41045. /**
  41046. * Detaches the behavior from the mesh
  41047. */
  41048. detach(): void;
  41049. }
  41050. }
  41051. declare module BABYLON {
  41052. /**
  41053. * 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
  41054. */
  41055. class SixDofDragBehavior implements Behavior<Mesh> {
  41056. private static _virtualScene;
  41057. private _ownerNode;
  41058. private _sceneRenderObserver;
  41059. private _scene;
  41060. private _targetPosition;
  41061. private _virtualOriginMesh;
  41062. private _virtualDragMesh;
  41063. private _pointerObserver;
  41064. private _moving;
  41065. private _startingOrientation;
  41066. /**
  41067. * 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)
  41068. */
  41069. private zDragFactor;
  41070. /**
  41071. * If the behavior is currently in a dragging state
  41072. */
  41073. dragging: boolean;
  41074. /**
  41075. * 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)
  41076. */
  41077. dragDeltaRatio: number;
  41078. /**
  41079. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41080. */
  41081. currentDraggingPointerID: number;
  41082. /**
  41083. * If camera controls should be detached during the drag
  41084. */
  41085. detachCameraControls: boolean;
  41086. /**
  41087. * Fires each time a drag starts
  41088. */
  41089. onDragStartObservable: Observable<{}>;
  41090. /**
  41091. * Fires each time a drag ends (eg. mouse release after drag)
  41092. */
  41093. onDragEndObservable: Observable<{}>;
  41094. /**
  41095. * 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
  41096. */
  41097. constructor();
  41098. /**
  41099. * The name of the behavior
  41100. */
  41101. readonly name: string;
  41102. /**
  41103. * Initializes the behavior
  41104. */
  41105. init(): void;
  41106. /**
  41107. * Attaches the scale behavior the passed in mesh
  41108. * @param ownerNode The mesh that will be scaled around once attached
  41109. */
  41110. attach(ownerNode: Mesh): void;
  41111. /**
  41112. * Detaches the behavior from the mesh
  41113. */
  41114. detach(): void;
  41115. }
  41116. }
  41117. declare module BABYLON {
  41118. /**
  41119. * Manage the gamepad inputs to control an arc rotate camera.
  41120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41121. */
  41122. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41123. /**
  41124. * Defines the camera the input is attached to.
  41125. */
  41126. camera: ArcRotateCamera;
  41127. /**
  41128. * Defines the gamepad the input is gathering event from.
  41129. */
  41130. gamepad: Nullable<Gamepad>;
  41131. /**
  41132. * Defines the gamepad rotation sensiblity.
  41133. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41134. */
  41135. gamepadRotationSensibility: number;
  41136. /**
  41137. * Defines the gamepad move sensiblity.
  41138. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41139. */
  41140. gamepadMoveSensibility: number;
  41141. private _onGamepadConnectedObserver;
  41142. private _onGamepadDisconnectedObserver;
  41143. /**
  41144. * Attach the input controls to a specific dom element to get the input from.
  41145. * @param element Defines the element the controls should be listened from
  41146. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41147. */
  41148. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41149. /**
  41150. * Detach the current controls from the specified dom element.
  41151. * @param element Defines the element to stop listening the inputs from
  41152. */
  41153. detachControl(element: Nullable<HTMLElement>): void;
  41154. /**
  41155. * Update the current camera state depending on the inputs that have been used this frame.
  41156. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41157. */
  41158. checkInputs(): void;
  41159. /**
  41160. * Gets the class name of the current intput.
  41161. * @returns the class name
  41162. */
  41163. getClassName(): string;
  41164. /**
  41165. * Get the friendly name associated with the input class.
  41166. * @returns the input friendly name
  41167. */
  41168. getSimpleName(): string;
  41169. }
  41170. }
  41171. declare module BABYLON {
  41172. /**
  41173. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41174. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41175. */
  41176. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41177. /**
  41178. * Defines the camera the input is attached to.
  41179. */
  41180. camera: ArcRotateCamera;
  41181. /**
  41182. * Defines the list of key codes associated with the up action (increase alpha)
  41183. */
  41184. keysUp: number[];
  41185. /**
  41186. * Defines the list of key codes associated with the down action (decrease alpha)
  41187. */
  41188. keysDown: number[];
  41189. /**
  41190. * Defines the list of key codes associated with the left action (increase beta)
  41191. */
  41192. keysLeft: number[];
  41193. /**
  41194. * Defines the list of key codes associated with the right action (decrease beta)
  41195. */
  41196. keysRight: number[];
  41197. /**
  41198. * Defines the list of key codes associated with the reset action.
  41199. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41200. */
  41201. keysReset: number[];
  41202. /**
  41203. * Defines the panning sensibility of the inputs.
  41204. * (How fast is the camera paning)
  41205. */
  41206. panningSensibility: number;
  41207. /**
  41208. * Defines the zooming sensibility of the inputs.
  41209. * (How fast is the camera zooming)
  41210. */
  41211. zoomingSensibility: number;
  41212. /**
  41213. * Defines wether maintaining the alt key down switch the movement mode from
  41214. * orientation to zoom.
  41215. */
  41216. useAltToZoom: boolean;
  41217. /**
  41218. * Rotation speed of the camera
  41219. */
  41220. angularSpeed: number;
  41221. private _keys;
  41222. private _ctrlPressed;
  41223. private _altPressed;
  41224. private _onCanvasBlurObserver;
  41225. private _onKeyboardObserver;
  41226. private _engine;
  41227. private _scene;
  41228. /**
  41229. * Attach the input controls to a specific dom element to get the input from.
  41230. * @param element Defines the element the controls should be listened from
  41231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41232. */
  41233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41234. /**
  41235. * Detach the current controls from the specified dom element.
  41236. * @param element Defines the element to stop listening the inputs from
  41237. */
  41238. detachControl(element: Nullable<HTMLElement>): void;
  41239. /**
  41240. * Update the current camera state depending on the inputs that have been used this frame.
  41241. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41242. */
  41243. checkInputs(): void;
  41244. /**
  41245. * Gets the class name of the current intput.
  41246. * @returns the class name
  41247. */
  41248. getClassName(): string;
  41249. /**
  41250. * Get the friendly name associated with the input class.
  41251. * @returns the input friendly name
  41252. */
  41253. getSimpleName(): string;
  41254. }
  41255. }
  41256. declare module BABYLON {
  41257. /**
  41258. * Manage the mouse wheel inputs to control an arc rotate camera.
  41259. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41260. */
  41261. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41262. /**
  41263. * Defines the camera the input is attached to.
  41264. */
  41265. camera: ArcRotateCamera;
  41266. /**
  41267. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41268. */
  41269. wheelPrecision: number;
  41270. /**
  41271. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41272. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41273. */
  41274. wheelDeltaPercentage: number;
  41275. private _wheel;
  41276. private _observer;
  41277. /**
  41278. * Attach the input controls to a specific dom element to get the input from.
  41279. * @param element Defines the element the controls should be listened from
  41280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41281. */
  41282. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41283. /**
  41284. * Detach the current controls from the specified dom element.
  41285. * @param element Defines the element to stop listening the inputs from
  41286. */
  41287. detachControl(element: Nullable<HTMLElement>): void;
  41288. /**
  41289. * Gets the class name of the current intput.
  41290. * @returns the class name
  41291. */
  41292. getClassName(): string;
  41293. /**
  41294. * Get the friendly name associated with the input class.
  41295. * @returns the input friendly name
  41296. */
  41297. getSimpleName(): string;
  41298. }
  41299. }
  41300. declare module BABYLON {
  41301. /**
  41302. * Manage the pointers inputs to control an arc rotate camera.
  41303. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41304. */
  41305. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  41306. /**
  41307. * Defines the camera the input is attached to.
  41308. */
  41309. camera: ArcRotateCamera;
  41310. /**
  41311. * Defines the buttons associated with the input to handle camera move.
  41312. */
  41313. buttons: number[];
  41314. /**
  41315. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41316. */
  41317. angularSensibilityX: number;
  41318. /**
  41319. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41320. */
  41321. angularSensibilityY: number;
  41322. /**
  41323. * Defines the pointer pinch precision or how fast is the camera zooming.
  41324. */
  41325. pinchPrecision: number;
  41326. /**
  41327. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  41328. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41329. */
  41330. pinchDeltaPercentage: number;
  41331. /**
  41332. * Defines the pointer panning sensibility or how fast is the camera moving.
  41333. */
  41334. panningSensibility: number;
  41335. /**
  41336. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41337. */
  41338. multiTouchPanning: boolean;
  41339. /**
  41340. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  41341. */
  41342. multiTouchPanAndZoom: boolean;
  41343. /**
  41344. * Revers pinch action direction.
  41345. */
  41346. pinchInwards: boolean;
  41347. private _isPanClick;
  41348. private _pointerInput;
  41349. private _observer;
  41350. private _onMouseMove;
  41351. private _onGestureStart;
  41352. private _onGesture;
  41353. private _MSGestureHandler;
  41354. private _onLostFocus;
  41355. private _onContextMenu;
  41356. /**
  41357. * Attach the input controls to a specific dom element to get the input from.
  41358. * @param element Defines the element the controls should be listened from
  41359. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41360. */
  41361. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41362. /**
  41363. * Detach the current controls from the specified dom element.
  41364. * @param element Defines the element to stop listening the inputs from
  41365. */
  41366. detachControl(element: Nullable<HTMLElement>): void;
  41367. /**
  41368. * Gets the class name of the current intput.
  41369. * @returns the class name
  41370. */
  41371. getClassName(): string;
  41372. /**
  41373. * Get the friendly name associated with the input class.
  41374. * @returns the input friendly name
  41375. */
  41376. getSimpleName(): string;
  41377. }
  41378. }
  41379. declare module BABYLON {
  41380. /**
  41381. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41382. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41383. */
  41384. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41385. /**
  41386. * Defines the camera the input is attached to.
  41387. */
  41388. camera: ArcRotateCamera;
  41389. /**
  41390. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41391. */
  41392. alphaCorrection: number;
  41393. /**
  41394. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41395. */
  41396. gammaCorrection: number;
  41397. private _alpha;
  41398. private _gamma;
  41399. private _dirty;
  41400. private _deviceOrientationHandler;
  41401. /**
  41402. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41403. */
  41404. constructor();
  41405. /**
  41406. * Attach the input controls to a specific dom element to get the input from.
  41407. * @param element Defines the element the controls should be listened from
  41408. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41409. */
  41410. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41411. /** @hidden */
  41412. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41413. /**
  41414. * Update the current camera state depending on the inputs that have been used this frame.
  41415. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41416. */
  41417. checkInputs(): void;
  41418. /**
  41419. * Detach the current controls from the specified dom element.
  41420. * @param element Defines the element to stop listening the inputs from
  41421. */
  41422. detachControl(element: Nullable<HTMLElement>): void;
  41423. /**
  41424. * Gets the class name of the current intput.
  41425. * @returns the class name
  41426. */
  41427. getClassName(): string;
  41428. /**
  41429. * Get the friendly name associated with the input class.
  41430. * @returns the input friendly name
  41431. */
  41432. getSimpleName(): string;
  41433. }
  41434. }
  41435. declare module BABYLON {
  41436. /**
  41437. * Listen to keyboard events to control the camera.
  41438. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41439. */
  41440. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41441. /**
  41442. * Defines the camera the input is attached to.
  41443. */
  41444. camera: FlyCamera;
  41445. /**
  41446. * The list of keyboard keys used to control the forward move of the camera.
  41447. */
  41448. keysForward: number[];
  41449. /**
  41450. * The list of keyboard keys used to control the backward move of the camera.
  41451. */
  41452. keysBackward: number[];
  41453. /**
  41454. * The list of keyboard keys used to control the forward move of the camera.
  41455. */
  41456. keysUp: number[];
  41457. /**
  41458. * The list of keyboard keys used to control the backward move of the camera.
  41459. */
  41460. keysDown: number[];
  41461. /**
  41462. * The list of keyboard keys used to control the right strafe move of the camera.
  41463. */
  41464. keysRight: number[];
  41465. /**
  41466. * The list of keyboard keys used to control the left strafe move of the camera.
  41467. */
  41468. keysLeft: number[];
  41469. private _keys;
  41470. private _onCanvasBlurObserver;
  41471. private _onKeyboardObserver;
  41472. private _engine;
  41473. private _scene;
  41474. /**
  41475. * Attach the input controls to a specific dom element to get the input from.
  41476. * @param element Defines the element the controls should be listened from
  41477. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41478. */
  41479. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41480. /**
  41481. * Detach the current controls from the specified dom element.
  41482. * @param element Defines the element to stop listening the inputs from
  41483. */
  41484. detachControl(element: Nullable<HTMLElement>): void;
  41485. /**
  41486. * Gets the class name of the current intput.
  41487. * @returns the class name
  41488. */
  41489. getClassName(): string;
  41490. /** @hidden */
  41491. _onLostFocus(e: FocusEvent): void;
  41492. /**
  41493. * Get the friendly name associated with the input class.
  41494. * @returns the input friendly name
  41495. */
  41496. getSimpleName(): string;
  41497. /**
  41498. * Update the current camera state depending on the inputs that have been used this frame.
  41499. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41500. */
  41501. checkInputs(): void;
  41502. }
  41503. }
  41504. declare module BABYLON {
  41505. /**
  41506. * Listen to mouse events to control the camera.
  41507. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41508. */
  41509. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41510. /**
  41511. * Defines the camera the input is attached to.
  41512. */
  41513. camera: FlyCamera;
  41514. /**
  41515. * Defines if touch is enabled. (Default is true.)
  41516. */
  41517. touchEnabled: boolean;
  41518. /**
  41519. * Defines the buttons associated with the input to handle camera rotation.
  41520. */
  41521. buttons: number[];
  41522. /**
  41523. * Assign buttons for Yaw control.
  41524. */
  41525. buttonsYaw: number[];
  41526. /**
  41527. * Assign buttons for Pitch control.
  41528. */
  41529. buttonsPitch: number[];
  41530. /**
  41531. * Assign buttons for Roll control.
  41532. */
  41533. buttonsRoll: number[];
  41534. /**
  41535. * Detect if any button is being pressed while mouse is moved.
  41536. * -1 = Mouse locked.
  41537. * 0 = Left button.
  41538. * 1 = Middle Button.
  41539. * 2 = Right Button.
  41540. */
  41541. activeButton: number;
  41542. /**
  41543. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41544. * Higher values reduce its sensitivity.
  41545. */
  41546. angularSensibility: number;
  41547. private _mousemoveCallback;
  41548. private _observer;
  41549. private _rollObserver;
  41550. private previousPosition;
  41551. private noPreventDefault;
  41552. private element;
  41553. /**
  41554. * Listen to mouse events to control the camera.
  41555. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41556. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41557. */
  41558. constructor(touchEnabled?: boolean);
  41559. /**
  41560. * Attach the mouse control to the HTML DOM element.
  41561. * @param element Defines the element that listens to the input events.
  41562. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41563. */
  41564. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41565. /**
  41566. * Detach the current controls from the specified dom element.
  41567. * @param element Defines the element to stop listening the inputs from
  41568. */
  41569. detachControl(element: Nullable<HTMLElement>): void;
  41570. /**
  41571. * Gets the class name of the current input.
  41572. * @returns the class name.
  41573. */
  41574. getClassName(): string;
  41575. /**
  41576. * Get the friendly name associated with the input class.
  41577. * @returns the input's friendly name.
  41578. */
  41579. getSimpleName(): string;
  41580. private _pointerInput;
  41581. private _onMouseMove;
  41582. /**
  41583. * Rotate camera by mouse offset.
  41584. */
  41585. private rotateCamera;
  41586. }
  41587. }
  41588. declare module BABYLON {
  41589. /**
  41590. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41591. * Screen rotation is taken into account.
  41592. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41593. */
  41594. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41595. private _camera;
  41596. private _screenOrientationAngle;
  41597. private _constantTranform;
  41598. private _screenQuaternion;
  41599. private _alpha;
  41600. private _beta;
  41601. private _gamma;
  41602. /**
  41603. * Instantiates a new input
  41604. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41605. */
  41606. constructor();
  41607. /**
  41608. * Define the camera controlled by the input.
  41609. */
  41610. camera: FreeCamera;
  41611. /**
  41612. * Attach the input controls to a specific dom element to get the input from.
  41613. * @param element Defines the element the controls should be listened from
  41614. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41615. */
  41616. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41617. private _orientationChanged;
  41618. private _deviceOrientation;
  41619. /**
  41620. * Detach the current controls from the specified dom element.
  41621. * @param element Defines the element to stop listening the inputs from
  41622. */
  41623. detachControl(element: Nullable<HTMLElement>): void;
  41624. /**
  41625. * Update the current camera state depending on the inputs that have been used this frame.
  41626. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41627. */
  41628. checkInputs(): void;
  41629. /**
  41630. * Gets the class name of the current intput.
  41631. * @returns the class name
  41632. */
  41633. getClassName(): string;
  41634. /**
  41635. * Get the friendly name associated with the input class.
  41636. * @returns the input friendly name
  41637. */
  41638. getSimpleName(): string;
  41639. }
  41640. }
  41641. declare module BABYLON {
  41642. /**
  41643. * Manage the gamepad inputs to control a free camera.
  41644. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41645. */
  41646. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41647. /**
  41648. * Define the camera the input is attached to.
  41649. */
  41650. camera: FreeCamera;
  41651. /**
  41652. * Define the Gamepad controlling the input
  41653. */
  41654. gamepad: Nullable<Gamepad>;
  41655. /**
  41656. * Defines the gamepad rotation sensiblity.
  41657. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41658. */
  41659. gamepadAngularSensibility: number;
  41660. /**
  41661. * Defines the gamepad move sensiblity.
  41662. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41663. */
  41664. gamepadMoveSensibility: number;
  41665. private _onGamepadConnectedObserver;
  41666. private _onGamepadDisconnectedObserver;
  41667. private _cameraTransform;
  41668. private _deltaTransform;
  41669. private _vector3;
  41670. private _vector2;
  41671. /**
  41672. * Attach the input controls to a specific dom element to get the input from.
  41673. * @param element Defines the element the controls should be listened from
  41674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41675. */
  41676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41677. /**
  41678. * Detach the current controls from the specified dom element.
  41679. * @param element Defines the element to stop listening the inputs from
  41680. */
  41681. detachControl(element: Nullable<HTMLElement>): void;
  41682. /**
  41683. * Update the current camera state depending on the inputs that have been used this frame.
  41684. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41685. */
  41686. checkInputs(): void;
  41687. /**
  41688. * Gets the class name of the current intput.
  41689. * @returns the class name
  41690. */
  41691. getClassName(): string;
  41692. /**
  41693. * Get the friendly name associated with the input class.
  41694. * @returns the input friendly name
  41695. */
  41696. getSimpleName(): string;
  41697. }
  41698. }
  41699. declare module BABYLON {
  41700. /**
  41701. * Manage the keyboard inputs to control the movement of a free camera.
  41702. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41703. */
  41704. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  41705. /**
  41706. * Defines the camera the input is attached to.
  41707. */
  41708. camera: FreeCamera;
  41709. /**
  41710. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  41711. */
  41712. keysUp: number[];
  41713. /**
  41714. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  41715. */
  41716. keysDown: number[];
  41717. /**
  41718. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  41719. */
  41720. keysLeft: number[];
  41721. /**
  41722. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  41723. */
  41724. keysRight: number[];
  41725. private _keys;
  41726. private _onCanvasBlurObserver;
  41727. private _onKeyboardObserver;
  41728. private _engine;
  41729. private _scene;
  41730. /**
  41731. * Attach the input controls to a specific dom element to get the input from.
  41732. * @param element Defines the element the controls should be listened from
  41733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41734. */
  41735. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41736. /**
  41737. * Detach the current controls from the specified dom element.
  41738. * @param element Defines the element to stop listening the inputs from
  41739. */
  41740. detachControl(element: Nullable<HTMLElement>): void;
  41741. /**
  41742. * Update the current camera state depending on the inputs that have been used this frame.
  41743. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41744. */
  41745. checkInputs(): void;
  41746. /**
  41747. * Gets the class name of the current intput.
  41748. * @returns the class name
  41749. */
  41750. getClassName(): string;
  41751. /** @hidden */
  41752. _onLostFocus(e: FocusEvent): void;
  41753. /**
  41754. * Get the friendly name associated with the input class.
  41755. * @returns the input friendly name
  41756. */
  41757. getSimpleName(): string;
  41758. }
  41759. }
  41760. declare module BABYLON {
  41761. /**
  41762. * Manage the mouse inputs to control the movement of a free camera.
  41763. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41764. */
  41765. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  41766. /**
  41767. * Define if touch is enabled in the mouse input
  41768. */
  41769. touchEnabled: boolean;
  41770. /**
  41771. * Defines the camera the input is attached to.
  41772. */
  41773. camera: FreeCamera;
  41774. /**
  41775. * Defines the buttons associated with the input to handle camera move.
  41776. */
  41777. buttons: number[];
  41778. /**
  41779. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  41780. */
  41781. angularSensibility: number;
  41782. private _pointerInput;
  41783. private _onMouseMove;
  41784. private _observer;
  41785. private previousPosition;
  41786. /**
  41787. * Manage the mouse inputs to control the movement of a free camera.
  41788. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41789. * @param touchEnabled Defines if touch is enabled or not
  41790. */
  41791. constructor(
  41792. /**
  41793. * Define if touch is enabled in the mouse input
  41794. */
  41795. touchEnabled?: boolean);
  41796. /**
  41797. * Attach the input controls to a specific dom element to get the input from.
  41798. * @param element Defines the element the controls should be listened from
  41799. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41800. */
  41801. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41802. /**
  41803. * Detach the current controls from the specified dom element.
  41804. * @param element Defines the element to stop listening the inputs from
  41805. */
  41806. detachControl(element: Nullable<HTMLElement>): void;
  41807. /**
  41808. * Gets the class name of the current intput.
  41809. * @returns the class name
  41810. */
  41811. getClassName(): string;
  41812. /**
  41813. * Get the friendly name associated with the input class.
  41814. * @returns the input friendly name
  41815. */
  41816. getSimpleName(): string;
  41817. }
  41818. }
  41819. declare module BABYLON {
  41820. /**
  41821. * Manage the touch inputs to control the movement of a free camera.
  41822. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41823. */
  41824. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  41825. /**
  41826. * Defines the camera the input is attached to.
  41827. */
  41828. camera: FreeCamera;
  41829. /**
  41830. * Defines the touch sensibility for rotation.
  41831. * The higher the faster.
  41832. */
  41833. touchAngularSensibility: number;
  41834. /**
  41835. * Defines the touch sensibility for move.
  41836. * The higher the faster.
  41837. */
  41838. touchMoveSensibility: number;
  41839. private _offsetX;
  41840. private _offsetY;
  41841. private _pointerPressed;
  41842. private _pointerInput;
  41843. private _observer;
  41844. private _onLostFocus;
  41845. /**
  41846. * Attach the input controls to a specific dom element to get the input from.
  41847. * @param element Defines the element the controls should be listened from
  41848. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41849. */
  41850. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41851. /**
  41852. * Detach the current controls from the specified dom element.
  41853. * @param element Defines the element to stop listening the inputs from
  41854. */
  41855. detachControl(element: Nullable<HTMLElement>): void;
  41856. /**
  41857. * Update the current camera state depending on the inputs that have been used this frame.
  41858. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41859. */
  41860. checkInputs(): void;
  41861. /**
  41862. * Gets the class name of the current intput.
  41863. * @returns the class name
  41864. */
  41865. getClassName(): string;
  41866. /**
  41867. * Get the friendly name associated with the input class.
  41868. * @returns the input friendly name
  41869. */
  41870. getSimpleName(): string;
  41871. }
  41872. }
  41873. declare module BABYLON {
  41874. /**
  41875. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41877. */
  41878. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41879. /**
  41880. * Defines the camera the input is attached to.
  41881. */
  41882. camera: FreeCamera;
  41883. private _leftjoystick;
  41884. private _rightjoystick;
  41885. /**
  41886. * Gets the left stick of the virtual joystick.
  41887. * @returns The virtual Joystick
  41888. */
  41889. getLeftJoystick(): VirtualJoystick;
  41890. /**
  41891. * Gets the right stick of the virtual joystick.
  41892. * @returns The virtual Joystick
  41893. */
  41894. getRightJoystick(): VirtualJoystick;
  41895. /**
  41896. * Update the current camera state depending on the inputs that have been used this frame.
  41897. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41898. */
  41899. checkInputs(): void;
  41900. /**
  41901. * Attach the input controls to a specific dom element to get the input from.
  41902. * @param element Defines the element the controls should be listened from
  41903. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41904. */
  41905. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41906. /**
  41907. * Detach the current controls from the specified dom element.
  41908. * @param element Defines the element to stop listening the inputs from
  41909. */
  41910. detachControl(element: Nullable<HTMLElement>): void;
  41911. /**
  41912. * Gets the class name of the current intput.
  41913. * @returns the class name
  41914. */
  41915. getClassName(): string;
  41916. /**
  41917. * Get the friendly name associated with the input class.
  41918. * @returns the input friendly name
  41919. */
  41920. getSimpleName(): string;
  41921. }
  41922. }
  41923. declare module BABYLON {
  41924. /**
  41925. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41926. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41927. */
  41928. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41929. /**
  41930. * Creates a new AnaglyphArcRotateCamera
  41931. * @param name defines camera name
  41932. * @param alpha defines alpha angle (in radians)
  41933. * @param beta defines beta angle (in radians)
  41934. * @param radius defines radius
  41935. * @param target defines camera target
  41936. * @param interaxialDistance defines distance between each color axis
  41937. * @param scene defines the hosting scene
  41938. */
  41939. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41940. /**
  41941. * Gets camera class name
  41942. * @returns AnaglyphArcRotateCamera
  41943. */
  41944. getClassName(): string;
  41945. }
  41946. }
  41947. declare module BABYLON {
  41948. /**
  41949. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41950. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41951. */
  41952. class AnaglyphFreeCamera extends FreeCamera {
  41953. /**
  41954. * Creates a new AnaglyphFreeCamera
  41955. * @param name defines camera name
  41956. * @param position defines initial position
  41957. * @param interaxialDistance defines distance between each color axis
  41958. * @param scene defines the hosting scene
  41959. */
  41960. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41961. /**
  41962. * Gets camera class name
  41963. * @returns AnaglyphFreeCamera
  41964. */
  41965. getClassName(): string;
  41966. }
  41967. }
  41968. declare module BABYLON {
  41969. /**
  41970. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41971. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41972. */
  41973. class AnaglyphGamepadCamera extends GamepadCamera {
  41974. /**
  41975. * Creates a new AnaglyphGamepadCamera
  41976. * @param name defines camera name
  41977. * @param position defines initial position
  41978. * @param interaxialDistance defines distance between each color axis
  41979. * @param scene defines the hosting scene
  41980. */
  41981. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41982. /**
  41983. * Gets camera class name
  41984. * @returns AnaglyphGamepadCamera
  41985. */
  41986. getClassName(): string;
  41987. }
  41988. }
  41989. declare module BABYLON {
  41990. /**
  41991. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41992. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41993. */
  41994. class AnaglyphUniversalCamera extends UniversalCamera {
  41995. /**
  41996. * Creates a new AnaglyphUniversalCamera
  41997. * @param name defines camera name
  41998. * @param position defines initial position
  41999. * @param interaxialDistance defines distance between each color axis
  42000. * @param scene defines the hosting scene
  42001. */
  42002. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42003. /**
  42004. * Gets camera class name
  42005. * @returns AnaglyphUniversalCamera
  42006. */
  42007. getClassName(): string;
  42008. }
  42009. }
  42010. declare module BABYLON {
  42011. /**
  42012. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42013. * @see http://doc.babylonjs.com/features/cameras
  42014. */
  42015. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42016. /**
  42017. * Creates a new StereoscopicArcRotateCamera
  42018. * @param name defines camera name
  42019. * @param alpha defines alpha angle (in radians)
  42020. * @param beta defines beta angle (in radians)
  42021. * @param radius defines radius
  42022. * @param target defines camera target
  42023. * @param interaxialDistance defines distance between each color axis
  42024. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42025. * @param scene defines the hosting scene
  42026. */
  42027. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42028. /**
  42029. * Gets camera class name
  42030. * @returns StereoscopicArcRotateCamera
  42031. */
  42032. getClassName(): string;
  42033. }
  42034. }
  42035. declare module BABYLON {
  42036. /**
  42037. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42038. * @see http://doc.babylonjs.com/features/cameras
  42039. */
  42040. class StereoscopicFreeCamera extends FreeCamera {
  42041. /**
  42042. * Creates a new StereoscopicFreeCamera
  42043. * @param name defines camera name
  42044. * @param position defines initial position
  42045. * @param interaxialDistance defines distance between each color axis
  42046. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42047. * @param scene defines the hosting scene
  42048. */
  42049. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42050. /**
  42051. * Gets camera class name
  42052. * @returns StereoscopicFreeCamera
  42053. */
  42054. getClassName(): string;
  42055. }
  42056. }
  42057. declare module BABYLON {
  42058. /**
  42059. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42060. * @see http://doc.babylonjs.com/features/cameras
  42061. */
  42062. class StereoscopicGamepadCamera extends GamepadCamera {
  42063. /**
  42064. * Creates a new StereoscopicGamepadCamera
  42065. * @param name defines camera name
  42066. * @param position defines initial position
  42067. * @param interaxialDistance defines distance between each color axis
  42068. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42069. * @param scene defines the hosting scene
  42070. */
  42071. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42072. /**
  42073. * Gets camera class name
  42074. * @returns StereoscopicGamepadCamera
  42075. */
  42076. getClassName(): string;
  42077. }
  42078. }
  42079. declare module BABYLON {
  42080. /**
  42081. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42082. * @see http://doc.babylonjs.com/features/cameras
  42083. */
  42084. class StereoscopicUniversalCamera extends UniversalCamera {
  42085. /**
  42086. * Creates a new StereoscopicUniversalCamera
  42087. * @param name defines camera name
  42088. * @param position defines initial position
  42089. * @param interaxialDistance defines distance between each color axis
  42090. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42091. * @param scene defines the hosting scene
  42092. */
  42093. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42094. /**
  42095. * Gets camera class name
  42096. * @returns StereoscopicUniversalCamera
  42097. */
  42098. getClassName(): string;
  42099. }
  42100. }
  42101. declare module BABYLON {
  42102. /**
  42103. * WebXR Camera which holds the views for the xrSession
  42104. * @see https://doc.babylonjs.com/how_to/webxr
  42105. */
  42106. class WebXRCamera extends FreeCamera {
  42107. private static _TmpMatrix;
  42108. /**
  42109. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42110. * @param name the name of the camera
  42111. * @param scene the scene to add the camera to
  42112. */
  42113. constructor(name: string, scene: BABYLON.Scene);
  42114. private _updateNumberOfRigCameras;
  42115. /** @hidden */
  42116. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42117. /**
  42118. * Updates the cameras position from the current pose information of the XR session
  42119. * @param xrSessionManager the session containing pose information
  42120. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42121. */
  42122. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42123. }
  42124. }
  42125. declare module BABYLON {
  42126. /**
  42127. * Button which can be used to enter a different mode of XR
  42128. */
  42129. class WebXREnterExitUIButton {
  42130. /** button element */
  42131. element: HTMLElement;
  42132. /** XR initialization options for the button */
  42133. initializationOptions: XRSessionCreationOptions;
  42134. /**
  42135. * Creates a WebXREnterExitUIButton
  42136. * @param element button element
  42137. * @param initializationOptions XR initialization options for the button
  42138. */
  42139. constructor(
  42140. /** button element */
  42141. element: HTMLElement,
  42142. /** XR initialization options for the button */
  42143. initializationOptions: XRSessionCreationOptions);
  42144. /**
  42145. * Overwritable function which can be used to update the button's visuals when the state changes
  42146. * @param activeButton the current active button in the UI
  42147. */
  42148. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42149. }
  42150. /**
  42151. * Options to create the webXR UI
  42152. */
  42153. class WebXREnterExitUIOptions {
  42154. /**
  42155. * Context to enter xr with
  42156. */
  42157. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  42158. /**
  42159. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42160. */
  42161. customButtons?: Array<WebXREnterExitUIButton>;
  42162. }
  42163. /**
  42164. * UI to allow the user to enter/exit XR mode
  42165. */
  42166. class WebXREnterExitUI implements IDisposable {
  42167. private scene;
  42168. private _overlay;
  42169. private _buttons;
  42170. private _activeButton;
  42171. /**
  42172. * Fired every time the active button is changed.
  42173. *
  42174. * When xr is entered via a button that launches xr that button will be the callback parameter
  42175. *
  42176. * When exiting xr the callback parameter will be null)
  42177. */
  42178. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42179. /**
  42180. * Creates UI to allow the user to enter/exit XR mode
  42181. * @param scene the scene to add the ui to
  42182. * @param helper the xr experience helper to enter/exit xr with
  42183. * @param options options to configure the UI
  42184. * @returns the created ui
  42185. */
  42186. static CreateAsync(scene: BABYLON.Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42187. private constructor();
  42188. private _updateButtons;
  42189. /**
  42190. * Disposes of the object
  42191. */
  42192. dispose(): void;
  42193. }
  42194. }
  42195. declare module BABYLON {
  42196. /**
  42197. * States of the webXR experience
  42198. */
  42199. enum WebXRState {
  42200. /**
  42201. * Transitioning to being in XR mode
  42202. */
  42203. ENTERING_XR = 0,
  42204. /**
  42205. * Transitioning to non XR mode
  42206. */
  42207. EXITING_XR = 1,
  42208. /**
  42209. * In XR mode and presenting
  42210. */
  42211. IN_XR = 2,
  42212. /**
  42213. * Not entered XR mode
  42214. */
  42215. NOT_IN_XR = 3
  42216. }
  42217. /**
  42218. * Helper class used to enable XR
  42219. * @see https://doc.babylonjs.com/how_to/webxr
  42220. */
  42221. class WebXRExperienceHelper implements IDisposable {
  42222. private scene;
  42223. /**
  42224. * 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
  42225. */
  42226. container: AbstractMesh;
  42227. /**
  42228. * Camera used to render xr content
  42229. */
  42230. camera: WebXRCamera;
  42231. /**
  42232. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42233. */
  42234. state: WebXRState;
  42235. private _setState;
  42236. private static _TmpVector;
  42237. /**
  42238. * Fires when the state of the experience helper has changed
  42239. */
  42240. onStateChangedObservable: Observable<WebXRState>;
  42241. /** @hidden */
  42242. _sessionManager: WebXRSessionManager;
  42243. private _nonVRCamera;
  42244. private _originalSceneAutoClear;
  42245. private _supported;
  42246. /**
  42247. * Creates the experience helper
  42248. * @param scene the scene to attach the experience helper to
  42249. * @returns a promise for the experience helper
  42250. */
  42251. static CreateAsync(scene: BABYLON.Scene): Promise<WebXRExperienceHelper>;
  42252. /**
  42253. * Creates a WebXRExperienceHelper
  42254. * @param scene The scene the helper should be created in
  42255. */
  42256. private constructor();
  42257. /**
  42258. * Exits XR mode and returns the scene to its original state
  42259. * @returns promise that resolves after xr mode has exited
  42260. */
  42261. exitXRAsync(): Promise<void>;
  42262. /**
  42263. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42264. * @param sessionCreationOptions options for the XR session
  42265. * @param frameOfReference frame of reference of the XR session
  42266. * @returns promise that resolves after xr mode has entered
  42267. */
  42268. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  42269. /**
  42270. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  42271. * @param ray ray to cast into the environment
  42272. * @returns Promise which resolves with a collision point in the environment if it exists
  42273. */
  42274. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  42275. /**
  42276. * Updates the global position of the camera by moving the camera's container
  42277. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42278. * @param position The desired global position of the camera
  42279. */
  42280. setPositionOfCameraUsingContainer(position: Vector3): void;
  42281. /**
  42282. * Rotates the xr camera by rotating the camera's container around the camera's position
  42283. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42284. * @param rotation the desired quaternion rotation to apply to the camera
  42285. */
  42286. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42287. /**
  42288. * Checks if the creation options are supported by the xr session
  42289. * @param options creation options
  42290. * @returns true if supported
  42291. */
  42292. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  42293. /**
  42294. * Disposes of the experience helper
  42295. */
  42296. dispose(): void;
  42297. }
  42298. }
  42299. declare module BABYLON {
  42300. /**
  42301. * Represents an XR input
  42302. */
  42303. class WebXRController {
  42304. /**
  42305. * 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
  42306. */
  42307. grip?: BABYLON.AbstractMesh;
  42308. /**
  42309. * Pointer which can be used to select objects or attach a visible laser to
  42310. */
  42311. pointer: BABYLON.AbstractMesh;
  42312. /**
  42313. * Creates the controller
  42314. * @see https://doc.babylonjs.com/how_to/webxr
  42315. * @param scene the scene which the controller should be associated to
  42316. */
  42317. constructor(scene: BABYLON.Scene);
  42318. /**
  42319. * Disposes of the object
  42320. */
  42321. dispose(): void;
  42322. }
  42323. /**
  42324. * XR input used to track XR inputs such as controllers/rays
  42325. */
  42326. class WebXRInput implements IDisposable {
  42327. private helper;
  42328. /**
  42329. * XR controllers being tracked
  42330. */
  42331. controllers: Array<WebXRController>;
  42332. private _tmpMatrix;
  42333. private _frameObserver;
  42334. /**
  42335. * Initializes the WebXRInput
  42336. * @param helper experience helper which the input should be created for
  42337. */
  42338. constructor(helper: WebXRExperienceHelper);
  42339. /**
  42340. * Disposes of the object
  42341. */
  42342. dispose(): void;
  42343. }
  42344. }
  42345. declare module BABYLON {
  42346. /**
  42347. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42348. */
  42349. class WebXRManagedOutputCanvas implements IDisposable {
  42350. private _canvas;
  42351. /**
  42352. * xrpresent context of the canvas which can be used to display/mirror xr content
  42353. */
  42354. canvasContext: Nullable<WebGLRenderingContext>;
  42355. /**
  42356. * Initializes the canvas to be added/removed upon entering/exiting xr
  42357. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42358. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42359. */
  42360. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42361. /**
  42362. * Disposes of the object
  42363. */
  42364. dispose(): void;
  42365. private _setManagedOutputCanvas;
  42366. private _addCanvas;
  42367. private _removeCanvas;
  42368. }
  42369. }
  42370. declare module BABYLON {
  42371. /**
  42372. * Manages an XRSession
  42373. * @see https://doc.babylonjs.com/how_to/webxr
  42374. */
  42375. class WebXRSessionManager implements IDisposable {
  42376. private scene;
  42377. /**
  42378. * Fires every time a new xrFrame arrives which can be used to update the camera
  42379. */
  42380. onXRFrameObservable: Observable<any>;
  42381. /**
  42382. * Fires when the xr session is ended either by the device or manually done
  42383. */
  42384. onXRSessionEnded: Observable<any>;
  42385. /** @hidden */
  42386. _xrSession: XRSession;
  42387. /** @hidden */
  42388. _frameOfReference: XRFrameOfReference;
  42389. /** @hidden */
  42390. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42391. /** @hidden */
  42392. _currentXRFrame: Nullable<XRFrame>;
  42393. private _xrNavigator;
  42394. private _xrDevice;
  42395. private _tmpMatrix;
  42396. /**
  42397. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42398. * @param scene The scene which the session should be created for
  42399. */
  42400. constructor(scene: BABYLON.Scene);
  42401. /**
  42402. * Initializes the manager
  42403. * After initialization enterXR can be called to start an XR session
  42404. * @returns Promise which resolves after it is initialized
  42405. */
  42406. initializeAsync(): Promise<void>;
  42407. /**
  42408. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  42409. * @param sessionCreationOptions xr options to create the session with
  42410. * @param frameOfReferenceType option to configure how the xr pose is expressed
  42411. * @returns Promise which resolves after it enters XR
  42412. */
  42413. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  42414. /**
  42415. * Stops the xrSession and restores the renderloop
  42416. * @returns Promise which resolves after it exits XR
  42417. */
  42418. exitXRAsync(): Promise<void>;
  42419. /**
  42420. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  42421. * @param ray ray to cast into the environment
  42422. * @returns Promise which resolves with a collision point in the environment if it exists
  42423. */
  42424. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  42425. /**
  42426. * Checks if a session would be supported for the creation options specified
  42427. * @param options creation options to check if they are supported
  42428. * @returns true if supported
  42429. */
  42430. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  42431. /**
  42432. * @hidden
  42433. * Converts the render layer of xrSession to a render target
  42434. * @param session session to create render target for
  42435. * @param scene scene the new render target should be created for
  42436. */
  42437. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: BABYLON.Scene): RenderTargetTexture;
  42438. /**
  42439. * Disposes of the session manager
  42440. */
  42441. dispose(): void;
  42442. }
  42443. }
  42444. declare module BABYLON {
  42445. /**
  42446. * Contains an array of blocks representing the octree
  42447. */
  42448. interface IOctreeContainer<T> {
  42449. /**
  42450. * Blocks within the octree
  42451. */
  42452. blocks: Array<OctreeBlock<T>>;
  42453. }
  42454. /**
  42455. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42456. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42457. */
  42458. class Octree<T> {
  42459. /** 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.) */
  42460. maxDepth: number;
  42461. /**
  42462. * Blocks within the octree containing objects
  42463. */
  42464. blocks: Array<OctreeBlock<T>>;
  42465. /**
  42466. * Content stored in the octree
  42467. */
  42468. dynamicContent: T[];
  42469. private _maxBlockCapacity;
  42470. private _selectionContent;
  42471. private _creationFunc;
  42472. /**
  42473. * Creates a octree
  42474. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42475. * @param creationFunc function to be used to instatiate the octree
  42476. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42477. * @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.)
  42478. */
  42479. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42480. /** 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.) */
  42481. maxDepth?: number);
  42482. /**
  42483. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42484. * @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);
  42485. * @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);
  42486. * @param entries meshes to be added to the octree blocks
  42487. */
  42488. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42489. /**
  42490. * Adds a mesh to the octree
  42491. * @param entry Mesh to add to the octree
  42492. */
  42493. addMesh(entry: T): void;
  42494. /**
  42495. * Selects an array of meshes within the frustum
  42496. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42497. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42498. * @returns array of meshes within the frustum
  42499. */
  42500. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42501. /**
  42502. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42503. * @param sphereCenter defines the bounding sphere center
  42504. * @param sphereRadius defines the bounding sphere radius
  42505. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42506. * @returns an array of objects that intersect the sphere
  42507. */
  42508. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42509. /**
  42510. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42511. * @param ray defines the ray to test with
  42512. * @returns array of intersected objects
  42513. */
  42514. intersectsRay(ray: Ray): SmartArray<T>;
  42515. /**
  42516. * @hidden
  42517. */
  42518. 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;
  42519. /**
  42520. * Adds a mesh into the octree block if it intersects the block
  42521. */
  42522. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42523. /**
  42524. * Adds a submesh into the octree block if it intersects the block
  42525. */
  42526. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42527. }
  42528. }
  42529. declare module BABYLON {
  42530. /**
  42531. * Class used to store a cell in an octree
  42532. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42533. */
  42534. class OctreeBlock<T> {
  42535. /**
  42536. * Gets the content of the current block
  42537. */
  42538. entries: T[];
  42539. /**
  42540. * Gets the list of block children
  42541. */
  42542. blocks: Array<OctreeBlock<T>>;
  42543. private _depth;
  42544. private _maxDepth;
  42545. private _capacity;
  42546. private _minPoint;
  42547. private _maxPoint;
  42548. private _boundingVectors;
  42549. private _creationFunc;
  42550. /**
  42551. * Creates a new block
  42552. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42553. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42554. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42555. * @param depth defines the current depth of this block in the octree
  42556. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42557. * @param creationFunc defines a callback to call when an element is added to the block
  42558. */
  42559. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42560. /**
  42561. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42562. */
  42563. readonly capacity: number;
  42564. /**
  42565. * Gets the minimum vector (in world space) of the block's bounding box
  42566. */
  42567. readonly minPoint: Vector3;
  42568. /**
  42569. * Gets the maximum vector (in world space) of the block's bounding box
  42570. */
  42571. readonly maxPoint: Vector3;
  42572. /**
  42573. * Add a new element to this block
  42574. * @param entry defines the element to add
  42575. */
  42576. addEntry(entry: T): void;
  42577. /**
  42578. * Add an array of elements to this block
  42579. * @param entries defines the array of elements to add
  42580. */
  42581. addEntries(entries: T[]): void;
  42582. /**
  42583. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42584. * @param frustumPlanes defines the frustum planes to test
  42585. * @param selection defines the array to store current content if selection is positive
  42586. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42587. */
  42588. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42589. /**
  42590. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42591. * @param sphereCenter defines the bounding sphere center
  42592. * @param sphereRadius defines the bounding sphere radius
  42593. * @param selection defines the array to store current content if selection is positive
  42594. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42595. */
  42596. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42597. /**
  42598. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42599. * @param ray defines the ray to test with
  42600. * @param selection defines the array to store current content if selection is positive
  42601. */
  42602. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42603. /**
  42604. * Subdivide the content into child blocks (this block will then be empty)
  42605. */
  42606. createInnerBlocks(): void;
  42607. }
  42608. }
  42609. declare module BABYLON {
  42610. interface Scene {
  42611. /**
  42612. * @hidden
  42613. * Backing Filed
  42614. */
  42615. _selectionOctree: Octree<AbstractMesh>;
  42616. /**
  42617. * Gets the octree used to boost mesh selection (picking)
  42618. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42619. */
  42620. selectionOctree: Octree<AbstractMesh>;
  42621. /**
  42622. * Creates or updates the octree used to boost selection (picking)
  42623. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42624. * @param maxCapacity defines the maximum capacity per leaf
  42625. * @param maxDepth defines the maximum depth of the octree
  42626. * @returns an octree of AbstractMesh
  42627. */
  42628. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42629. }
  42630. interface AbstractMesh {
  42631. /**
  42632. * @hidden
  42633. * Backing Field
  42634. */
  42635. _submeshesOctree: Octree<SubMesh>;
  42636. /**
  42637. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42638. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42639. * @param maxCapacity defines the maximum size of each block (64 by default)
  42640. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42641. * @returns the new octree
  42642. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42643. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42644. */
  42645. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42646. }
  42647. /**
  42648. * Defines the octree scene component responsible to manage any octrees
  42649. * in a given scene.
  42650. */
  42651. class OctreeSceneComponent {
  42652. /**
  42653. * The component name helpfull to identify the component in the list of scene components.
  42654. */
  42655. readonly name: string;
  42656. /**
  42657. * The scene the component belongs to.
  42658. */
  42659. scene: Scene;
  42660. /**
  42661. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42662. */
  42663. readonly checksIsEnabled: boolean;
  42664. /**
  42665. * Creates a new instance of the component for the given scene
  42666. * @param scene Defines the scene to register the component in
  42667. */
  42668. constructor(scene: Scene);
  42669. /**
  42670. * Registers the component in a given scene
  42671. */
  42672. register(): void;
  42673. /**
  42674. * Return the list of active meshes
  42675. * @returns the list of active meshes
  42676. */
  42677. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42678. /**
  42679. * Return the list of active sub meshes
  42680. * @param mesh The mesh to get the candidates sub meshes from
  42681. * @returns the list of active sub meshes
  42682. */
  42683. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42684. private _tempRay;
  42685. /**
  42686. * Return the list of sub meshes intersecting with a given local ray
  42687. * @param mesh defines the mesh to find the submesh for
  42688. * @param localRay defines the ray in local space
  42689. * @returns the list of intersecting sub meshes
  42690. */
  42691. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42692. /**
  42693. * Return the list of sub meshes colliding with a collider
  42694. * @param mesh defines the mesh to find the submesh for
  42695. * @param collider defines the collider to evaluate the collision against
  42696. * @returns the list of colliding sub meshes
  42697. */
  42698. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42699. /**
  42700. * Rebuilds the elements related to this component in case of
  42701. * context lost for instance.
  42702. */
  42703. rebuild(): void;
  42704. /**
  42705. * Disposes the component and the associated ressources.
  42706. */
  42707. dispose(): void;
  42708. }
  42709. }
  42710. declare module BABYLON {
  42711. /**
  42712. * This represents all the required metrics to create a VR camera.
  42713. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42714. */
  42715. class VRCameraMetrics {
  42716. /**
  42717. * Define the horizontal resolution off the screen.
  42718. */
  42719. hResolution: number;
  42720. /**
  42721. * Define the vertical resolution off the screen.
  42722. */
  42723. vResolution: number;
  42724. /**
  42725. * Define the horizontal screen size.
  42726. */
  42727. hScreenSize: number;
  42728. /**
  42729. * Define the vertical screen size.
  42730. */
  42731. vScreenSize: number;
  42732. /**
  42733. * Define the vertical screen center position.
  42734. */
  42735. vScreenCenter: number;
  42736. /**
  42737. * Define the distance of the eyes to the screen.
  42738. */
  42739. eyeToScreenDistance: number;
  42740. /**
  42741. * Define the distance between both lenses
  42742. */
  42743. lensSeparationDistance: number;
  42744. /**
  42745. * Define the distance between both viewer's eyes.
  42746. */
  42747. interpupillaryDistance: number;
  42748. /**
  42749. * Define the distortion factor of the VR postprocess.
  42750. * Please, touch with care.
  42751. */
  42752. distortionK: number[];
  42753. /**
  42754. * Define the chromatic aberration correction factors for the VR post process.
  42755. */
  42756. chromaAbCorrection: number[];
  42757. /**
  42758. * Define the scale factor of the post process.
  42759. * The smaller the better but the slower.
  42760. */
  42761. postProcessScaleFactor: number;
  42762. /**
  42763. * Define an offset for the lens center.
  42764. */
  42765. lensCenterOffset: number;
  42766. /**
  42767. * Define if the current vr camera should compensate the distortion of the lense or not.
  42768. */
  42769. compensateDistortion: boolean;
  42770. /**
  42771. * Gets the rendering aspect ratio based on the provided resolutions.
  42772. */
  42773. readonly aspectRatio: number;
  42774. /**
  42775. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42776. */
  42777. readonly aspectRatioFov: number;
  42778. /**
  42779. * @hidden
  42780. */
  42781. readonly leftHMatrix: Matrix;
  42782. /**
  42783. * @hidden
  42784. */
  42785. readonly rightHMatrix: Matrix;
  42786. /**
  42787. * @hidden
  42788. */
  42789. readonly leftPreViewMatrix: Matrix;
  42790. /**
  42791. * @hidden
  42792. */
  42793. readonly rightPreViewMatrix: Matrix;
  42794. /**
  42795. * Get the default VRMetrics based on the most generic setup.
  42796. * @returns the default vr metrics
  42797. */
  42798. static GetDefault(): VRCameraMetrics;
  42799. }
  42800. }
  42801. declare module BABYLON {
  42802. /**
  42803. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42804. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42805. */
  42806. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42807. /**
  42808. * Creates a new VRDeviceOrientationArcRotateCamera
  42809. * @param name defines camera name
  42810. * @param alpha defines the camera rotation along the logitudinal axis
  42811. * @param beta defines the camera rotation along the latitudinal axis
  42812. * @param radius defines the camera distance from its target
  42813. * @param target defines the camera target
  42814. * @param scene defines the scene the camera belongs to
  42815. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42816. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42817. */
  42818. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42819. /**
  42820. * Gets camera class name
  42821. * @returns VRDeviceOrientationArcRotateCamera
  42822. */
  42823. getClassName(): string;
  42824. }
  42825. }
  42826. declare module BABYLON {
  42827. /**
  42828. * Camera used to simulate VR rendering (based on FreeCamera)
  42829. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42830. */
  42831. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42832. /**
  42833. * Creates a new VRDeviceOrientationFreeCamera
  42834. * @param name defines camera name
  42835. * @param position defines the start position of the camera
  42836. * @param scene defines the scene the camera belongs to
  42837. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42838. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42839. */
  42840. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42841. /**
  42842. * Gets camera class name
  42843. * @returns VRDeviceOrientationFreeCamera
  42844. */
  42845. getClassName(): string;
  42846. }
  42847. }
  42848. declare module BABYLON {
  42849. /**
  42850. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42851. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42852. */
  42853. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42854. /**
  42855. * Creates a new VRDeviceOrientationGamepadCamera
  42856. * @param name defines camera name
  42857. * @param position defines the start position of the camera
  42858. * @param scene defines the scene the camera belongs to
  42859. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42860. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42861. */
  42862. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42863. /**
  42864. * Gets camera class name
  42865. * @returns VRDeviceOrientationGamepadCamera
  42866. */
  42867. getClassName(): string;
  42868. }
  42869. }
  42870. declare module BABYLON {
  42871. /**
  42872. * Options to modify the vr teleportation behavior.
  42873. */
  42874. interface VRTeleportationOptions {
  42875. /**
  42876. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42877. */
  42878. floorMeshName?: string;
  42879. /**
  42880. * A list of meshes to be used as the teleportation floor. (default: empty)
  42881. */
  42882. floorMeshes?: Mesh[];
  42883. }
  42884. /**
  42885. * Options to modify the vr experience helper's behavior.
  42886. */
  42887. interface VRExperienceHelperOptions extends WebVROptions {
  42888. /**
  42889. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42890. */
  42891. createDeviceOrientationCamera?: boolean;
  42892. /**
  42893. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42894. */
  42895. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42896. /**
  42897. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42898. */
  42899. laserToggle?: boolean;
  42900. /**
  42901. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42902. */
  42903. floorMeshes?: Mesh[];
  42904. }
  42905. /**
  42906. * Helps to quickly add VR support to an existing scene.
  42907. * See http://doc.babylonjs.com/how_to/webvr_helper
  42908. */
  42909. class VRExperienceHelper {
  42910. /** Options to modify the vr experience helper's behavior. */
  42911. webVROptions: VRExperienceHelperOptions;
  42912. private _scene;
  42913. private _position;
  42914. private _btnVR;
  42915. private _btnVRDisplayed;
  42916. private _webVRsupported;
  42917. private _webVRready;
  42918. private _webVRrequesting;
  42919. private _webVRpresenting;
  42920. private _hasEnteredVR;
  42921. private _fullscreenVRpresenting;
  42922. private _canvas;
  42923. private _webVRCamera;
  42924. private _vrDeviceOrientationCamera;
  42925. private _deviceOrientationCamera;
  42926. private _existingCamera;
  42927. private _onKeyDown;
  42928. private _onVrDisplayPresentChange;
  42929. private _onVRDisplayChanged;
  42930. private _onVRRequestPresentStart;
  42931. private _onVRRequestPresentComplete;
  42932. /**
  42933. * Observable raised when entering VR.
  42934. */
  42935. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42936. /**
  42937. * Observable raised when exiting VR.
  42938. */
  42939. onExitingVRObservable: Observable<VRExperienceHelper>;
  42940. /**
  42941. * Observable raised when controller mesh is loaded.
  42942. */
  42943. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42944. /** Return this.onEnteringVRObservable
  42945. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42946. */
  42947. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42948. /** Return this.onExitingVRObservable
  42949. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42950. */
  42951. readonly onExitingVR: Observable<VRExperienceHelper>;
  42952. /** Return this.onControllerMeshLoadedObservable
  42953. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42954. */
  42955. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42956. private _rayLength;
  42957. private _useCustomVRButton;
  42958. private _teleportationRequested;
  42959. private _teleportActive;
  42960. private _floorMeshName;
  42961. private _floorMeshesCollection;
  42962. private _rotationAllowed;
  42963. private _teleportBackwardsVector;
  42964. private _teleportationTarget;
  42965. private _isDefaultTeleportationTarget;
  42966. private _postProcessMove;
  42967. private _teleportationFillColor;
  42968. private _teleportationBorderColor;
  42969. private _rotationAngle;
  42970. private _haloCenter;
  42971. private _cameraGazer;
  42972. private _padSensibilityUp;
  42973. private _padSensibilityDown;
  42974. private _leftController;
  42975. private _rightController;
  42976. /**
  42977. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42978. */
  42979. onNewMeshSelected: Observable<AbstractMesh>;
  42980. /**
  42981. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42982. */
  42983. onNewMeshPicked: Observable<PickingInfo>;
  42984. private _circleEase;
  42985. /**
  42986. * Observable raised before camera teleportation
  42987. */
  42988. onBeforeCameraTeleport: Observable<Vector3>;
  42989. /**
  42990. * Observable raised after camera teleportation
  42991. */
  42992. onAfterCameraTeleport: Observable<Vector3>;
  42993. /**
  42994. * Observable raised when current selected mesh gets unselected
  42995. */
  42996. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42997. private _raySelectionPredicate;
  42998. /**
  42999. * To be optionaly changed by user to define custom ray selection
  43000. */
  43001. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43002. /**
  43003. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43004. */
  43005. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43006. /**
  43007. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43008. */
  43009. teleportationEnabled: boolean;
  43010. private _defaultHeight;
  43011. private _teleportationInitialized;
  43012. private _interactionsEnabled;
  43013. private _interactionsRequested;
  43014. private _displayGaze;
  43015. private _displayLaserPointer;
  43016. /**
  43017. * The mesh used to display where the user is going to teleport.
  43018. */
  43019. /**
  43020. * Sets the mesh to be used to display where the user is going to teleport.
  43021. */
  43022. teleportationTarget: Mesh;
  43023. /**
  43024. * 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
  43025. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43026. * See http://doc.babylonjs.com/resources/baking_transformations
  43027. */
  43028. gazeTrackerMesh: Mesh;
  43029. /**
  43030. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43031. */
  43032. updateGazeTrackerScale: boolean;
  43033. /**
  43034. * The gaze tracking mesh corresponding to the left controller
  43035. */
  43036. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  43037. /**
  43038. * The gaze tracking mesh corresponding to the right controller
  43039. */
  43040. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  43041. /**
  43042. * If the ray of the gaze should be displayed.
  43043. */
  43044. /**
  43045. * Sets if the ray of the gaze should be displayed.
  43046. */
  43047. displayGaze: boolean;
  43048. /**
  43049. * If the ray of the LaserPointer should be displayed.
  43050. */
  43051. /**
  43052. * Sets if the ray of the LaserPointer should be displayed.
  43053. */
  43054. displayLaserPointer: boolean;
  43055. /**
  43056. * The deviceOrientationCamera used as the camera when not in VR.
  43057. */
  43058. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  43059. /**
  43060. * Based on the current WebVR support, returns the current VR camera used.
  43061. */
  43062. readonly currentVRCamera: Nullable<Camera>;
  43063. /**
  43064. * The webVRCamera which is used when in VR.
  43065. */
  43066. readonly webVRCamera: WebVRFreeCamera;
  43067. /**
  43068. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43069. */
  43070. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  43071. private readonly _teleportationRequestInitiated;
  43072. /**
  43073. * Instantiates a VRExperienceHelper.
  43074. * Helps to quickly add VR support to an existing scene.
  43075. * @param scene The scene the VRExperienceHelper belongs to.
  43076. * @param webVROptions Options to modify the vr experience helper's behavior.
  43077. */
  43078. constructor(scene: Scene,
  43079. /** Options to modify the vr experience helper's behavior. */
  43080. webVROptions?: VRExperienceHelperOptions);
  43081. private _onDefaultMeshLoaded;
  43082. private _onResize;
  43083. private _onFullscreenChange;
  43084. /**
  43085. * Gets a value indicating if we are currently in VR mode.
  43086. */
  43087. readonly isInVRMode: boolean;
  43088. private onVrDisplayPresentChange;
  43089. private onVRDisplayChanged;
  43090. private moveButtonToBottomRight;
  43091. private displayVRButton;
  43092. private updateButtonVisibility;
  43093. private _cachedAngularSensibility;
  43094. /**
  43095. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  43096. * Otherwise, will use the fullscreen API.
  43097. */
  43098. enterVR(): void;
  43099. /**
  43100. * Attempt to exit VR, or fullscreen.
  43101. */
  43102. exitVR(): void;
  43103. /**
  43104. * The position of the vr experience helper.
  43105. */
  43106. /**
  43107. * Sets the position of the vr experience helper.
  43108. */
  43109. position: Vector3;
  43110. /**
  43111. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43112. */
  43113. enableInteractions(): void;
  43114. private readonly _noControllerIsActive;
  43115. private beforeRender;
  43116. private _isTeleportationFloor;
  43117. /**
  43118. * Adds a floor mesh to be used for teleportation.
  43119. * @param floorMesh the mesh to be used for teleportation.
  43120. */
  43121. addFloorMesh(floorMesh: Mesh): void;
  43122. /**
  43123. * Removes a floor mesh from being used for teleportation.
  43124. * @param floorMesh the mesh to be removed.
  43125. */
  43126. removeFloorMesh(floorMesh: Mesh): void;
  43127. /**
  43128. * Enables interactions and teleportation using the VR controllers and gaze.
  43129. * @param vrTeleportationOptions options to modify teleportation behavior.
  43130. */
  43131. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43132. private _onNewGamepadConnected;
  43133. private _tryEnableInteractionOnController;
  43134. private _onNewGamepadDisconnected;
  43135. private _enableInteractionOnController;
  43136. private _checkTeleportWithRay;
  43137. private _checkRotate;
  43138. private _checkTeleportBackwards;
  43139. private _enableTeleportationOnController;
  43140. private _createTeleportationCircles;
  43141. private _displayTeleportationTarget;
  43142. private _hideTeleportationTarget;
  43143. private _rotateCamera;
  43144. private _moveTeleportationSelectorTo;
  43145. private _workingVector;
  43146. private _workingQuaternion;
  43147. private _workingMatrix;
  43148. /**
  43149. * Teleports the users feet to the desired location
  43150. * @param location The location where the user's feet should be placed
  43151. */
  43152. teleportCamera(location: Vector3): void;
  43153. private _convertNormalToDirectionOfRay;
  43154. private _castRayAndSelectObject;
  43155. private _notifySelectedMeshUnselected;
  43156. /**
  43157. * Sets the color of the laser ray from the vr controllers.
  43158. * @param color new color for the ray.
  43159. */
  43160. changeLaserColor(color: Color3): void;
  43161. /**
  43162. * Sets the color of the ray from the vr headsets gaze.
  43163. * @param color new color for the ray.
  43164. */
  43165. changeGazeColor(color: Color3): void;
  43166. /**
  43167. * Exits VR and disposes of the vr experience helper
  43168. */
  43169. dispose(): void;
  43170. /**
  43171. * Gets the name of the VRExperienceHelper class
  43172. * @returns "VRExperienceHelper"
  43173. */
  43174. getClassName(): string;
  43175. }
  43176. }
  43177. declare module BABYLON {
  43178. /**
  43179. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  43180. * IMPORTANT!! The data is right-hand data.
  43181. * @export
  43182. * @interface DevicePose
  43183. */
  43184. interface DevicePose {
  43185. /**
  43186. * The position of the device, values in array are [x,y,z].
  43187. */
  43188. readonly position: Nullable<Float32Array>;
  43189. /**
  43190. * The linearVelocity of the device, values in array are [x,y,z].
  43191. */
  43192. readonly linearVelocity: Nullable<Float32Array>;
  43193. /**
  43194. * The linearAcceleration of the device, values in array are [x,y,z].
  43195. */
  43196. readonly linearAcceleration: Nullable<Float32Array>;
  43197. /**
  43198. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  43199. */
  43200. readonly orientation: Nullable<Float32Array>;
  43201. /**
  43202. * The angularVelocity of the device, values in array are [x,y,z].
  43203. */
  43204. readonly angularVelocity: Nullable<Float32Array>;
  43205. /**
  43206. * The angularAcceleration of the device, values in array are [x,y,z].
  43207. */
  43208. readonly angularAcceleration: Nullable<Float32Array>;
  43209. }
  43210. /**
  43211. * Interface representing a pose controlled object in Babylon.
  43212. * A pose controlled object has both regular pose values as well as pose values
  43213. * from an external device such as a VR head mounted display
  43214. */
  43215. interface PoseControlled {
  43216. /**
  43217. * The position of the object in babylon space.
  43218. */
  43219. position: Vector3;
  43220. /**
  43221. * The rotation quaternion of the object in babylon space.
  43222. */
  43223. rotationQuaternion: Quaternion;
  43224. /**
  43225. * The position of the device in babylon space.
  43226. */
  43227. devicePosition?: Vector3;
  43228. /**
  43229. * The rotation quaternion of the device in babylon space.
  43230. */
  43231. deviceRotationQuaternion: Quaternion;
  43232. /**
  43233. * The raw pose coming from the device.
  43234. */
  43235. rawPose: Nullable<DevicePose>;
  43236. /**
  43237. * The scale of the device to be used when translating from device space to babylon space.
  43238. */
  43239. deviceScaleFactor: number;
  43240. /**
  43241. * Updates the poseControlled values based on the input device pose.
  43242. * @param poseData the pose data to update the object with
  43243. */
  43244. updateFromDevice(poseData: DevicePose): void;
  43245. }
  43246. /**
  43247. * Set of options to customize the webVRCamera
  43248. */
  43249. interface WebVROptions {
  43250. /**
  43251. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  43252. */
  43253. trackPosition?: boolean;
  43254. /**
  43255. * Sets the scale of the vrDevice in babylon space. (default: 1)
  43256. */
  43257. positionScale?: number;
  43258. /**
  43259. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  43260. */
  43261. displayName?: string;
  43262. /**
  43263. * Should the native controller meshes be initialized. (default: true)
  43264. */
  43265. controllerMeshes?: boolean;
  43266. /**
  43267. * Creating a default HemiLight only on controllers. (default: true)
  43268. */
  43269. defaultLightingOnControllers?: boolean;
  43270. /**
  43271. * If you don't want to use the default VR button of the helper. (default: false)
  43272. */
  43273. useCustomVRButton?: boolean;
  43274. /**
  43275. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  43276. */
  43277. customVRButton?: HTMLButtonElement;
  43278. /**
  43279. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  43280. */
  43281. rayLength?: number;
  43282. /**
  43283. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  43284. */
  43285. defaultHeight?: number;
  43286. }
  43287. /**
  43288. * This represents a WebVR camera.
  43289. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  43290. * @example http://doc.babylonjs.com/how_to/webvr_camera
  43291. */
  43292. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  43293. private webVROptions;
  43294. /**
  43295. * @hidden
  43296. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  43297. */
  43298. _vrDevice: any;
  43299. /**
  43300. * The rawPose of the vrDevice.
  43301. */
  43302. rawPose: Nullable<DevicePose>;
  43303. private _onVREnabled;
  43304. private _specsVersion;
  43305. private _attached;
  43306. private _frameData;
  43307. protected _descendants: Array<Node>;
  43308. private _deviceRoomPosition;
  43309. /** @hidden */
  43310. _deviceRoomRotationQuaternion: Quaternion;
  43311. private _standingMatrix;
  43312. /**
  43313. * Represents device position in babylon space.
  43314. */
  43315. devicePosition: Vector3;
  43316. /**
  43317. * Represents device rotation in babylon space.
  43318. */
  43319. deviceRotationQuaternion: Quaternion;
  43320. /**
  43321. * The scale of the device to be used when translating from device space to babylon space.
  43322. */
  43323. deviceScaleFactor: number;
  43324. private _deviceToWorld;
  43325. private _worldToDevice;
  43326. /**
  43327. * References to the webVR controllers for the vrDevice.
  43328. */
  43329. controllers: Array<WebVRController>;
  43330. /**
  43331. * Emits an event when a controller is attached.
  43332. */
  43333. onControllersAttachedObservable: Observable<WebVRController[]>;
  43334. /**
  43335. * Emits an event when a controller's mesh has been loaded;
  43336. */
  43337. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43338. /**
  43339. * Emits an event when the HMD's pose has been updated.
  43340. */
  43341. onPoseUpdatedFromDeviceObservable: Observable<any>;
  43342. private _poseSet;
  43343. /**
  43344. * If the rig cameras be used as parent instead of this camera.
  43345. */
  43346. rigParenting: boolean;
  43347. private _lightOnControllers;
  43348. private _defaultHeight?;
  43349. /**
  43350. * Instantiates a WebVRFreeCamera.
  43351. * @param name The name of the WebVRFreeCamera
  43352. * @param position The starting anchor position for the camera
  43353. * @param scene The scene the camera belongs to
  43354. * @param webVROptions a set of customizable options for the webVRCamera
  43355. */
  43356. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  43357. /**
  43358. * Gets the device distance from the ground in meters.
  43359. * @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.
  43360. */
  43361. deviceDistanceToRoomGround(): number;
  43362. /**
  43363. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  43364. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  43365. */
  43366. useStandingMatrix(callback?: (bool: boolean) => void): void;
  43367. /**
  43368. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  43369. * @returns A promise with a boolean set to if the standing matrix is supported.
  43370. */
  43371. useStandingMatrixAsync(): Promise<boolean>;
  43372. /**
  43373. * Disposes the camera
  43374. */
  43375. dispose(): void;
  43376. /**
  43377. * Gets a vrController by name.
  43378. * @param name The name of the controller to retreive
  43379. * @returns the controller matching the name specified or null if not found
  43380. */
  43381. getControllerByName(name: string): Nullable<WebVRController>;
  43382. private _leftController;
  43383. /**
  43384. * The controller corrisponding to the users left hand.
  43385. */
  43386. readonly leftController: Nullable<WebVRController>;
  43387. private _rightController;
  43388. /**
  43389. * The controller corrisponding to the users right hand.
  43390. */
  43391. readonly rightController: Nullable<WebVRController>;
  43392. /**
  43393. * Casts a ray forward from the vrCamera's gaze.
  43394. * @param length Length of the ray (default: 100)
  43395. * @returns the ray corrisponding to the gaze
  43396. */
  43397. getForwardRay(length?: number): Ray;
  43398. /**
  43399. * @hidden
  43400. * Updates the camera based on device's frame data
  43401. */
  43402. _checkInputs(): void;
  43403. /**
  43404. * Updates the poseControlled values based on the input device pose.
  43405. * @param poseData Pose coming from the device
  43406. */
  43407. updateFromDevice(poseData: DevicePose): void;
  43408. private _htmlElementAttached;
  43409. private _detachIfAttached;
  43410. /**
  43411. * WebVR's attach control will start broadcasting frames to the device.
  43412. * Note that in certain browsers (chrome for example) this function must be called
  43413. * within a user-interaction callback. Example:
  43414. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  43415. *
  43416. * @param element html element to attach the vrDevice to
  43417. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  43418. */
  43419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43420. /**
  43421. * Detaches the camera from the html element and disables VR
  43422. *
  43423. * @param element html element to detach from
  43424. */
  43425. detachControl(element: HTMLElement): void;
  43426. /**
  43427. * @returns the name of this class
  43428. */
  43429. getClassName(): string;
  43430. /**
  43431. * Calls resetPose on the vrDisplay
  43432. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  43433. */
  43434. resetToCurrentRotation(): void;
  43435. /**
  43436. * @hidden
  43437. * Updates the rig cameras (left and right eye)
  43438. */
  43439. _updateRigCameras(): void;
  43440. private _workingVector;
  43441. private _oneVector;
  43442. private _workingMatrix;
  43443. private updateCacheCalled;
  43444. private _correctPositionIfNotTrackPosition;
  43445. /**
  43446. * @hidden
  43447. * Updates the cached values of the camera
  43448. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  43449. */
  43450. _updateCache(ignoreParentClass?: boolean): void;
  43451. /**
  43452. * @hidden
  43453. * Get current device position in babylon world
  43454. */
  43455. _computeDevicePosition(): void;
  43456. /**
  43457. * Updates the current device position and rotation in the babylon world
  43458. */
  43459. update(): void;
  43460. /**
  43461. * @hidden
  43462. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  43463. * @returns an identity matrix
  43464. */
  43465. _getViewMatrix(): Matrix;
  43466. private _tmpMatrix;
  43467. /**
  43468. * This function is called by the two RIG cameras.
  43469. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  43470. */
  43471. protected _getWebVRViewMatrix(): Matrix;
  43472. protected _getWebVRProjectionMatrix(): Matrix;
  43473. private _onGamepadConnectedObserver;
  43474. private _onGamepadDisconnectedObserver;
  43475. private _updateCacheWhenTrackingDisabledObserver;
  43476. /**
  43477. * Initializes the controllers and their meshes
  43478. */
  43479. initControllers(): void;
  43480. }
  43481. }
  43482. declare module BABYLON {
  43483. /** @hidden */
  43484. class _OcclusionDataStorage {
  43485. /** @hidden */
  43486. occlusionInternalRetryCounter: number;
  43487. /** @hidden */
  43488. isOcclusionQueryInProgress: boolean;
  43489. /** @hidden */
  43490. isOccluded: boolean;
  43491. /** @hidden */
  43492. occlusionRetryCount: number;
  43493. /** @hidden */
  43494. occlusionType: number;
  43495. /** @hidden */
  43496. occlusionQueryAlgorithmType: number;
  43497. }
  43498. interface Engine {
  43499. /**
  43500. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43501. * @return the new query
  43502. */
  43503. createQuery(): WebGLQuery;
  43504. /**
  43505. * Delete and release a webGL query
  43506. * @param query defines the query to delete
  43507. * @return the current engine
  43508. */
  43509. deleteQuery(query: WebGLQuery): Engine;
  43510. /**
  43511. * Check if a given query has resolved and got its value
  43512. * @param query defines the query to check
  43513. * @returns true if the query got its value
  43514. */
  43515. isQueryResultAvailable(query: WebGLQuery): boolean;
  43516. /**
  43517. * Gets the value of a given query
  43518. * @param query defines the query to check
  43519. * @returns the value of the query
  43520. */
  43521. getQueryResult(query: WebGLQuery): number;
  43522. /**
  43523. * Initiates an occlusion query
  43524. * @param algorithmType defines the algorithm to use
  43525. * @param query defines the query to use
  43526. * @returns the current engine
  43527. * @see http://doc.babylonjs.com/features/occlusionquery
  43528. */
  43529. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43530. /**
  43531. * Ends an occlusion query
  43532. * @see http://doc.babylonjs.com/features/occlusionquery
  43533. * @param algorithmType defines the algorithm to use
  43534. * @returns the current engine
  43535. */
  43536. endOcclusionQuery(algorithmType: number): Engine;
  43537. /**
  43538. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43539. * Please note that only one query can be issued at a time
  43540. * @returns a time token used to track the time span
  43541. */
  43542. startTimeQuery(): Nullable<_TimeToken>;
  43543. /**
  43544. * Ends a time query
  43545. * @param token defines the token used to measure the time span
  43546. * @returns the time spent (in ns)
  43547. */
  43548. endTimeQuery(token: _TimeToken): int;
  43549. /** @hidden */
  43550. _currentNonTimestampToken: Nullable<_TimeToken>;
  43551. /** @hidden */
  43552. _createTimeQuery(): WebGLQuery;
  43553. /** @hidden */
  43554. _deleteTimeQuery(query: WebGLQuery): void;
  43555. /** @hidden */
  43556. _getGlAlgorithmType(algorithmType: number): number;
  43557. /** @hidden */
  43558. _getTimeQueryResult(query: WebGLQuery): any;
  43559. /** @hidden */
  43560. _getTimeQueryAvailability(query: WebGLQuery): any;
  43561. }
  43562. interface AbstractMesh {
  43563. /**
  43564. * Backing filed
  43565. * @hidden
  43566. */
  43567. __occlusionDataStorage: _OcclusionDataStorage;
  43568. /**
  43569. * Access property
  43570. * @hidden
  43571. */
  43572. _occlusionDataStorage: _OcclusionDataStorage;
  43573. /**
  43574. * 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.
  43575. * The default value is -1 which means don't break the query and wait till the result
  43576. * @see http://doc.babylonjs.com/features/occlusionquery
  43577. */
  43578. occlusionRetryCount: number;
  43579. /**
  43580. * 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:
  43581. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43582. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43583. * * 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.
  43584. * @see http://doc.babylonjs.com/features/occlusionquery
  43585. */
  43586. occlusionType: number;
  43587. /**
  43588. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43589. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43590. * * 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.
  43591. * @see http://doc.babylonjs.com/features/occlusionquery
  43592. */
  43593. occlusionQueryAlgorithmType: number;
  43594. /**
  43595. * 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
  43596. * @see http://doc.babylonjs.com/features/occlusionquery
  43597. */
  43598. isOccluded: boolean;
  43599. /**
  43600. * Flag to check the progress status of the query
  43601. * @see http://doc.babylonjs.com/features/occlusionquery
  43602. */
  43603. isOcclusionQueryInProgress: boolean;
  43604. }
  43605. }
  43606. declare module BABYLON {
  43607. interface Engine {
  43608. /**
  43609. * Creates a webGL transform feedback object
  43610. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43611. * @returns the webGL transform feedback object
  43612. */
  43613. createTransformFeedback(): WebGLTransformFeedback;
  43614. /**
  43615. * Delete a webGL transform feedback object
  43616. * @param value defines the webGL transform feedback object to delete
  43617. */
  43618. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43619. /**
  43620. * Bind a webGL transform feedback object to the webgl context
  43621. * @param value defines the webGL transform feedback object to bind
  43622. */
  43623. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43624. /**
  43625. * Begins a transform feedback operation
  43626. * @param usePoints defines if points or triangles must be used
  43627. */
  43628. beginTransformFeedback(usePoints: boolean): void;
  43629. /**
  43630. * Ends a transform feedback operation
  43631. */
  43632. endTransformFeedback(): void;
  43633. /**
  43634. * Specify the varyings to use with transform feedback
  43635. * @param program defines the associated webGL program
  43636. * @param value defines the list of strings representing the varying names
  43637. */
  43638. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43639. /**
  43640. * Bind a webGL buffer for a transform feedback operation
  43641. * @param value defines the webGL buffer to bind
  43642. */
  43643. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43644. }
  43645. }
  43646. declare module BABYLON {
  43647. /**
  43648. * Google Daydream controller
  43649. */
  43650. class DaydreamController extends WebVRController {
  43651. /**
  43652. * Base Url for the controller model.
  43653. */
  43654. static MODEL_BASE_URL: string;
  43655. /**
  43656. * File name for the controller model.
  43657. */
  43658. static MODEL_FILENAME: string;
  43659. /**
  43660. * Gamepad Id prefix used to identify Daydream Controller.
  43661. */
  43662. static readonly GAMEPAD_ID_PREFIX: string;
  43663. /**
  43664. * Creates a new DaydreamController from a gamepad
  43665. * @param vrGamepad the gamepad that the controller should be created from
  43666. */
  43667. constructor(vrGamepad: any);
  43668. /**
  43669. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43670. * @param scene scene in which to add meshes
  43671. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43672. */
  43673. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43674. /**
  43675. * Called once for each button that changed state since the last frame
  43676. * @param buttonIdx Which button index changed
  43677. * @param state New state of the button
  43678. * @param changes Which properties on the state changed since last frame
  43679. */
  43680. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43681. }
  43682. }
  43683. declare module BABYLON {
  43684. /**
  43685. * Gear VR Controller
  43686. */
  43687. class GearVRController extends WebVRController {
  43688. /**
  43689. * Base Url for the controller model.
  43690. */
  43691. static MODEL_BASE_URL: string;
  43692. /**
  43693. * File name for the controller model.
  43694. */
  43695. static MODEL_FILENAME: string;
  43696. /**
  43697. * Gamepad Id prefix used to identify this controller.
  43698. */
  43699. static readonly GAMEPAD_ID_PREFIX: string;
  43700. private readonly _buttonIndexToObservableNameMap;
  43701. /**
  43702. * Creates a new GearVRController from a gamepad
  43703. * @param vrGamepad the gamepad that the controller should be created from
  43704. */
  43705. constructor(vrGamepad: any);
  43706. /**
  43707. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43708. * @param scene scene in which to add meshes
  43709. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43710. */
  43711. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43712. /**
  43713. * Called once for each button that changed state since the last frame
  43714. * @param buttonIdx Which button index changed
  43715. * @param state New state of the button
  43716. * @param changes Which properties on the state changed since last frame
  43717. */
  43718. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43719. }
  43720. }
  43721. declare module BABYLON {
  43722. /**
  43723. * Generic Controller
  43724. */
  43725. class GenericController extends WebVRController {
  43726. /**
  43727. * Base Url for the controller model.
  43728. */
  43729. static readonly MODEL_BASE_URL: string;
  43730. /**
  43731. * File name for the controller model.
  43732. */
  43733. static readonly MODEL_FILENAME: string;
  43734. /**
  43735. * Creates a new GenericController from a gamepad
  43736. * @param vrGamepad the gamepad that the controller should be created from
  43737. */
  43738. constructor(vrGamepad: any);
  43739. /**
  43740. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43741. * @param scene scene in which to add meshes
  43742. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43743. */
  43744. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43745. /**
  43746. * Called once for each button that changed state since the last frame
  43747. * @param buttonIdx Which button index changed
  43748. * @param state New state of the button
  43749. * @param changes Which properties on the state changed since last frame
  43750. */
  43751. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43752. }
  43753. }
  43754. declare module BABYLON {
  43755. /**
  43756. * Oculus Touch Controller
  43757. */
  43758. class OculusTouchController extends WebVRController {
  43759. /**
  43760. * Base Url for the controller model.
  43761. */
  43762. static MODEL_BASE_URL: string;
  43763. /**
  43764. * File name for the left controller model.
  43765. */
  43766. static MODEL_LEFT_FILENAME: string;
  43767. /**
  43768. * File name for the right controller model.
  43769. */
  43770. static MODEL_RIGHT_FILENAME: string;
  43771. /**
  43772. * Fired when the secondary trigger on this controller is modified
  43773. */
  43774. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43775. /**
  43776. * Fired when the thumb rest on this controller is modified
  43777. */
  43778. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43779. /**
  43780. * Creates a new OculusTouchController from a gamepad
  43781. * @param vrGamepad the gamepad that the controller should be created from
  43782. */
  43783. constructor(vrGamepad: any);
  43784. /**
  43785. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43786. * @param scene scene in which to add meshes
  43787. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43788. */
  43789. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43790. /**
  43791. * Fired when the A button on this controller is modified
  43792. */
  43793. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43794. /**
  43795. * Fired when the B button on this controller is modified
  43796. */
  43797. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43798. /**
  43799. * Fired when the X button on this controller is modified
  43800. */
  43801. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43802. /**
  43803. * Fired when the Y button on this controller is modified
  43804. */
  43805. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43806. /**
  43807. * Called once for each button that changed state since the last frame
  43808. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43809. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43810. * 2) secondary trigger (same)
  43811. * 3) A (right) X (left), touch, pressed = value
  43812. * 4) B / Y
  43813. * 5) thumb rest
  43814. * @param buttonIdx Which button index changed
  43815. * @param state New state of the button
  43816. * @param changes Which properties on the state changed since last frame
  43817. */
  43818. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43819. }
  43820. }
  43821. declare module BABYLON {
  43822. /**
  43823. * Defines the types of pose enabled controllers that are supported
  43824. */
  43825. enum PoseEnabledControllerType {
  43826. /**
  43827. * HTC Vive
  43828. */
  43829. VIVE = 0,
  43830. /**
  43831. * Oculus Rift
  43832. */
  43833. OCULUS = 1,
  43834. /**
  43835. * Windows mixed reality
  43836. */
  43837. WINDOWS = 2,
  43838. /**
  43839. * Samsung gear VR
  43840. */
  43841. GEAR_VR = 3,
  43842. /**
  43843. * Google Daydream
  43844. */
  43845. DAYDREAM = 4,
  43846. /**
  43847. * Generic
  43848. */
  43849. GENERIC = 5
  43850. }
  43851. /**
  43852. * Defines the MutableGamepadButton interface for the state of a gamepad button
  43853. */
  43854. interface MutableGamepadButton {
  43855. /**
  43856. * Value of the button/trigger
  43857. */
  43858. value: number;
  43859. /**
  43860. * If the button/trigger is currently touched
  43861. */
  43862. touched: boolean;
  43863. /**
  43864. * If the button/trigger is currently pressed
  43865. */
  43866. pressed: boolean;
  43867. }
  43868. /**
  43869. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  43870. * @hidden
  43871. */
  43872. interface ExtendedGamepadButton extends GamepadButton {
  43873. /**
  43874. * If the button/trigger is currently pressed
  43875. */
  43876. readonly pressed: boolean;
  43877. /**
  43878. * If the button/trigger is currently touched
  43879. */
  43880. readonly touched: boolean;
  43881. /**
  43882. * Value of the button/trigger
  43883. */
  43884. readonly value: number;
  43885. }
  43886. /**
  43887. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43888. */
  43889. class PoseEnabledControllerHelper {
  43890. /**
  43891. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43892. * @param vrGamepad the gamepad to initialized
  43893. * @returns a vr controller of the type the gamepad identified as
  43894. */
  43895. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  43896. }
  43897. /**
  43898. * Defines the PoseEnabledController object that contains state of a vr capable controller
  43899. */
  43900. class PoseEnabledController extends Gamepad implements PoseControlled {
  43901. private _deviceRoomPosition;
  43902. private _deviceRoomRotationQuaternion;
  43903. /**
  43904. * The device position in babylon space
  43905. */
  43906. devicePosition: Vector3;
  43907. /**
  43908. * The device rotation in babylon space
  43909. */
  43910. deviceRotationQuaternion: Quaternion;
  43911. /**
  43912. * The scale factor of the device in babylon space
  43913. */
  43914. deviceScaleFactor: number;
  43915. /**
  43916. * (Likely devicePosition should be used instead) The device position in its room space
  43917. */
  43918. position: Vector3;
  43919. /**
  43920. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  43921. */
  43922. rotationQuaternion: Quaternion;
  43923. /**
  43924. * The type of controller (Eg. Windows mixed reality)
  43925. */
  43926. controllerType: PoseEnabledControllerType;
  43927. protected _calculatedPosition: Vector3;
  43928. private _calculatedRotation;
  43929. /**
  43930. * The raw pose from the device
  43931. */
  43932. rawPose: DevicePose;
  43933. private _trackPosition;
  43934. private _maxRotationDistFromHeadset;
  43935. private _draggedRoomRotation;
  43936. /**
  43937. * @hidden
  43938. */
  43939. _disableTrackPosition(fixedPosition: Vector3): void;
  43940. /**
  43941. * Internal, the mesh attached to the controller
  43942. * @hidden
  43943. */
  43944. _mesh: Nullable<AbstractMesh>;
  43945. private _poseControlledCamera;
  43946. private _leftHandSystemQuaternion;
  43947. /**
  43948. * Internal, matrix used to convert room space to babylon space
  43949. * @hidden
  43950. */
  43951. _deviceToWorld: Matrix;
  43952. /**
  43953. * Node to be used when casting a ray from the controller
  43954. * @hidden
  43955. */
  43956. _pointingPoseNode: Nullable<TransformNode>;
  43957. /**
  43958. * Name of the child mesh that can be used to cast a ray from the controller
  43959. */
  43960. static readonly POINTING_POSE: string;
  43961. /**
  43962. * Creates a new PoseEnabledController from a gamepad
  43963. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  43964. */
  43965. constructor(browserGamepad: any);
  43966. private _workingMatrix;
  43967. /**
  43968. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  43969. */
  43970. update(): void;
  43971. /**
  43972. * Updates only the pose device and mesh without doing any button event checking
  43973. */
  43974. protected _updatePoseAndMesh(): void;
  43975. /**
  43976. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  43977. * @param poseData raw pose fromthe device
  43978. */
  43979. updateFromDevice(poseData: DevicePose): void;
  43980. /**
  43981. * @hidden
  43982. */
  43983. _meshAttachedObservable: Observable<AbstractMesh>;
  43984. /**
  43985. * Attaches a mesh to the controller
  43986. * @param mesh the mesh to be attached
  43987. */
  43988. attachToMesh(mesh: AbstractMesh): void;
  43989. /**
  43990. * Attaches the controllers mesh to a camera
  43991. * @param camera the camera the mesh should be attached to
  43992. */
  43993. attachToPoseControlledCamera(camera: TargetCamera): void;
  43994. /**
  43995. * Disposes of the controller
  43996. */
  43997. dispose(): void;
  43998. /**
  43999. * The mesh that is attached to the controller
  44000. */
  44001. readonly mesh: Nullable<AbstractMesh>;
  44002. /**
  44003. * Gets the ray of the controller in the direction the controller is pointing
  44004. * @param length the length the resulting ray should be
  44005. * @returns a ray in the direction the controller is pointing
  44006. */
  44007. getForwardRay(length?: number): Ray;
  44008. }
  44009. }
  44010. declare module BABYLON {
  44011. /**
  44012. * Vive Controller
  44013. */
  44014. class ViveController extends WebVRController {
  44015. /**
  44016. * Base Url for the controller model.
  44017. */
  44018. static MODEL_BASE_URL: string;
  44019. /**
  44020. * File name for the controller model.
  44021. */
  44022. static MODEL_FILENAME: string;
  44023. /**
  44024. * Creates a new ViveController from a gamepad
  44025. * @param vrGamepad the gamepad that the controller should be created from
  44026. */
  44027. constructor(vrGamepad: any);
  44028. /**
  44029. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44030. * @param scene scene in which to add meshes
  44031. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44032. */
  44033. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44034. /**
  44035. * Fired when the left button on this controller is modified
  44036. */
  44037. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44038. /**
  44039. * Fired when the right button on this controller is modified
  44040. */
  44041. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44042. /**
  44043. * Fired when the menu button on this controller is modified
  44044. */
  44045. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44046. /**
  44047. * Called once for each button that changed state since the last frame
  44048. * Vive mapping:
  44049. * 0: touchpad
  44050. * 1: trigger
  44051. * 2: left AND right buttons
  44052. * 3: menu button
  44053. * @param buttonIdx Which button index changed
  44054. * @param state New state of the button
  44055. * @param changes Which properties on the state changed since last frame
  44056. */
  44057. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44058. }
  44059. }
  44060. declare module BABYLON {
  44061. /**
  44062. * Defines the WebVRController object that represents controllers tracked in 3D space
  44063. */
  44064. abstract class WebVRController extends PoseEnabledController {
  44065. /**
  44066. * Internal, the default controller model for the controller
  44067. */
  44068. protected _defaultModel: AbstractMesh;
  44069. /**
  44070. * Fired when the trigger state has changed
  44071. */
  44072. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44073. /**
  44074. * Fired when the main button state has changed
  44075. */
  44076. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44077. /**
  44078. * Fired when the secondary button state has changed
  44079. */
  44080. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44081. /**
  44082. * Fired when the pad state has changed
  44083. */
  44084. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  44085. /**
  44086. * Fired when controllers stick values have changed
  44087. */
  44088. onPadValuesChangedObservable: Observable<StickValues>;
  44089. /**
  44090. * Array of button availible on the controller
  44091. */
  44092. protected _buttons: Array<MutableGamepadButton>;
  44093. private _onButtonStateChange;
  44094. /**
  44095. * Fired when a controller button's state has changed
  44096. * @param callback the callback containing the button that was modified
  44097. */
  44098. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  44099. /**
  44100. * X and Y axis corrisponding to the controllers joystick
  44101. */
  44102. pad: StickValues;
  44103. /**
  44104. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  44105. */
  44106. hand: string;
  44107. /**
  44108. * The default controller model for the controller
  44109. */
  44110. readonly defaultModel: AbstractMesh;
  44111. /**
  44112. * Creates a new WebVRController from a gamepad
  44113. * @param vrGamepad the gamepad that the WebVRController should be created from
  44114. */
  44115. constructor(vrGamepad: any);
  44116. /**
  44117. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  44118. */
  44119. update(): void;
  44120. /**
  44121. * Function to be called when a button is modified
  44122. */
  44123. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44124. /**
  44125. * Loads a mesh and attaches it to the controller
  44126. * @param scene the scene the mesh should be added to
  44127. * @param meshLoaded callback for when the mesh has been loaded
  44128. */
  44129. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44130. private _setButtonValue;
  44131. private _changes;
  44132. private _checkChanges;
  44133. /**
  44134. * Disposes of th webVRCOntroller
  44135. */
  44136. dispose(): void;
  44137. }
  44138. }
  44139. declare module BABYLON {
  44140. /**
  44141. * Defines the WindowsMotionController object that the state of the windows motion controller
  44142. */
  44143. class WindowsMotionController extends WebVRController {
  44144. /**
  44145. * The base url used to load the left and right controller models
  44146. */
  44147. static MODEL_BASE_URL: string;
  44148. /**
  44149. * The name of the left controller model file
  44150. */
  44151. static MODEL_LEFT_FILENAME: string;
  44152. /**
  44153. * The name of the right controller model file
  44154. */
  44155. static MODEL_RIGHT_FILENAME: string;
  44156. /**
  44157. * The controller name prefix for this controller type
  44158. */
  44159. static readonly GAMEPAD_ID_PREFIX: string;
  44160. /**
  44161. * The controller id pattern for this controller type
  44162. */
  44163. private static readonly GAMEPAD_ID_PATTERN;
  44164. private _loadedMeshInfo;
  44165. private readonly _mapping;
  44166. /**
  44167. * Fired when the trackpad on this controller is clicked
  44168. */
  44169. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44170. /**
  44171. * Fired when the trackpad on this controller is modified
  44172. */
  44173. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44174. /**
  44175. * The current x and y values of this controller's trackpad
  44176. */
  44177. trackpad: StickValues;
  44178. /**
  44179. * Creates a new WindowsMotionController from a gamepad
  44180. * @param vrGamepad the gamepad that the controller should be created from
  44181. */
  44182. constructor(vrGamepad: any);
  44183. /**
  44184. * Fired when the trigger on this controller is modified
  44185. */
  44186. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44187. /**
  44188. * Fired when the menu button on this controller is modified
  44189. */
  44190. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44191. /**
  44192. * Fired when the grip button on this controller is modified
  44193. */
  44194. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44195. /**
  44196. * Fired when the thumbstick button on this controller is modified
  44197. */
  44198. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44199. /**
  44200. * Fired when the touchpad button on this controller is modified
  44201. */
  44202. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44203. /**
  44204. * Fired when the touchpad values on this controller are modified
  44205. */
  44206. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44207. private _updateTrackpad;
  44208. /**
  44209. * Called once per frame by the engine.
  44210. */
  44211. update(): void;
  44212. /**
  44213. * Called once for each button that changed state since the last frame
  44214. * @param buttonIdx Which button index changed
  44215. * @param state New state of the button
  44216. * @param changes Which properties on the state changed since last frame
  44217. */
  44218. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44219. /**
  44220. * Moves the buttons on the controller mesh based on their current state
  44221. * @param buttonName the name of the button to move
  44222. * @param buttonValue the value of the button which determines the buttons new position
  44223. */
  44224. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44225. /**
  44226. * Moves the axis on the controller mesh based on its current state
  44227. * @param axis the index of the axis
  44228. * @param axisValue the value of the axis which determines the meshes new position
  44229. * @hidden
  44230. */
  44231. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44232. /**
  44233. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44234. * @param scene scene in which to add meshes
  44235. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44236. */
  44237. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44238. /**
  44239. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44240. * can be transformed by button presses and axes values, based on this._mapping.
  44241. *
  44242. * @param scene scene in which the meshes exist
  44243. * @param meshes list of meshes that make up the controller model to process
  44244. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44245. */
  44246. private processModel;
  44247. private createMeshInfo;
  44248. /**
  44249. * Gets the ray of the controller in the direction the controller is pointing
  44250. * @param length the length the resulting ray should be
  44251. * @returns a ray in the direction the controller is pointing
  44252. */
  44253. getForwardRay(length?: number): Ray;
  44254. /**
  44255. * Disposes of the controller
  44256. */
  44257. dispose(): void;
  44258. }
  44259. }
  44260. declare module BABYLON {
  44261. /**
  44262. * Interface to implement to create a shadow generator compatible with BJS.
  44263. */
  44264. interface IShadowGenerator {
  44265. /**
  44266. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44267. * @returns The render target texture if present otherwise, null
  44268. */
  44269. getShadowMap(): Nullable<RenderTargetTexture>;
  44270. /**
  44271. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44272. * @returns The render target texture if the shadow map is present otherwise, null
  44273. */
  44274. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44275. /**
  44276. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44277. * @param subMesh The submesh we want to render in the shadow map
  44278. * @param useInstances Defines wether will draw in the map using instances
  44279. * @returns true if ready otherwise, false
  44280. */
  44281. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44282. /**
  44283. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44284. * @param defines Defines of the material we want to update
  44285. * @param lightIndex Index of the light in the enabled light list of the material
  44286. */
  44287. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  44288. /**
  44289. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44290. * defined in the generator but impacting the effect).
  44291. * It implies the unifroms available on the materials are the standard BJS ones.
  44292. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44293. * @param effect The effect we are binfing the information for
  44294. */
  44295. bindShadowLight(lightIndex: string, effect: Effect): void;
  44296. /**
  44297. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44298. * (eq to shadow prjection matrix * light transform matrix)
  44299. * @returns The transform matrix used to create the shadow map
  44300. */
  44301. getTransformMatrix(): Matrix;
  44302. /**
  44303. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44304. * Cube and 2D textures for instance.
  44305. */
  44306. recreateShadowMap(): void;
  44307. /**
  44308. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44309. * @param onCompiled Callback triggered at the and of the effects compilation
  44310. * @param options Sets of optional options forcing the compilation with different modes
  44311. */
  44312. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44313. useInstances: boolean;
  44314. }>): void;
  44315. /**
  44316. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44317. * @param options Sets of optional options forcing the compilation with different modes
  44318. * @returns A promise that resolves when the compilation completes
  44319. */
  44320. forceCompilationAsync(options?: Partial<{
  44321. useInstances: boolean;
  44322. }>): Promise<void>;
  44323. /**
  44324. * Serializes the shadow generator setup to a json object.
  44325. * @returns The serialized JSON object
  44326. */
  44327. serialize(): any;
  44328. /**
  44329. * Disposes the Shadow map and related Textures and effects.
  44330. */
  44331. dispose(): void;
  44332. }
  44333. /**
  44334. * Default implementation IShadowGenerator.
  44335. * This is the main object responsible of generating shadows in the framework.
  44336. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44337. */
  44338. class ShadowGenerator implements IShadowGenerator {
  44339. /**
  44340. * Shadow generator mode None: no filtering applied.
  44341. */
  44342. static readonly FILTER_NONE: number;
  44343. /**
  44344. * Shadow generator mode ESM: Exponential Shadow Mapping.
  44345. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44346. */
  44347. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  44348. /**
  44349. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  44350. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  44351. */
  44352. static readonly FILTER_POISSONSAMPLING: number;
  44353. /**
  44354. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  44355. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44356. */
  44357. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  44358. /**
  44359. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  44360. * edge artifacts on steep falloff.
  44361. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44362. */
  44363. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  44364. /**
  44365. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  44366. * edge artifacts on steep falloff.
  44367. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44368. */
  44369. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  44370. /**
  44371. * Shadow generator mode PCF: Percentage Closer Filtering
  44372. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44373. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  44374. */
  44375. static readonly FILTER_PCF: number;
  44376. /**
  44377. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  44378. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44379. * Contact Hardening
  44380. */
  44381. static readonly FILTER_PCSS: number;
  44382. /**
  44383. * Reserved for PCF and PCSS
  44384. * Highest Quality.
  44385. *
  44386. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  44387. *
  44388. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  44389. */
  44390. static readonly QUALITY_HIGH: number;
  44391. /**
  44392. * Reserved for PCF and PCSS
  44393. * Good tradeoff for quality/perf cross devices
  44394. *
  44395. * Execute PCF on a 3*3 kernel.
  44396. *
  44397. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  44398. */
  44399. static readonly QUALITY_MEDIUM: number;
  44400. /**
  44401. * Reserved for PCF and PCSS
  44402. * The lowest quality but the fastest.
  44403. *
  44404. * Execute PCF on a 1*1 kernel.
  44405. *
  44406. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  44407. */
  44408. static readonly QUALITY_LOW: number;
  44409. private _bias;
  44410. /**
  44411. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44412. */
  44413. /**
  44414. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44415. */
  44416. bias: number;
  44417. private _normalBias;
  44418. /**
  44419. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44420. */
  44421. /**
  44422. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44423. */
  44424. normalBias: number;
  44425. private _blurBoxOffset;
  44426. /**
  44427. * Gets the blur box offset: offset applied during the blur pass.
  44428. * Only usefull if useKernelBlur = false
  44429. */
  44430. /**
  44431. * Sets the blur box offset: offset applied during the blur pass.
  44432. * Only usefull if useKernelBlur = false
  44433. */
  44434. blurBoxOffset: number;
  44435. private _blurScale;
  44436. /**
  44437. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44438. * 2 means half of the size.
  44439. */
  44440. /**
  44441. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44442. * 2 means half of the size.
  44443. */
  44444. blurScale: number;
  44445. private _blurKernel;
  44446. /**
  44447. * Gets the blur kernel: kernel size of the blur pass.
  44448. * Only usefull if useKernelBlur = true
  44449. */
  44450. /**
  44451. * Sets the blur kernel: kernel size of the blur pass.
  44452. * Only usefull if useKernelBlur = true
  44453. */
  44454. blurKernel: number;
  44455. private _useKernelBlur;
  44456. /**
  44457. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44458. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  44459. */
  44460. /**
  44461. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44462. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  44463. */
  44464. useKernelBlur: boolean;
  44465. private _depthScale;
  44466. /**
  44467. * Gets the depth scale used in ESM mode.
  44468. */
  44469. /**
  44470. * Sets the depth scale used in ESM mode.
  44471. * This can override the scale stored on the light.
  44472. */
  44473. depthScale: number;
  44474. private _filter;
  44475. /**
  44476. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44477. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44478. */
  44479. /**
  44480. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44481. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44482. */
  44483. filter: number;
  44484. /**
  44485. * Gets if the current filter is set to Poisson Sampling.
  44486. */
  44487. /**
  44488. * Sets the current filter to Poisson Sampling.
  44489. */
  44490. usePoissonSampling: boolean;
  44491. /**
  44492. * Gets if the current filter is set to ESM.
  44493. */
  44494. /**
  44495. * Sets the current filter is to ESM.
  44496. */
  44497. useExponentialShadowMap: boolean;
  44498. /**
  44499. * Gets if the current filter is set to filtered ESM.
  44500. */
  44501. /**
  44502. * Gets if the current filter is set to filtered ESM.
  44503. */
  44504. useBlurExponentialShadowMap: boolean;
  44505. /**
  44506. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44507. * exponential to prevent steep falloff artifacts).
  44508. */
  44509. /**
  44510. * Sets the current filter to "close ESM" (using the inverse of the
  44511. * exponential to prevent steep falloff artifacts).
  44512. */
  44513. useCloseExponentialShadowMap: boolean;
  44514. /**
  44515. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44516. * exponential to prevent steep falloff artifacts).
  44517. */
  44518. /**
  44519. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44520. * exponential to prevent steep falloff artifacts).
  44521. */
  44522. useBlurCloseExponentialShadowMap: boolean;
  44523. /**
  44524. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44525. */
  44526. /**
  44527. * Sets the current filter to "PCF" (percentage closer filtering).
  44528. */
  44529. usePercentageCloserFiltering: boolean;
  44530. private _filteringQuality;
  44531. /**
  44532. * Gets the PCF or PCSS Quality.
  44533. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44534. */
  44535. /**
  44536. * Sets the PCF or PCSS Quality.
  44537. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44538. */
  44539. filteringQuality: number;
  44540. /**
  44541. * Gets if the current filter is set to "PCSS" (contact hardening).
  44542. */
  44543. /**
  44544. * Sets the current filter to "PCSS" (contact hardening).
  44545. */
  44546. useContactHardeningShadow: boolean;
  44547. private _contactHardeningLightSizeUVRatio;
  44548. /**
  44549. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44550. * Using a ratio helps keeping shape stability independently of the map size.
  44551. *
  44552. * It does not account for the light projection as it was having too much
  44553. * instability during the light setup or during light position changes.
  44554. *
  44555. * Only valid if useContactHardeningShadow is true.
  44556. */
  44557. /**
  44558. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44559. * Using a ratio helps keeping shape stability independently of the map size.
  44560. *
  44561. * It does not account for the light projection as it was having too much
  44562. * instability during the light setup or during light position changes.
  44563. *
  44564. * Only valid if useContactHardeningShadow is true.
  44565. */
  44566. contactHardeningLightSizeUVRatio: number;
  44567. private _darkness;
  44568. /**
  44569. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44570. * 0 means strongest and 1 would means no shadow.
  44571. * @returns the darkness.
  44572. */
  44573. getDarkness(): number;
  44574. /**
  44575. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44576. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44577. * @returns the shadow generator allowing fluent coding.
  44578. */
  44579. setDarkness(darkness: number): ShadowGenerator;
  44580. private _transparencyShadow;
  44581. /**
  44582. * Sets the ability to have transparent shadow (boolean).
  44583. * @param transparent True if transparent else False
  44584. * @returns the shadow generator allowing fluent coding
  44585. */
  44586. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  44587. private _shadowMap;
  44588. private _shadowMap2;
  44589. /**
  44590. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44591. * @returns The render target texture if present otherwise, null
  44592. */
  44593. getShadowMap(): Nullable<RenderTargetTexture>;
  44594. /**
  44595. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44596. * @returns The render target texture if the shadow map is present otherwise, null
  44597. */
  44598. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44599. /**
  44600. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44601. * @param mesh Mesh to add
  44602. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44603. * @returns the Shadow Generator itself
  44604. */
  44605. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44606. /**
  44607. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44608. * @param mesh Mesh to remove
  44609. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44610. * @returns the Shadow Generator itself
  44611. */
  44612. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44613. /**
  44614. * Controls the extent to which the shadows fade out at the edge of the frustum
  44615. * Used only by directionals and spots
  44616. */
  44617. frustumEdgeFalloff: number;
  44618. private _light;
  44619. /**
  44620. * Returns the associated light object.
  44621. * @returns the light generating the shadow
  44622. */
  44623. getLight(): IShadowLight;
  44624. /**
  44625. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44626. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44627. * It might on the other hand introduce peter panning.
  44628. */
  44629. forceBackFacesOnly: boolean;
  44630. private _scene;
  44631. private _lightDirection;
  44632. private _effect;
  44633. private _viewMatrix;
  44634. private _projectionMatrix;
  44635. private _transformMatrix;
  44636. private _cachedPosition;
  44637. private _cachedDirection;
  44638. private _cachedDefines;
  44639. private _currentRenderID;
  44640. private _boxBlurPostprocess;
  44641. private _kernelBlurXPostprocess;
  44642. private _kernelBlurYPostprocess;
  44643. private _blurPostProcesses;
  44644. private _mapSize;
  44645. private _currentFaceIndex;
  44646. private _currentFaceIndexCache;
  44647. private _textureType;
  44648. private _defaultTextureMatrix;
  44649. /**
  44650. * Creates a ShadowGenerator object.
  44651. * A ShadowGenerator is the required tool to use the shadows.
  44652. * Each light casting shadows needs to use its own ShadowGenerator.
  44653. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44654. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44655. * @param light The light object generating the shadows.
  44656. * @param useFullFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  44657. */
  44658. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  44659. private _initializeGenerator;
  44660. private _initializeShadowMap;
  44661. private _initializeBlurRTTAndPostProcesses;
  44662. private _renderForShadowMap;
  44663. private _renderSubMeshForShadowMap;
  44664. private _applyFilterValues;
  44665. /**
  44666. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44667. * @param onCompiled Callback triggered at the and of the effects compilation
  44668. * @param options Sets of optional options forcing the compilation with different modes
  44669. */
  44670. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44671. useInstances: boolean;
  44672. }>): void;
  44673. /**
  44674. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44675. * @param options Sets of optional options forcing the compilation with different modes
  44676. * @returns A promise that resolves when the compilation completes
  44677. */
  44678. forceCompilationAsync(options?: Partial<{
  44679. useInstances: boolean;
  44680. }>): Promise<void>;
  44681. /**
  44682. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44683. * @param subMesh The submesh we want to render in the shadow map
  44684. * @param useInstances Defines wether will draw in the map using instances
  44685. * @returns true if ready otherwise, false
  44686. */
  44687. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44688. /**
  44689. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44690. * @param defines Defines of the material we want to update
  44691. * @param lightIndex Index of the light in the enabled light list of the material
  44692. */
  44693. prepareDefines(defines: any, lightIndex: number): void;
  44694. /**
  44695. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44696. * defined in the generator but impacting the effect).
  44697. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44698. * @param effect The effect we are binfing the information for
  44699. */
  44700. bindShadowLight(lightIndex: string, effect: Effect): void;
  44701. /**
  44702. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44703. * (eq to shadow prjection matrix * light transform matrix)
  44704. * @returns The transform matrix used to create the shadow map
  44705. */
  44706. getTransformMatrix(): Matrix;
  44707. /**
  44708. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44709. * Cube and 2D textures for instance.
  44710. */
  44711. recreateShadowMap(): void;
  44712. private _disposeBlurPostProcesses;
  44713. private _disposeRTTandPostProcesses;
  44714. /**
  44715. * Disposes the ShadowGenerator.
  44716. * Returns nothing.
  44717. */
  44718. dispose(): void;
  44719. /**
  44720. * Serializes the shadow generator setup to a json object.
  44721. * @returns The serialized JSON object
  44722. */
  44723. serialize(): any;
  44724. /**
  44725. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44726. * @param parsedShadowGenerator The JSON object to parse
  44727. * @param scene The scene to create the shadow map for
  44728. * @returns The parsed shadow generator
  44729. */
  44730. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  44731. }
  44732. }
  44733. declare module BABYLON {
  44734. /**
  44735. * Defines the shadow generator component responsible to manage any shadow generators
  44736. * in a given scene.
  44737. */
  44738. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44739. /**
  44740. * The component name helpfull to identify the component in the list of scene components.
  44741. */
  44742. readonly name: string;
  44743. /**
  44744. * The scene the component belongs to.
  44745. */
  44746. scene: Scene;
  44747. /**
  44748. * Creates a new instance of the component for the given scene
  44749. * @param scene Defines the scene to register the component in
  44750. */
  44751. constructor(scene: Scene);
  44752. /**
  44753. * Registers the component in a given scene
  44754. */
  44755. register(): void;
  44756. /**
  44757. * Rebuilds the elements related to this component in case of
  44758. * context lost for instance.
  44759. */
  44760. rebuild(): void;
  44761. /**
  44762. * Serializes the component data to the specified json object
  44763. * @param serializationObject The object to serialize to
  44764. */
  44765. serialize(serializationObject: any): void;
  44766. /**
  44767. * Adds all the element from the container to the scene
  44768. * @param container the container holding the elements
  44769. */
  44770. addFromContainer(container: AbstractScene): void;
  44771. /**
  44772. * Removes all the elements in the container from the scene
  44773. * @param container contains the elements to remove
  44774. */
  44775. removeFromContainer(container: AbstractScene): void;
  44776. /**
  44777. * Rebuilds the elements related to this component in case of
  44778. * context lost for instance.
  44779. */
  44780. dispose(): void;
  44781. private _gatherRenderTargets;
  44782. }
  44783. }
  44784. declare module BABYLON {
  44785. }
  44786. declare module BABYLON {
  44787. /**
  44788. * Background material used to create an efficient environement around your scene.
  44789. */
  44790. class BackgroundMaterial extends PushMaterial {
  44791. /**
  44792. * Standard reflectance value at parallel view angle.
  44793. */
  44794. static StandardReflectance0: number;
  44795. /**
  44796. * Standard reflectance value at grazing angle.
  44797. */
  44798. static StandardReflectance90: number;
  44799. protected _primaryColor: Color3;
  44800. /**
  44801. * Key light Color (multiply against the environement texture)
  44802. */
  44803. primaryColor: Color3;
  44804. protected __perceptualColor: Nullable<Color3>;
  44805. /**
  44806. * Experimental Internal Use Only.
  44807. *
  44808. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44809. * This acts as a helper to set the primary color to a more "human friendly" value.
  44810. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44811. * output color as close as possible from the chosen value.
  44812. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44813. * part of lighting setup.)
  44814. */
  44815. _perceptualColor: Nullable<Color3>;
  44816. protected _primaryColorShadowLevel: float;
  44817. /**
  44818. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44819. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44820. */
  44821. primaryColorShadowLevel: float;
  44822. protected _primaryColorHighlightLevel: float;
  44823. /**
  44824. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44825. * The primary color is used at the level chosen to define what the white area would look.
  44826. */
  44827. primaryColorHighlightLevel: float;
  44828. protected _reflectionTexture: Nullable<BaseTexture>;
  44829. /**
  44830. * Reflection Texture used in the material.
  44831. * Should be author in a specific way for the best result (refer to the documentation).
  44832. */
  44833. reflectionTexture: Nullable<BaseTexture>;
  44834. protected _reflectionBlur: float;
  44835. /**
  44836. * Reflection Texture level of blur.
  44837. *
  44838. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44839. * texture twice.
  44840. */
  44841. reflectionBlur: float;
  44842. protected _diffuseTexture: Nullable<BaseTexture>;
  44843. /**
  44844. * Diffuse Texture used in the material.
  44845. * Should be author in a specific way for the best result (refer to the documentation).
  44846. */
  44847. diffuseTexture: Nullable<BaseTexture>;
  44848. protected _shadowLights: Nullable<IShadowLight[]>;
  44849. /**
  44850. * Specify the list of lights casting shadow on the material.
  44851. * All scene shadow lights will be included if null.
  44852. */
  44853. shadowLights: Nullable<IShadowLight[]>;
  44854. protected _shadowLevel: float;
  44855. /**
  44856. * Helps adjusting the shadow to a softer level if required.
  44857. * 0 means black shadows and 1 means no shadows.
  44858. */
  44859. shadowLevel: float;
  44860. protected _sceneCenter: Vector3;
  44861. /**
  44862. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44863. * It is usually zero but might be interesting to modify according to your setup.
  44864. */
  44865. sceneCenter: Vector3;
  44866. protected _opacityFresnel: boolean;
  44867. /**
  44868. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44869. * This helps ensuring a nice transition when the camera goes under the ground.
  44870. */
  44871. opacityFresnel: boolean;
  44872. protected _reflectionFresnel: boolean;
  44873. /**
  44874. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44875. * This helps adding a mirror texture on the ground.
  44876. */
  44877. reflectionFresnel: boolean;
  44878. protected _reflectionFalloffDistance: number;
  44879. /**
  44880. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44881. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44882. */
  44883. reflectionFalloffDistance: number;
  44884. protected _reflectionAmount: number;
  44885. /**
  44886. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44887. */
  44888. reflectionAmount: number;
  44889. protected _reflectionReflectance0: number;
  44890. /**
  44891. * This specifies the weight of the reflection at grazing angle.
  44892. */
  44893. reflectionReflectance0: number;
  44894. protected _reflectionReflectance90: number;
  44895. /**
  44896. * This specifies the weight of the reflection at a perpendicular point of view.
  44897. */
  44898. reflectionReflectance90: number;
  44899. /**
  44900. * Sets the reflection reflectance fresnel values according to the default standard
  44901. * empirically know to work well :-)
  44902. */
  44903. reflectionStandardFresnelWeight: number;
  44904. protected _useRGBColor: boolean;
  44905. /**
  44906. * Helps to directly use the maps channels instead of their level.
  44907. */
  44908. useRGBColor: boolean;
  44909. protected _enableNoise: boolean;
  44910. /**
  44911. * This helps reducing the banding effect that could occur on the background.
  44912. */
  44913. enableNoise: boolean;
  44914. /**
  44915. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44916. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44917. * Recommended to be keep at 1.0 except for special cases.
  44918. */
  44919. fovMultiplier: number;
  44920. private _fovMultiplier;
  44921. /**
  44922. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44923. */
  44924. useEquirectangularFOV: boolean;
  44925. private _maxSimultaneousLights;
  44926. /**
  44927. * Number of Simultaneous lights allowed on the material.
  44928. */
  44929. maxSimultaneousLights: int;
  44930. /**
  44931. * Default configuration related to image processing available in the Background Material.
  44932. */
  44933. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44934. /**
  44935. * Keep track of the image processing observer to allow dispose and replace.
  44936. */
  44937. private _imageProcessingObserver;
  44938. /**
  44939. * Attaches a new image processing configuration to the PBR Material.
  44940. * @param configuration (if null the scene configuration will be use)
  44941. */
  44942. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44943. /**
  44944. * Gets the image processing configuration used either in this material.
  44945. */
  44946. /**
  44947. * Sets the Default image processing configuration used either in the this material.
  44948. *
  44949. * If sets to null, the scene one is in use.
  44950. */
  44951. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44952. /**
  44953. * Gets wether the color curves effect is enabled.
  44954. */
  44955. /**
  44956. * Sets wether the color curves effect is enabled.
  44957. */
  44958. cameraColorCurvesEnabled: boolean;
  44959. /**
  44960. * Gets wether the color grading effect is enabled.
  44961. */
  44962. /**
  44963. * Gets wether the color grading effect is enabled.
  44964. */
  44965. cameraColorGradingEnabled: boolean;
  44966. /**
  44967. * Gets wether tonemapping is enabled or not.
  44968. */
  44969. /**
  44970. * Sets wether tonemapping is enabled or not
  44971. */
  44972. cameraToneMappingEnabled: boolean;
  44973. /**
  44974. * The camera exposure used on this material.
  44975. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44976. * This corresponds to a photographic exposure.
  44977. */
  44978. /**
  44979. * The camera exposure used on this material.
  44980. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44981. * This corresponds to a photographic exposure.
  44982. */
  44983. cameraExposure: float;
  44984. /**
  44985. * Gets The camera contrast used on this material.
  44986. */
  44987. /**
  44988. * Sets The camera contrast used on this material.
  44989. */
  44990. cameraContrast: float;
  44991. /**
  44992. * Gets the Color Grading 2D Lookup Texture.
  44993. */
  44994. /**
  44995. * Sets the Color Grading 2D Lookup Texture.
  44996. */
  44997. cameraColorGradingTexture: Nullable<BaseTexture>;
  44998. /**
  44999. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45000. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45001. * 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;
  45002. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45003. */
  45004. /**
  45005. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45006. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45007. * 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;
  45008. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45009. */
  45010. cameraColorCurves: Nullable<ColorCurves>;
  45011. /**
  45012. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45013. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45014. */
  45015. switchToBGR: boolean;
  45016. private _renderTargets;
  45017. private _reflectionControls;
  45018. private _white;
  45019. private _primaryShadowColor;
  45020. private _primaryHighlightColor;
  45021. /**
  45022. * Instantiates a Background Material in the given scene
  45023. * @param name The friendly name of the material
  45024. * @param scene The scene to add the material to
  45025. */
  45026. constructor(name: string, scene: Scene);
  45027. /**
  45028. * Gets a boolean indicating that current material needs to register RTT
  45029. */
  45030. readonly hasRenderTargetTextures: boolean;
  45031. /**
  45032. * The entire material has been created in order to prevent overdraw.
  45033. * @returns false
  45034. */
  45035. needAlphaTesting(): boolean;
  45036. /**
  45037. * The entire material has been created in order to prevent overdraw.
  45038. * @returns true if blending is enable
  45039. */
  45040. needAlphaBlending(): boolean;
  45041. /**
  45042. * Checks wether the material is ready to be rendered for a given mesh.
  45043. * @param mesh The mesh to render
  45044. * @param subMesh The submesh to check against
  45045. * @param useInstances Specify wether or not the material is used with instances
  45046. * @returns true if all the dependencies are ready (Textures, Effects...)
  45047. */
  45048. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45049. /**
  45050. * Compute the primary color according to the chosen perceptual color.
  45051. */
  45052. private _computePrimaryColorFromPerceptualColor;
  45053. /**
  45054. * Compute the highlights and shadow colors according to their chosen levels.
  45055. */
  45056. private _computePrimaryColors;
  45057. /**
  45058. * Build the uniform buffer used in the material.
  45059. */
  45060. buildUniformLayout(): void;
  45061. /**
  45062. * Unbind the material.
  45063. */
  45064. unbind(): void;
  45065. /**
  45066. * Bind only the world matrix to the material.
  45067. * @param world The world matrix to bind.
  45068. */
  45069. bindOnlyWorldMatrix(world: Matrix): void;
  45070. /**
  45071. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45072. * @param world The world matrix to bind.
  45073. * @param subMesh The submesh to bind for.
  45074. */
  45075. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45076. /**
  45077. * Dispose the material.
  45078. * @param forceDisposeEffect Force disposal of the associated effect.
  45079. * @param forceDisposeTextures Force disposal of the associated textures.
  45080. */
  45081. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45082. /**
  45083. * Clones the material.
  45084. * @param name The cloned name.
  45085. * @returns The cloned material.
  45086. */
  45087. clone(name: string): BackgroundMaterial;
  45088. /**
  45089. * Serializes the current material to its JSON representation.
  45090. * @returns The JSON representation.
  45091. */
  45092. serialize(): any;
  45093. /**
  45094. * Gets the class name of the material
  45095. * @returns "BackgroundMaterial"
  45096. */
  45097. getClassName(): string;
  45098. /**
  45099. * Parse a JSON input to create back a background material.
  45100. * @param source The JSON data to parse
  45101. * @param scene The scene to create the parsed material in
  45102. * @param rootUrl The root url of the assets the material depends upon
  45103. * @returns the instantiated BackgroundMaterial.
  45104. */
  45105. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45106. }
  45107. }
  45108. declare module BABYLON {
  45109. /**
  45110. * The Physically based material base class of BJS.
  45111. *
  45112. * This offers the main features of a standard PBR material.
  45113. * For more information, please refer to the documentation :
  45114. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45115. */
  45116. abstract class PBRBaseMaterial extends PushMaterial {
  45117. /**
  45118. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45119. */
  45120. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45121. /**
  45122. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45123. * to enhance interoperability with other engines.
  45124. */
  45125. static readonly LIGHTFALLOFF_GLTF: number;
  45126. /**
  45127. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45128. * to enhance interoperability with other materials.
  45129. */
  45130. static readonly LIGHTFALLOFF_STANDARD: number;
  45131. /**
  45132. * Intensity of the direct lights e.g. the four lights available in your scene.
  45133. * This impacts both the direct diffuse and specular highlights.
  45134. */
  45135. protected _directIntensity: number;
  45136. /**
  45137. * Intensity of the emissive part of the material.
  45138. * This helps controlling the emissive effect without modifying the emissive color.
  45139. */
  45140. protected _emissiveIntensity: number;
  45141. /**
  45142. * Intensity of the environment e.g. how much the environment will light the object
  45143. * either through harmonics for rough material or through the refelction for shiny ones.
  45144. */
  45145. protected _environmentIntensity: number;
  45146. /**
  45147. * This is a special control allowing the reduction of the specular highlights coming from the
  45148. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45149. */
  45150. protected _specularIntensity: number;
  45151. /**
  45152. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45153. */
  45154. private _lightingInfos;
  45155. /**
  45156. * Debug Control allowing disabling the bump map on this material.
  45157. */
  45158. protected _disableBumpMap: boolean;
  45159. /**
  45160. * AKA Diffuse Texture in standard nomenclature.
  45161. */
  45162. protected _albedoTexture: BaseTexture;
  45163. /**
  45164. * AKA Occlusion Texture in other nomenclature.
  45165. */
  45166. protected _ambientTexture: BaseTexture;
  45167. /**
  45168. * AKA Occlusion Texture Intensity in other nomenclature.
  45169. */
  45170. protected _ambientTextureStrength: number;
  45171. /**
  45172. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45173. * 1 means it completely occludes it
  45174. * 0 mean it has no impact
  45175. */
  45176. protected _ambientTextureImpactOnAnalyticalLights: number;
  45177. /**
  45178. * Stores the alpha values in a texture.
  45179. */
  45180. protected _opacityTexture: BaseTexture;
  45181. /**
  45182. * Stores the reflection values in a texture.
  45183. */
  45184. protected _reflectionTexture: BaseTexture;
  45185. /**
  45186. * Stores the refraction values in a texture.
  45187. */
  45188. protected _refractionTexture: BaseTexture;
  45189. /**
  45190. * Stores the emissive values in a texture.
  45191. */
  45192. protected _emissiveTexture: BaseTexture;
  45193. /**
  45194. * AKA Specular texture in other nomenclature.
  45195. */
  45196. protected _reflectivityTexture: BaseTexture;
  45197. /**
  45198. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45199. */
  45200. protected _metallicTexture: BaseTexture;
  45201. /**
  45202. * Specifies the metallic scalar of the metallic/roughness workflow.
  45203. * Can also be used to scale the metalness values of the metallic texture.
  45204. */
  45205. protected _metallic: Nullable<number>;
  45206. /**
  45207. * Specifies the roughness scalar of the metallic/roughness workflow.
  45208. * Can also be used to scale the roughness values of the metallic texture.
  45209. */
  45210. protected _roughness: Nullable<number>;
  45211. /**
  45212. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45213. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45214. */
  45215. protected _microSurfaceTexture: BaseTexture;
  45216. /**
  45217. * Stores surface normal data used to displace a mesh in a texture.
  45218. */
  45219. protected _bumpTexture: BaseTexture;
  45220. /**
  45221. * Stores the pre-calculated light information of a mesh in a texture.
  45222. */
  45223. protected _lightmapTexture: BaseTexture;
  45224. /**
  45225. * The color of a material in ambient lighting.
  45226. */
  45227. protected _ambientColor: Color3;
  45228. /**
  45229. * AKA Diffuse Color in other nomenclature.
  45230. */
  45231. protected _albedoColor: Color3;
  45232. /**
  45233. * AKA Specular Color in other nomenclature.
  45234. */
  45235. protected _reflectivityColor: Color3;
  45236. /**
  45237. * The color applied when light is reflected from a material.
  45238. */
  45239. protected _reflectionColor: Color3;
  45240. /**
  45241. * The color applied when light is emitted from a material.
  45242. */
  45243. protected _emissiveColor: Color3;
  45244. /**
  45245. * AKA Glossiness in other nomenclature.
  45246. */
  45247. protected _microSurface: number;
  45248. /**
  45249. * source material index of refraction (IOR)' / 'destination material IOR.
  45250. */
  45251. protected _indexOfRefraction: number;
  45252. /**
  45253. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  45254. */
  45255. protected _invertRefractionY: boolean;
  45256. /**
  45257. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45258. * Materials half opaque for instance using refraction could benefit from this control.
  45259. */
  45260. protected _linkRefractionWithTransparency: boolean;
  45261. /**
  45262. * Specifies that the material will use the light map as a show map.
  45263. */
  45264. protected _useLightmapAsShadowmap: boolean;
  45265. /**
  45266. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45267. * makes the reflect vector face the model (under horizon).
  45268. */
  45269. protected _useHorizonOcclusion: boolean;
  45270. /**
  45271. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45272. * too much the area relying on ambient texture to define their ambient occlusion.
  45273. */
  45274. protected _useRadianceOcclusion: boolean;
  45275. /**
  45276. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45277. */
  45278. protected _useAlphaFromAlbedoTexture: boolean;
  45279. /**
  45280. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45281. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45282. */
  45283. protected _useSpecularOverAlpha: boolean;
  45284. /**
  45285. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45286. */
  45287. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45288. /**
  45289. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45290. */
  45291. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45292. /**
  45293. * Specifies if the metallic texture contains the roughness information in its green channel.
  45294. */
  45295. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45296. /**
  45297. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45298. */
  45299. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45300. /**
  45301. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45302. */
  45303. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45304. /**
  45305. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45306. */
  45307. protected _useAmbientInGrayScale: boolean;
  45308. /**
  45309. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45310. * The material will try to infer what glossiness each pixel should be.
  45311. */
  45312. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45313. /**
  45314. * Defines the falloff type used in this material.
  45315. * It by default is Physical.
  45316. */
  45317. protected _lightFalloff: number;
  45318. /**
  45319. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45320. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45321. */
  45322. protected _useRadianceOverAlpha: boolean;
  45323. /**
  45324. * Allows using an object space normal map (instead of tangent space).
  45325. */
  45326. protected _useObjectSpaceNormalMap: boolean;
  45327. /**
  45328. * Allows using the bump map in parallax mode.
  45329. */
  45330. protected _useParallax: boolean;
  45331. /**
  45332. * Allows using the bump map in parallax occlusion mode.
  45333. */
  45334. protected _useParallaxOcclusion: boolean;
  45335. /**
  45336. * Controls the scale bias of the parallax mode.
  45337. */
  45338. protected _parallaxScaleBias: number;
  45339. /**
  45340. * If sets to true, disables all the lights affecting the material.
  45341. */
  45342. protected _disableLighting: boolean;
  45343. /**
  45344. * Number of Simultaneous lights allowed on the material.
  45345. */
  45346. protected _maxSimultaneousLights: number;
  45347. /**
  45348. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45349. */
  45350. protected _invertNormalMapX: boolean;
  45351. /**
  45352. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45353. */
  45354. protected _invertNormalMapY: boolean;
  45355. /**
  45356. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45357. */
  45358. protected _twoSidedLighting: boolean;
  45359. /**
  45360. * Defines the alpha limits in alpha test mode.
  45361. */
  45362. protected _alphaCutOff: number;
  45363. /**
  45364. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45365. */
  45366. protected _forceAlphaTest: boolean;
  45367. /**
  45368. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45369. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45370. */
  45371. protected _useAlphaFresnel: boolean;
  45372. /**
  45373. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45374. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45375. */
  45376. protected _useLinearAlphaFresnel: boolean;
  45377. /**
  45378. * The transparency mode of the material.
  45379. */
  45380. protected _transparencyMode: Nullable<number>;
  45381. /**
  45382. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45383. * from cos thetav and roughness:
  45384. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45385. */
  45386. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45387. /**
  45388. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45389. */
  45390. protected _forceIrradianceInFragment: boolean;
  45391. /**
  45392. * Force normal to face away from face.
  45393. */
  45394. protected _forceNormalForward: boolean;
  45395. /**
  45396. * Enables specular anti aliasing in the PBR shader.
  45397. * It will both interacts on the Geometry for analytical and IBL lighting.
  45398. * It also prefilter the roughness map based on the bump values.
  45399. */
  45400. protected _enableSpecularAntiAliasing: boolean;
  45401. /**
  45402. * Default configuration related to image processing available in the PBR Material.
  45403. */
  45404. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45405. /**
  45406. * Keep track of the image processing observer to allow dispose and replace.
  45407. */
  45408. private _imageProcessingObserver;
  45409. /**
  45410. * Attaches a new image processing configuration to the PBR Material.
  45411. * @param configuration
  45412. */
  45413. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45414. /**
  45415. * Stores the available render targets.
  45416. */
  45417. private _renderTargets;
  45418. /**
  45419. * Sets the global ambient color for the material used in lighting calculations.
  45420. */
  45421. private _globalAmbientColor;
  45422. /**
  45423. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45424. */
  45425. private _useLogarithmicDepth;
  45426. /**
  45427. * If set to true, no lighting calculations will be applied.
  45428. */
  45429. private _unlit;
  45430. /**
  45431. * Instantiates a new PBRMaterial instance.
  45432. *
  45433. * @param name The material name
  45434. * @param scene The scene the material will be use in.
  45435. */
  45436. constructor(name: string, scene: Scene);
  45437. /**
  45438. * Gets a boolean indicating that current material needs to register RTT
  45439. */
  45440. readonly hasRenderTargetTextures: boolean;
  45441. /**
  45442. * Gets the name of the material class.
  45443. */
  45444. getClassName(): string;
  45445. /**
  45446. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45447. */
  45448. /**
  45449. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45450. */
  45451. useLogarithmicDepth: boolean;
  45452. /**
  45453. * Gets the current transparency mode.
  45454. */
  45455. /**
  45456. * Sets the transparency mode of the material.
  45457. *
  45458. * | Value | Type | Description |
  45459. * | ----- | ----------------------------------- | ----------- |
  45460. * | 0 | OPAQUE | |
  45461. * | 1 | ALPHATEST | |
  45462. * | 2 | ALPHABLEND | |
  45463. * | 3 | ALPHATESTANDBLEND | |
  45464. *
  45465. */
  45466. transparencyMode: Nullable<number>;
  45467. /**
  45468. * Returns true if alpha blending should be disabled.
  45469. */
  45470. private readonly _disableAlphaBlending;
  45471. /**
  45472. * Specifies whether or not this material should be rendered in alpha blend mode.
  45473. */
  45474. needAlphaBlending(): boolean;
  45475. /**
  45476. * Specifies if the mesh will require alpha blending.
  45477. * @param mesh - BJS mesh.
  45478. */
  45479. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45480. /**
  45481. * Specifies whether or not this material should be rendered in alpha test mode.
  45482. */
  45483. needAlphaTesting(): boolean;
  45484. /**
  45485. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45486. */
  45487. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45488. /**
  45489. * Gets the texture used for the alpha test.
  45490. */
  45491. getAlphaTestTexture(): BaseTexture;
  45492. /**
  45493. * Stores the reflectivity values based on metallic roughness workflow.
  45494. */
  45495. private static _scaledReflectivity;
  45496. /**
  45497. * Specifies that the submesh is ready to be used.
  45498. * @param mesh - BJS mesh.
  45499. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45500. * @param useInstances - Specifies that instances should be used.
  45501. * @returns - boolean indicating that the submesh is ready or not.
  45502. */
  45503. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45504. /**
  45505. * Specifies if the material uses metallic roughness workflow.
  45506. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45507. */
  45508. isMetallicWorkflow(): boolean;
  45509. private _prepareEffect;
  45510. private _prepareDefines;
  45511. /**
  45512. * Force shader compilation
  45513. */
  45514. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45515. clipPlane: boolean;
  45516. }>): void;
  45517. /**
  45518. * Initializes the uniform buffer layout for the shader.
  45519. */
  45520. buildUniformLayout(): void;
  45521. /**
  45522. * Unbinds the textures.
  45523. */
  45524. unbind(): void;
  45525. /**
  45526. * Binds the submesh data.
  45527. * @param world - The world matrix.
  45528. * @param mesh - The BJS mesh.
  45529. * @param subMesh - A submesh of the BJS mesh.
  45530. */
  45531. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45532. /**
  45533. * Returns the animatable textures.
  45534. * @returns - Array of animatable textures.
  45535. */
  45536. getAnimatables(): IAnimatable[];
  45537. /**
  45538. * Returns the texture used for reflections.
  45539. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45540. */
  45541. private _getReflectionTexture;
  45542. /**
  45543. * Returns the texture used for refraction or null if none is used.
  45544. * @returns - Refection texture if present. If no refraction texture and refraction
  45545. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45546. */
  45547. private _getRefractionTexture;
  45548. /**
  45549. * Disposes the resources of the material.
  45550. * @param forceDisposeEffect - Forces the disposal of effects.
  45551. * @param forceDisposeTextures - Forces the disposal of all textures.
  45552. */
  45553. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45554. }
  45555. }
  45556. declare module BABYLON {
  45557. /**
  45558. * The Physically based simple base material of BJS.
  45559. *
  45560. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45561. * It is used as the base class for both the specGloss and metalRough conventions.
  45562. */
  45563. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45564. /**
  45565. * Number of Simultaneous lights allowed on the material.
  45566. */
  45567. maxSimultaneousLights: number;
  45568. /**
  45569. * If sets to true, disables all the lights affecting the material.
  45570. */
  45571. disableLighting: boolean;
  45572. /**
  45573. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45574. */
  45575. environmentTexture: BaseTexture;
  45576. /**
  45577. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45578. */
  45579. invertNormalMapX: boolean;
  45580. /**
  45581. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45582. */
  45583. invertNormalMapY: boolean;
  45584. /**
  45585. * Normal map used in the model.
  45586. */
  45587. normalTexture: BaseTexture;
  45588. /**
  45589. * Emissivie color used to self-illuminate the model.
  45590. */
  45591. emissiveColor: Color3;
  45592. /**
  45593. * Emissivie texture used to self-illuminate the model.
  45594. */
  45595. emissiveTexture: BaseTexture;
  45596. /**
  45597. * Occlusion Channel Strenght.
  45598. */
  45599. occlusionStrength: number;
  45600. /**
  45601. * Occlusion Texture of the material (adding extra occlusion effects).
  45602. */
  45603. occlusionTexture: BaseTexture;
  45604. /**
  45605. * Defines the alpha limits in alpha test mode.
  45606. */
  45607. alphaCutOff: number;
  45608. /**
  45609. * Gets the current double sided mode.
  45610. */
  45611. /**
  45612. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45613. */
  45614. doubleSided: boolean;
  45615. /**
  45616. * Stores the pre-calculated light information of a mesh in a texture.
  45617. */
  45618. lightmapTexture: BaseTexture;
  45619. /**
  45620. * If true, the light map contains occlusion information instead of lighting info.
  45621. */
  45622. useLightmapAsShadowmap: boolean;
  45623. /**
  45624. * Return the active textures of the material.
  45625. */
  45626. getActiveTextures(): BaseTexture[];
  45627. hasTexture(texture: BaseTexture): boolean;
  45628. /**
  45629. * Instantiates a new PBRMaterial instance.
  45630. *
  45631. * @param name The material name
  45632. * @param scene The scene the material will be use in.
  45633. */
  45634. constructor(name: string, scene: Scene);
  45635. getClassName(): string;
  45636. }
  45637. }
  45638. declare module BABYLON {
  45639. /**
  45640. * The Physically based material of BJS.
  45641. *
  45642. * This offers the main features of a standard PBR material.
  45643. * For more information, please refer to the documentation :
  45644. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45645. */
  45646. class PBRMaterial extends PBRBaseMaterial {
  45647. /**
  45648. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45649. */
  45650. static readonly PBRMATERIAL_OPAQUE: number;
  45651. /**
  45652. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45653. */
  45654. static readonly PBRMATERIAL_ALPHATEST: number;
  45655. /**
  45656. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45657. */
  45658. static readonly PBRMATERIAL_ALPHABLEND: number;
  45659. /**
  45660. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45661. * They are also discarded below the alpha cutoff threshold to improve performances.
  45662. */
  45663. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45664. /**
  45665. * Defines the default value of how much AO map is occluding the analytical lights
  45666. * (point spot...).
  45667. */
  45668. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45669. /**
  45670. * Intensity of the direct lights e.g. the four lights available in your scene.
  45671. * This impacts both the direct diffuse and specular highlights.
  45672. */
  45673. directIntensity: number;
  45674. /**
  45675. * Intensity of the emissive part of the material.
  45676. * This helps controlling the emissive effect without modifying the emissive color.
  45677. */
  45678. emissiveIntensity: number;
  45679. /**
  45680. * Intensity of the environment e.g. how much the environment will light the object
  45681. * either through harmonics for rough material or through the refelction for shiny ones.
  45682. */
  45683. environmentIntensity: number;
  45684. /**
  45685. * This is a special control allowing the reduction of the specular highlights coming from the
  45686. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45687. */
  45688. specularIntensity: number;
  45689. /**
  45690. * Debug Control allowing disabling the bump map on this material.
  45691. */
  45692. disableBumpMap: boolean;
  45693. /**
  45694. * AKA Diffuse Texture in standard nomenclature.
  45695. */
  45696. albedoTexture: BaseTexture;
  45697. /**
  45698. * AKA Occlusion Texture in other nomenclature.
  45699. */
  45700. ambientTexture: BaseTexture;
  45701. /**
  45702. * AKA Occlusion Texture Intensity in other nomenclature.
  45703. */
  45704. ambientTextureStrength: number;
  45705. /**
  45706. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45707. * 1 means it completely occludes it
  45708. * 0 mean it has no impact
  45709. */
  45710. ambientTextureImpactOnAnalyticalLights: number;
  45711. /**
  45712. * Stores the alpha values in a texture.
  45713. */
  45714. opacityTexture: BaseTexture;
  45715. /**
  45716. * Stores the reflection values in a texture.
  45717. */
  45718. reflectionTexture: Nullable<BaseTexture>;
  45719. /**
  45720. * Stores the emissive values in a texture.
  45721. */
  45722. emissiveTexture: BaseTexture;
  45723. /**
  45724. * AKA Specular texture in other nomenclature.
  45725. */
  45726. reflectivityTexture: BaseTexture;
  45727. /**
  45728. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45729. */
  45730. metallicTexture: BaseTexture;
  45731. /**
  45732. * Specifies the metallic scalar of the metallic/roughness workflow.
  45733. * Can also be used to scale the metalness values of the metallic texture.
  45734. */
  45735. metallic: Nullable<number>;
  45736. /**
  45737. * Specifies the roughness scalar of the metallic/roughness workflow.
  45738. * Can also be used to scale the roughness values of the metallic texture.
  45739. */
  45740. roughness: Nullable<number>;
  45741. /**
  45742. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45743. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45744. */
  45745. microSurfaceTexture: BaseTexture;
  45746. /**
  45747. * Stores surface normal data used to displace a mesh in a texture.
  45748. */
  45749. bumpTexture: BaseTexture;
  45750. /**
  45751. * Stores the pre-calculated light information of a mesh in a texture.
  45752. */
  45753. lightmapTexture: BaseTexture;
  45754. /**
  45755. * Stores the refracted light information in a texture.
  45756. */
  45757. refractionTexture: BaseTexture;
  45758. /**
  45759. * The color of a material in ambient lighting.
  45760. */
  45761. ambientColor: Color3;
  45762. /**
  45763. * AKA Diffuse Color in other nomenclature.
  45764. */
  45765. albedoColor: Color3;
  45766. /**
  45767. * AKA Specular Color in other nomenclature.
  45768. */
  45769. reflectivityColor: Color3;
  45770. /**
  45771. * The color reflected from the material.
  45772. */
  45773. reflectionColor: Color3;
  45774. /**
  45775. * The color emitted from the material.
  45776. */
  45777. emissiveColor: Color3;
  45778. /**
  45779. * AKA Glossiness in other nomenclature.
  45780. */
  45781. microSurface: number;
  45782. /**
  45783. * source material index of refraction (IOR)' / 'destination material IOR.
  45784. */
  45785. indexOfRefraction: number;
  45786. /**
  45787. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  45788. */
  45789. invertRefractionY: boolean;
  45790. /**
  45791. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45792. * Materials half opaque for instance using refraction could benefit from this control.
  45793. */
  45794. linkRefractionWithTransparency: boolean;
  45795. /**
  45796. * If true, the light map contains occlusion information instead of lighting info.
  45797. */
  45798. useLightmapAsShadowmap: boolean;
  45799. /**
  45800. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45801. */
  45802. useAlphaFromAlbedoTexture: boolean;
  45803. /**
  45804. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45805. */
  45806. forceAlphaTest: boolean;
  45807. /**
  45808. * Defines the alpha limits in alpha test mode.
  45809. */
  45810. alphaCutOff: number;
  45811. /**
  45812. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45813. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45814. */
  45815. useSpecularOverAlpha: boolean;
  45816. /**
  45817. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45818. */
  45819. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45820. /**
  45821. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45822. */
  45823. useRoughnessFromMetallicTextureAlpha: boolean;
  45824. /**
  45825. * Specifies if the metallic texture contains the roughness information in its green channel.
  45826. */
  45827. useRoughnessFromMetallicTextureGreen: boolean;
  45828. /**
  45829. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45830. */
  45831. useMetallnessFromMetallicTextureBlue: boolean;
  45832. /**
  45833. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45834. */
  45835. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45836. /**
  45837. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45838. */
  45839. useAmbientInGrayScale: boolean;
  45840. /**
  45841. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45842. * The material will try to infer what glossiness each pixel should be.
  45843. */
  45844. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45845. /**
  45846. * BJS is using an harcoded light falloff based on a manually sets up range.
  45847. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45848. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45849. */
  45850. /**
  45851. * BJS is using an harcoded light falloff based on a manually sets up range.
  45852. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45853. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45854. */
  45855. usePhysicalLightFalloff: boolean;
  45856. /**
  45857. * In order to support the falloff compatibility with gltf, a special mode has been added
  45858. * to reproduce the gltf light falloff.
  45859. */
  45860. /**
  45861. * In order to support the falloff compatibility with gltf, a special mode has been added
  45862. * to reproduce the gltf light falloff.
  45863. */
  45864. useGLTFLightFalloff: boolean;
  45865. /**
  45866. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45867. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45868. */
  45869. useRadianceOverAlpha: boolean;
  45870. /**
  45871. * Allows using an object space normal map (instead of tangent space).
  45872. */
  45873. useObjectSpaceNormalMap: boolean;
  45874. /**
  45875. * Allows using the bump map in parallax mode.
  45876. */
  45877. useParallax: boolean;
  45878. /**
  45879. * Allows using the bump map in parallax occlusion mode.
  45880. */
  45881. useParallaxOcclusion: boolean;
  45882. /**
  45883. * Controls the scale bias of the parallax mode.
  45884. */
  45885. parallaxScaleBias: number;
  45886. /**
  45887. * If sets to true, disables all the lights affecting the material.
  45888. */
  45889. disableLighting: boolean;
  45890. /**
  45891. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45892. */
  45893. forceIrradianceInFragment: boolean;
  45894. /**
  45895. * Number of Simultaneous lights allowed on the material.
  45896. */
  45897. maxSimultaneousLights: number;
  45898. /**
  45899. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45900. */
  45901. invertNormalMapX: boolean;
  45902. /**
  45903. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45904. */
  45905. invertNormalMapY: boolean;
  45906. /**
  45907. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45908. */
  45909. twoSidedLighting: boolean;
  45910. /**
  45911. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45912. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45913. */
  45914. useAlphaFresnel: boolean;
  45915. /**
  45916. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45917. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45918. */
  45919. useLinearAlphaFresnel: boolean;
  45920. /**
  45921. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45922. * And/Or occlude the blended part.
  45923. */
  45924. environmentBRDFTexture: Nullable<BaseTexture>;
  45925. /**
  45926. * Force normal to face away from face.
  45927. */
  45928. forceNormalForward: boolean;
  45929. /**
  45930. * Enables specular anti aliasing in the PBR shader.
  45931. * It will both interacts on the Geometry for analytical and IBL lighting.
  45932. * It also prefilter the roughness map based on the bump values.
  45933. */
  45934. enableSpecularAntiAliasing: boolean;
  45935. /**
  45936. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45937. * makes the reflect vector face the model (under horizon).
  45938. */
  45939. useHorizonOcclusion: boolean;
  45940. /**
  45941. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45942. * too much the area relying on ambient texture to define their ambient occlusion.
  45943. */
  45944. useRadianceOcclusion: boolean;
  45945. /**
  45946. * If set to true, no lighting calculations will be applied.
  45947. */
  45948. unlit: boolean;
  45949. /**
  45950. * Gets the image processing configuration used either in this material.
  45951. */
  45952. /**
  45953. * Sets the Default image processing configuration used either in the this material.
  45954. *
  45955. * If sets to null, the scene one is in use.
  45956. */
  45957. imageProcessingConfiguration: ImageProcessingConfiguration;
  45958. /**
  45959. * Gets wether the color curves effect is enabled.
  45960. */
  45961. /**
  45962. * Sets wether the color curves effect is enabled.
  45963. */
  45964. cameraColorCurvesEnabled: boolean;
  45965. /**
  45966. * Gets wether the color grading effect is enabled.
  45967. */
  45968. /**
  45969. * Gets wether the color grading effect is enabled.
  45970. */
  45971. cameraColorGradingEnabled: boolean;
  45972. /**
  45973. * Gets wether tonemapping is enabled or not.
  45974. */
  45975. /**
  45976. * Sets wether tonemapping is enabled or not
  45977. */
  45978. cameraToneMappingEnabled: boolean;
  45979. /**
  45980. * The camera exposure used on this material.
  45981. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45982. * This corresponds to a photographic exposure.
  45983. */
  45984. /**
  45985. * The camera exposure used on this material.
  45986. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45987. * This corresponds to a photographic exposure.
  45988. */
  45989. cameraExposure: number;
  45990. /**
  45991. * Gets The camera contrast used on this material.
  45992. */
  45993. /**
  45994. * Sets The camera contrast used on this material.
  45995. */
  45996. cameraContrast: number;
  45997. /**
  45998. * Gets the Color Grading 2D Lookup Texture.
  45999. */
  46000. /**
  46001. * Sets the Color Grading 2D Lookup Texture.
  46002. */
  46003. cameraColorGradingTexture: Nullable<BaseTexture>;
  46004. /**
  46005. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46006. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46007. * 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;
  46008. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46009. */
  46010. /**
  46011. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46012. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46013. * 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;
  46014. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46015. */
  46016. cameraColorCurves: Nullable<ColorCurves>;
  46017. /**
  46018. * Instantiates a new PBRMaterial instance.
  46019. *
  46020. * @param name The material name
  46021. * @param scene The scene the material will be use in.
  46022. */
  46023. constructor(name: string, scene: Scene);
  46024. /**
  46025. * Returns the name of this material class.
  46026. */
  46027. getClassName(): string;
  46028. /**
  46029. * Returns an array of the actively used textures.
  46030. * @returns - Array of BaseTextures
  46031. */
  46032. getActiveTextures(): BaseTexture[];
  46033. /**
  46034. * Checks to see if a texture is used in the material.
  46035. * @param texture - Base texture to use.
  46036. * @returns - Boolean specifying if a texture is used in the material.
  46037. */
  46038. hasTexture(texture: BaseTexture): boolean;
  46039. /**
  46040. * Makes a duplicate of the current material.
  46041. * @param name - name to use for the new material.
  46042. */
  46043. clone(name: string): PBRMaterial;
  46044. /**
  46045. * Serializes this PBR Material.
  46046. * @returns - An object with the serialized material.
  46047. */
  46048. serialize(): any;
  46049. /**
  46050. * Parses a PBR Material from a serialized object.
  46051. * @param source - Serialized object.
  46052. * @param scene - BJS scene instance.
  46053. * @param rootUrl - url for the scene object
  46054. * @returns - PBRMaterial
  46055. */
  46056. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46057. }
  46058. }
  46059. declare module BABYLON {
  46060. /**
  46061. * The PBR material of BJS following the metal roughness convention.
  46062. *
  46063. * This fits to the PBR convention in the GLTF definition:
  46064. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  46065. */
  46066. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  46067. /**
  46068. * The base color has two different interpretations depending on the value of metalness.
  46069. * When the material is a metal, the base color is the specific measured reflectance value
  46070. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  46071. * of the material.
  46072. */
  46073. baseColor: Color3;
  46074. /**
  46075. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  46076. * well as opacity information in the alpha channel.
  46077. */
  46078. baseTexture: BaseTexture;
  46079. /**
  46080. * Specifies the metallic scalar value of the material.
  46081. * Can also be used to scale the metalness values of the metallic texture.
  46082. */
  46083. metallic: number;
  46084. /**
  46085. * Specifies the roughness scalar value of the material.
  46086. * Can also be used to scale the roughness values of the metallic texture.
  46087. */
  46088. roughness: number;
  46089. /**
  46090. * Texture containing both the metallic value in the B channel and the
  46091. * roughness value in the G channel to keep better precision.
  46092. */
  46093. metallicRoughnessTexture: BaseTexture;
  46094. /**
  46095. * Instantiates a new PBRMetalRoughnessMaterial instance.
  46096. *
  46097. * @param name The material name
  46098. * @param scene The scene the material will be use in.
  46099. */
  46100. constructor(name: string, scene: Scene);
  46101. /**
  46102. * Return the currrent class name of the material.
  46103. */
  46104. getClassName(): string;
  46105. /**
  46106. * Return the active textures of the material.
  46107. */
  46108. getActiveTextures(): BaseTexture[];
  46109. /**
  46110. * Checks to see if a texture is used in the material.
  46111. * @param texture - Base texture to use.
  46112. * @returns - Boolean specifying if a texture is used in the material.
  46113. */
  46114. hasTexture(texture: BaseTexture): boolean;
  46115. /**
  46116. * Makes a duplicate of the current material.
  46117. * @param name - name to use for the new material.
  46118. */
  46119. clone(name: string): PBRMetallicRoughnessMaterial;
  46120. /**
  46121. * Serialize the material to a parsable JSON object.
  46122. */
  46123. serialize(): any;
  46124. /**
  46125. * Parses a JSON object correponding to the serialize function.
  46126. */
  46127. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  46128. }
  46129. }
  46130. declare module BABYLON {
  46131. /**
  46132. * The PBR material of BJS following the specular glossiness convention.
  46133. *
  46134. * This fits to the PBR convention in the GLTF definition:
  46135. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  46136. */
  46137. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  46138. /**
  46139. * Specifies the diffuse color of the material.
  46140. */
  46141. diffuseColor: Color3;
  46142. /**
  46143. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  46144. * channel.
  46145. */
  46146. diffuseTexture: BaseTexture;
  46147. /**
  46148. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  46149. */
  46150. specularColor: Color3;
  46151. /**
  46152. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  46153. */
  46154. glossiness: number;
  46155. /**
  46156. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  46157. */
  46158. specularGlossinessTexture: BaseTexture;
  46159. /**
  46160. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  46161. *
  46162. * @param name The material name
  46163. * @param scene The scene the material will be use in.
  46164. */
  46165. constructor(name: string, scene: Scene);
  46166. /**
  46167. * Return the currrent class name of the material.
  46168. */
  46169. getClassName(): string;
  46170. /**
  46171. * Return the active textures of the material.
  46172. */
  46173. getActiveTextures(): BaseTexture[];
  46174. /**
  46175. * Checks to see if a texture is used in the material.
  46176. * @param texture - Base texture to use.
  46177. * @returns - Boolean specifying if a texture is used in the material.
  46178. */
  46179. hasTexture(texture: BaseTexture): boolean;
  46180. /**
  46181. * Makes a duplicate of the current material.
  46182. * @param name - name to use for the new material.
  46183. */
  46184. clone(name: string): PBRSpecularGlossinessMaterial;
  46185. /**
  46186. * Serialize the material to a parsable JSON object.
  46187. */
  46188. serialize(): any;
  46189. /**
  46190. * Parses a JSON object correponding to the serialize function.
  46191. */
  46192. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  46193. }
  46194. }
  46195. declare module BABYLON {
  46196. /**
  46197. * Base class of all the textures in babylon.
  46198. * It groups all the common properties the materials, post process, lights... might need
  46199. * in order to make a correct use of the texture.
  46200. */
  46201. class BaseTexture {
  46202. /**
  46203. * Default anisotropic filtering level for the application.
  46204. * It is set to 4 as a good tradeoff between perf and quality.
  46205. */
  46206. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  46207. /**
  46208. * Gets or sets the unique id of the texture
  46209. */
  46210. uniqueId: number;
  46211. /**
  46212. * Define the name of the texture.
  46213. */
  46214. name: string;
  46215. /**
  46216. * Gets or sets an object used to store user defined information.
  46217. */
  46218. metadata: any;
  46219. private _hasAlpha;
  46220. /**
  46221. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  46222. */
  46223. hasAlpha: boolean;
  46224. /**
  46225. * Defines if the alpha value should be determined via the rgb values.
  46226. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  46227. */
  46228. getAlphaFromRGB: boolean;
  46229. /**
  46230. * Intensity or strength of the texture.
  46231. * It is commonly used by materials to fine tune the intensity of the texture
  46232. */
  46233. level: number;
  46234. /**
  46235. * Define the UV chanel to use starting from 0 and defaulting to 0.
  46236. * This is part of the texture as textures usually maps to one uv set.
  46237. */
  46238. coordinatesIndex: number;
  46239. private _coordinatesMode;
  46240. /**
  46241. * How a texture is mapped.
  46242. *
  46243. * | Value | Type | Description |
  46244. * | ----- | ----------------------------------- | ----------- |
  46245. * | 0 | EXPLICIT_MODE | |
  46246. * | 1 | SPHERICAL_MODE | |
  46247. * | 2 | PLANAR_MODE | |
  46248. * | 3 | CUBIC_MODE | |
  46249. * | 4 | PROJECTION_MODE | |
  46250. * | 5 | SKYBOX_MODE | |
  46251. * | 6 | INVCUBIC_MODE | |
  46252. * | 7 | EQUIRECTANGULAR_MODE | |
  46253. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  46254. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  46255. */
  46256. coordinatesMode: number;
  46257. /**
  46258. * | Value | Type | Description |
  46259. * | ----- | ------------------ | ----------- |
  46260. * | 0 | CLAMP_ADDRESSMODE | |
  46261. * | 1 | WRAP_ADDRESSMODE | |
  46262. * | 2 | MIRROR_ADDRESSMODE | |
  46263. */
  46264. wrapU: number;
  46265. /**
  46266. * | Value | Type | Description |
  46267. * | ----- | ------------------ | ----------- |
  46268. * | 0 | CLAMP_ADDRESSMODE | |
  46269. * | 1 | WRAP_ADDRESSMODE | |
  46270. * | 2 | MIRROR_ADDRESSMODE | |
  46271. */
  46272. wrapV: number;
  46273. /**
  46274. * | Value | Type | Description |
  46275. * | ----- | ------------------ | ----------- |
  46276. * | 0 | CLAMP_ADDRESSMODE | |
  46277. * | 1 | WRAP_ADDRESSMODE | |
  46278. * | 2 | MIRROR_ADDRESSMODE | |
  46279. */
  46280. wrapR: number;
  46281. /**
  46282. * With compliant hardware and browser (supporting anisotropic filtering)
  46283. * this defines the level of anisotropic filtering in the texture.
  46284. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  46285. */
  46286. anisotropicFilteringLevel: number;
  46287. /**
  46288. * Define if the texture is a cube texture or if false a 2d texture.
  46289. */
  46290. isCube: boolean;
  46291. /**
  46292. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  46293. */
  46294. is3D: boolean;
  46295. /**
  46296. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  46297. * HDR texture are usually stored in linear space.
  46298. * This only impacts the PBR and Background materials
  46299. */
  46300. gammaSpace: boolean;
  46301. /**
  46302. * Gets whether or not the texture contains RGBD data.
  46303. */
  46304. readonly isRGBD: boolean;
  46305. /**
  46306. * Is Z inverted in the texture (useful in a cube texture).
  46307. */
  46308. invertZ: boolean;
  46309. /**
  46310. * @hidden
  46311. */
  46312. lodLevelInAlpha: boolean;
  46313. /**
  46314. * With prefiltered texture, defined the offset used during the prefiltering steps.
  46315. */
  46316. lodGenerationOffset: number;
  46317. /**
  46318. * With prefiltered texture, defined the scale used during the prefiltering steps.
  46319. */
  46320. lodGenerationScale: number;
  46321. /**
  46322. * Define if the texture is a render target.
  46323. */
  46324. isRenderTarget: boolean;
  46325. /**
  46326. * Define the unique id of the texture in the scene.
  46327. */
  46328. readonly uid: string;
  46329. /**
  46330. * Return a string representation of the texture.
  46331. * @returns the texture as a string
  46332. */
  46333. toString(): string;
  46334. /**
  46335. * Get the class name of the texture.
  46336. * @returns "BaseTexture"
  46337. */
  46338. getClassName(): string;
  46339. /**
  46340. * Define the list of animation attached to the texture.
  46341. */
  46342. animations: Animation[];
  46343. /**
  46344. * An event triggered when the texture is disposed.
  46345. */
  46346. onDisposeObservable: Observable<BaseTexture>;
  46347. private _onDisposeObserver;
  46348. /**
  46349. * Callback triggered when the texture has been disposed.
  46350. * Kept for back compatibility, you can use the onDisposeObservable instead.
  46351. */
  46352. onDispose: () => void;
  46353. /**
  46354. * Define the current state of the loading sequence when in delayed load mode.
  46355. */
  46356. delayLoadState: number;
  46357. private _scene;
  46358. /** @hidden */
  46359. _texture: Nullable<InternalTexture>;
  46360. private _uid;
  46361. /**
  46362. * Define if the texture is preventinga material to render or not.
  46363. * If not and the texture is not ready, the engine will use a default black texture instead.
  46364. */
  46365. readonly isBlocking: boolean;
  46366. /**
  46367. * Instantiates a new BaseTexture.
  46368. * Base class of all the textures in babylon.
  46369. * It groups all the common properties the materials, post process, lights... might need
  46370. * in order to make a correct use of the texture.
  46371. * @param scene Define the scene the texture blongs to
  46372. */
  46373. constructor(scene: Nullable<Scene>);
  46374. /**
  46375. * Get the scene the texture belongs to.
  46376. * @returns the scene or null if undefined
  46377. */
  46378. getScene(): Nullable<Scene>;
  46379. /**
  46380. * Get the texture transform matrix used to offset tile the texture for istance.
  46381. * @returns the transformation matrix
  46382. */
  46383. getTextureMatrix(): Matrix;
  46384. /**
  46385. * Get the texture reflection matrix used to rotate/transform the reflection.
  46386. * @returns the reflection matrix
  46387. */
  46388. getReflectionTextureMatrix(): Matrix;
  46389. /**
  46390. * Get the underlying lower level texture from Babylon.
  46391. * @returns the insternal texture
  46392. */
  46393. getInternalTexture(): Nullable<InternalTexture>;
  46394. /**
  46395. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  46396. * @returns true if ready or not blocking
  46397. */
  46398. isReadyOrNotBlocking(): boolean;
  46399. /**
  46400. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  46401. * @returns true if fully ready
  46402. */
  46403. isReady(): boolean;
  46404. private _cachedSize;
  46405. /**
  46406. * Get the size of the texture.
  46407. * @returns the texture size.
  46408. */
  46409. getSize(): ISize;
  46410. /**
  46411. * Get the base size of the texture.
  46412. * It can be different from the size if the texture has been resized for POT for instance
  46413. * @returns the base size
  46414. */
  46415. getBaseSize(): ISize;
  46416. /**
  46417. * Scales the texture if is `canRescale()`
  46418. * @param ratio the resize factor we want to use to rescale
  46419. */
  46420. scale(ratio: number): void;
  46421. /**
  46422. * Get if the texture can rescale.
  46423. */
  46424. readonly canRescale: boolean;
  46425. /** @hidden */
  46426. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  46427. /** @hidden */
  46428. _rebuild(): void;
  46429. /**
  46430. * Triggers the load sequence in delayed load mode.
  46431. */
  46432. delayLoad(): void;
  46433. /**
  46434. * Clones the texture.
  46435. * @returns the cloned texture
  46436. */
  46437. clone(): Nullable<BaseTexture>;
  46438. /**
  46439. * Get the texture underlying type (INT, FLOAT...)
  46440. */
  46441. readonly textureType: number;
  46442. /**
  46443. * Get the texture underlying format (RGB, RGBA...)
  46444. */
  46445. readonly textureFormat: number;
  46446. /**
  46447. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  46448. * This will returns an RGBA array buffer containing either in values (0-255) or
  46449. * float values (0-1) depending of the underlying buffer type.
  46450. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  46451. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  46452. * @param buffer defines a user defined buffer to fill with data (can be null)
  46453. * @returns The Array buffer containing the pixels data.
  46454. */
  46455. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  46456. /**
  46457. * Release and destroy the underlying lower level texture aka internalTexture.
  46458. */
  46459. releaseInternalTexture(): void;
  46460. /**
  46461. * Get the polynomial representation of the texture data.
  46462. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46463. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46464. */
  46465. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46466. /** @hidden */
  46467. readonly _lodTextureHigh: Nullable<BaseTexture>;
  46468. /** @hidden */
  46469. readonly _lodTextureMid: Nullable<BaseTexture>;
  46470. /** @hidden */
  46471. readonly _lodTextureLow: Nullable<BaseTexture>;
  46472. /**
  46473. * Dispose the texture and release its associated resources.
  46474. */
  46475. dispose(): void;
  46476. /**
  46477. * Serialize the texture into a JSON representation that can be parsed later on.
  46478. * @returns the JSON representation of the texture
  46479. */
  46480. serialize(): any;
  46481. /**
  46482. * Helper function to be called back once a list of texture contains only ready textures.
  46483. * @param textures Define the list of textures to wait for
  46484. * @param callback Define the callback triggered once the entire list will be ready
  46485. */
  46486. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  46487. }
  46488. }
  46489. declare module BABYLON {
  46490. /**
  46491. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46492. * It can help converting any input color in a desired output one. This can then be used to create effects
  46493. * from sepia, black and white to sixties or futuristic rendering...
  46494. *
  46495. * The only supported format is currently 3dl.
  46496. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46497. */
  46498. class ColorGradingTexture extends BaseTexture {
  46499. /**
  46500. * The current texture matrix. (will always be identity in color grading texture)
  46501. */
  46502. private _textureMatrix;
  46503. /**
  46504. * The texture URL.
  46505. */
  46506. url: string;
  46507. /**
  46508. * Empty line regex stored for GC.
  46509. */
  46510. private static _noneEmptyLineRegex;
  46511. private _engine;
  46512. /**
  46513. * Instantiates a ColorGradingTexture from the following parameters.
  46514. *
  46515. * @param url The location of the color gradind data (currently only supporting 3dl)
  46516. * @param scene The scene the texture will be used in
  46517. */
  46518. constructor(url: string, scene: Scene);
  46519. /**
  46520. * Returns the texture matrix used in most of the material.
  46521. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46522. */
  46523. getTextureMatrix(): Matrix;
  46524. /**
  46525. * Occurs when the file being loaded is a .3dl LUT file.
  46526. */
  46527. private load3dlTexture;
  46528. /**
  46529. * Starts the loading process of the texture.
  46530. */
  46531. private loadTexture;
  46532. /**
  46533. * Clones the color gradind texture.
  46534. */
  46535. clone(): ColorGradingTexture;
  46536. /**
  46537. * Called during delayed load for textures.
  46538. */
  46539. delayLoad(): void;
  46540. /**
  46541. * Parses a color grading texture serialized by Babylon.
  46542. * @param parsedTexture The texture information being parsedTexture
  46543. * @param scene The scene to load the texture in
  46544. * @param rootUrl The root url of the data assets to load
  46545. * @return A color gradind texture
  46546. */
  46547. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  46548. /**
  46549. * Serializes the LUT texture to json format.
  46550. */
  46551. serialize(): any;
  46552. }
  46553. }
  46554. declare module BABYLON {
  46555. /**
  46556. * Class for creating a cube texture
  46557. */
  46558. class CubeTexture extends BaseTexture {
  46559. /**
  46560. * The url of the texture
  46561. */
  46562. url: string;
  46563. /**
  46564. * Gets or sets the center of the bounding box associated with the cube texture.
  46565. * It must define where the camera used to render the texture was set
  46566. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46567. */
  46568. boundingBoxPosition: Vector3;
  46569. private _boundingBoxSize;
  46570. /**
  46571. * Gets or sets the size of the bounding box associated with the cube texture
  46572. * When defined, the cubemap will switch to local mode
  46573. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46574. * @example https://www.babylonjs-playground.com/#RNASML
  46575. */
  46576. /**
  46577. * Returns the bounding box size
  46578. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46579. */
  46580. boundingBoxSize: Vector3;
  46581. protected _rotationY: number;
  46582. /**
  46583. * Sets texture matrix rotation angle around Y axis in radians.
  46584. */
  46585. /**
  46586. * Gets texture matrix rotation angle around Y axis radians.
  46587. */
  46588. rotationY: number;
  46589. private _noMipmap;
  46590. private _files;
  46591. private _extensions;
  46592. private _textureMatrix;
  46593. private _format;
  46594. private _createPolynomials;
  46595. /** @hidden */
  46596. readonly _prefiltered: boolean;
  46597. /**
  46598. * Creates a cube texture from an array of image urls
  46599. * @param files defines an array of image urls
  46600. * @param scene defines the hosting scene
  46601. * @param noMipmap specifies if mip maps are not used
  46602. * @returns a cube texture
  46603. */
  46604. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  46605. /**
  46606. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  46607. * @param url defines the url of the prefiltered texture
  46608. * @param scene defines the scene the texture is attached to
  46609. * @param forcedExtension defines the extension of the file if different from the url
  46610. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46611. * @return the prefiltered texture
  46612. */
  46613. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  46614. /**
  46615. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  46616. * as prefiltered data.
  46617. * @param rootUrl defines the url of the texture or the root name of the six images
  46618. * @param scene defines the scene the texture is attached to
  46619. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  46620. * @param noMipmap defines if mipmaps should be created or not
  46621. * @param files defines the six files to load for the different faces
  46622. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  46623. * @param onError defines a callback triggered in case of error during load
  46624. * @param format defines the internal format to use for the texture once loaded
  46625. * @param prefiltered defines whether or not the texture is created from prefiltered data
  46626. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  46627. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46628. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46629. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46630. * @return the cube texture
  46631. */
  46632. 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);
  46633. /**
  46634. * Delays loading of the cube texture
  46635. */
  46636. delayLoad(): void;
  46637. /**
  46638. * Returns the reflection texture matrix
  46639. * @returns the reflection texture matrix
  46640. */
  46641. getReflectionTextureMatrix(): Matrix;
  46642. /**
  46643. * Sets the reflection texture matrix
  46644. * @param value Reflection texture matrix
  46645. */
  46646. setReflectionTextureMatrix(value: Matrix): void;
  46647. /**
  46648. * Parses text to create a cube texture
  46649. * @param parsedTexture define the serialized text to read from
  46650. * @param scene defines the hosting scene
  46651. * @param rootUrl defines the root url of the cube texture
  46652. * @returns a cube texture
  46653. */
  46654. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  46655. /**
  46656. * Makes a clone, or deep copy, of the cube texture
  46657. * @returns a new cube texture
  46658. */
  46659. clone(): CubeTexture;
  46660. }
  46661. }
  46662. declare module BABYLON {
  46663. /**
  46664. * A class extending Texture allowing drawing on a texture
  46665. * @see http://doc.babylonjs.com/how_to/dynamictexture
  46666. */
  46667. class DynamicTexture extends Texture {
  46668. private _generateMipMaps;
  46669. private _canvas;
  46670. private _context;
  46671. private _engine;
  46672. /**
  46673. * Creates a DynamicTexture
  46674. * @param name defines the name of the texture
  46675. * @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
  46676. * @param scene defines the scene where you want the texture
  46677. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46678. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46679. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  46680. */
  46681. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46682. /**
  46683. * Gets the current state of canRescale
  46684. */
  46685. readonly canRescale: boolean;
  46686. private _recreate;
  46687. /**
  46688. * Scales the texture
  46689. * @param ratio the scale factor to apply to both width and height
  46690. */
  46691. scale(ratio: number): void;
  46692. /**
  46693. * Resizes the texture
  46694. * @param width the new width
  46695. * @param height the new height
  46696. */
  46697. scaleTo(width: number, height: number): void;
  46698. /**
  46699. * Gets the context of the canvas used by the texture
  46700. * @returns the canvas context of the dynamic texture
  46701. */
  46702. getContext(): CanvasRenderingContext2D;
  46703. /**
  46704. * Clears the texture
  46705. */
  46706. clear(): void;
  46707. /**
  46708. * Updates the texture
  46709. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46710. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46711. */
  46712. update(invertY?: boolean, premulAlpha?: boolean): void;
  46713. /**
  46714. * Draws text onto the texture
  46715. * @param text defines the text to be drawn
  46716. * @param x defines the placement of the text from the left
  46717. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46718. * @param font defines the font to be used with font-style, font-size, font-name
  46719. * @param color defines the color used for the text
  46720. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46721. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46722. * @param update defines whether texture is immediately update (default is true)
  46723. */
  46724. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  46725. /**
  46726. * Clones the texture
  46727. * @returns the clone of the texture.
  46728. */
  46729. clone(): DynamicTexture;
  46730. /**
  46731. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46732. * @returns a serialized dynamic texture object
  46733. */
  46734. serialize(): any;
  46735. /** @hidden */
  46736. _rebuild(): void;
  46737. }
  46738. }
  46739. declare module BABYLON {
  46740. /**
  46741. * This represents a texture coming from an HDR input.
  46742. *
  46743. * The only supported format is currently panorama picture stored in RGBE format.
  46744. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46745. */
  46746. class HDRCubeTexture extends BaseTexture {
  46747. private static _facesMapping;
  46748. private _generateHarmonics;
  46749. private _noMipmap;
  46750. private _textureMatrix;
  46751. private _size;
  46752. private _onLoad;
  46753. private _onError;
  46754. /**
  46755. * The texture URL.
  46756. */
  46757. url: string;
  46758. /**
  46759. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46760. */
  46761. coordinatesMode: number;
  46762. protected _isBlocking: boolean;
  46763. /**
  46764. * Sets wether or not the texture is blocking during loading.
  46765. */
  46766. /**
  46767. * Gets wether or not the texture is blocking during loading.
  46768. */
  46769. isBlocking: boolean;
  46770. protected _rotationY: number;
  46771. /**
  46772. * Sets texture matrix rotation angle around Y axis in radians.
  46773. */
  46774. /**
  46775. * Gets texture matrix rotation angle around Y axis radians.
  46776. */
  46777. rotationY: number;
  46778. /**
  46779. * Gets or sets the center of the bounding box associated with the cube texture
  46780. * It must define where the camera used to render the texture was set
  46781. */
  46782. boundingBoxPosition: Vector3;
  46783. private _boundingBoxSize;
  46784. /**
  46785. * Gets or sets the size of the bounding box associated with the cube texture
  46786. * When defined, the cubemap will switch to local mode
  46787. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46788. * @example https://www.babylonjs-playground.com/#RNASML
  46789. */
  46790. boundingBoxSize: Vector3;
  46791. /**
  46792. * Instantiates an HDRTexture from the following parameters.
  46793. *
  46794. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  46795. * @param scene The scene the texture will be used in
  46796. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  46797. * @param noMipmap Forces to not generate the mipmap if true
  46798. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  46799. * @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)
  46800. * @param reserved Reserved flag for internal use.
  46801. */
  46802. 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>);
  46803. /**
  46804. * Occurs when the file is raw .hdr file.
  46805. */
  46806. private loadTexture;
  46807. clone(): HDRCubeTexture;
  46808. delayLoad(): void;
  46809. /**
  46810. * Get the texture reflection matrix used to rotate/transform the reflection.
  46811. * @returns the reflection matrix
  46812. */
  46813. getReflectionTextureMatrix(): Matrix;
  46814. /**
  46815. * Set the texture reflection matrix used to rotate/transform the reflection.
  46816. * @param value Define the reflection matrix to set
  46817. */
  46818. setReflectionTextureMatrix(value: Matrix): void;
  46819. /**
  46820. * Parses a JSON representation of an HDR Texture in order to create the texture
  46821. * @param parsedTexture Define the JSON representation
  46822. * @param scene Define the scene the texture should be created in
  46823. * @param rootUrl Define the root url in case we need to load relative dependencies
  46824. * @returns the newly created texture after parsing
  46825. */
  46826. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  46827. serialize(): any;
  46828. }
  46829. }
  46830. declare module BABYLON {
  46831. /**
  46832. * Class used to store data associated with WebGL texture data for the engine
  46833. * This class should not be used directly
  46834. */
  46835. class InternalTexture implements IInternalTextureTracker {
  46836. /**
  46837. * The source of the texture data is unknown
  46838. */
  46839. static DATASOURCE_UNKNOWN: number;
  46840. /**
  46841. * Texture data comes from an URL
  46842. */
  46843. static DATASOURCE_URL: number;
  46844. /**
  46845. * Texture data is only used for temporary storage
  46846. */
  46847. static DATASOURCE_TEMP: number;
  46848. /**
  46849. * Texture data comes from raw data (ArrayBuffer)
  46850. */
  46851. static DATASOURCE_RAW: number;
  46852. /**
  46853. * Texture content is dynamic (video or dynamic texture)
  46854. */
  46855. static DATASOURCE_DYNAMIC: number;
  46856. /**
  46857. * Texture content is generated by rendering to it
  46858. */
  46859. static DATASOURCE_RENDERTARGET: number;
  46860. /**
  46861. * Texture content is part of a multi render target process
  46862. */
  46863. static DATASOURCE_MULTIRENDERTARGET: number;
  46864. /**
  46865. * Texture data comes from a cube data file
  46866. */
  46867. static DATASOURCE_CUBE: number;
  46868. /**
  46869. * Texture data comes from a raw cube data
  46870. */
  46871. static DATASOURCE_CUBERAW: number;
  46872. /**
  46873. * Texture data come from a prefiltered cube data file
  46874. */
  46875. static DATASOURCE_CUBEPREFILTERED: number;
  46876. /**
  46877. * Texture content is raw 3D data
  46878. */
  46879. static DATASOURCE_RAW3D: number;
  46880. /**
  46881. * Texture content is a depth texture
  46882. */
  46883. static DATASOURCE_DEPTHTEXTURE: number;
  46884. /**
  46885. * Texture data comes from a raw cube data encoded with RGBD
  46886. */
  46887. static DATASOURCE_CUBERAW_RGBD: number;
  46888. /**
  46889. * Defines if the texture is ready
  46890. */
  46891. isReady: boolean;
  46892. /**
  46893. * Defines if the texture is a cube texture
  46894. */
  46895. isCube: boolean;
  46896. /**
  46897. * Defines if the texture contains 3D data
  46898. */
  46899. is3D: boolean;
  46900. /**
  46901. * Gets the URL used to load this texture
  46902. */
  46903. url: string;
  46904. /**
  46905. * Gets the sampling mode of the texture
  46906. */
  46907. samplingMode: number;
  46908. /**
  46909. * Gets a boolean indicating if the texture needs mipmaps generation
  46910. */
  46911. generateMipMaps: boolean;
  46912. /**
  46913. * Gets the number of samples used by the texture (WebGL2+ only)
  46914. */
  46915. samples: number;
  46916. /**
  46917. * Gets the type of the texture (int, float...)
  46918. */
  46919. type: number;
  46920. /**
  46921. * Gets the format of the texture (RGB, RGBA...)
  46922. */
  46923. format: number;
  46924. /**
  46925. * Observable called when the texture is loaded
  46926. */
  46927. onLoadedObservable: Observable<InternalTexture>;
  46928. /**
  46929. * Gets the width of the texture
  46930. */
  46931. width: number;
  46932. /**
  46933. * Gets the height of the texture
  46934. */
  46935. height: number;
  46936. /**
  46937. * Gets the depth of the texture
  46938. */
  46939. depth: number;
  46940. /**
  46941. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  46942. */
  46943. baseWidth: number;
  46944. /**
  46945. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  46946. */
  46947. baseHeight: number;
  46948. /**
  46949. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  46950. */
  46951. baseDepth: number;
  46952. /**
  46953. * Gets a boolean indicating if the texture is inverted on Y axis
  46954. */
  46955. invertY: boolean;
  46956. /**
  46957. * Gets or set the previous tracker in the list
  46958. */
  46959. previous: Nullable<IInternalTextureTracker>;
  46960. /**
  46961. * Gets or set the next tracker in the list
  46962. */
  46963. next: Nullable<IInternalTextureTracker>;
  46964. /** @hidden */
  46965. _initialSlot: number;
  46966. /** @hidden */
  46967. _designatedSlot: number;
  46968. /** @hidden */
  46969. _dataSource: number;
  46970. /** @hidden */
  46971. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  46972. /** @hidden */
  46973. _bufferView: Nullable<ArrayBufferView>;
  46974. /** @hidden */
  46975. _bufferViewArray: Nullable<ArrayBufferView[]>;
  46976. /** @hidden */
  46977. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  46978. /** @hidden */
  46979. _size: number;
  46980. /** @hidden */
  46981. _extension: string;
  46982. /** @hidden */
  46983. _files: Nullable<string[]>;
  46984. /** @hidden */
  46985. _workingCanvas: HTMLCanvasElement;
  46986. /** @hidden */
  46987. _workingContext: CanvasRenderingContext2D;
  46988. /** @hidden */
  46989. _framebuffer: Nullable<WebGLFramebuffer>;
  46990. /** @hidden */
  46991. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  46992. /** @hidden */
  46993. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  46994. /** @hidden */
  46995. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  46996. /** @hidden */
  46997. _attachments: Nullable<number[]>;
  46998. /** @hidden */
  46999. _cachedCoordinatesMode: Nullable<number>;
  47000. /** @hidden */
  47001. _cachedWrapU: Nullable<number>;
  47002. /** @hidden */
  47003. _cachedWrapV: Nullable<number>;
  47004. /** @hidden */
  47005. _cachedWrapR: Nullable<number>;
  47006. /** @hidden */
  47007. _cachedAnisotropicFilteringLevel: Nullable<number>;
  47008. /** @hidden */
  47009. _isDisabled: boolean;
  47010. /** @hidden */
  47011. _compression: Nullable<string>;
  47012. /** @hidden */
  47013. _generateStencilBuffer: boolean;
  47014. /** @hidden */
  47015. _generateDepthBuffer: boolean;
  47016. /** @hidden */
  47017. _comparisonFunction: number;
  47018. /** @hidden */
  47019. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  47020. /** @hidden */
  47021. _lodGenerationScale: number;
  47022. /** @hidden */
  47023. _lodGenerationOffset: number;
  47024. /** @hidden */
  47025. _lodTextureHigh: BaseTexture;
  47026. /** @hidden */
  47027. _lodTextureMid: BaseTexture;
  47028. /** @hidden */
  47029. _lodTextureLow: BaseTexture;
  47030. /** @hidden */
  47031. _isRGBD: boolean;
  47032. /** @hidden */
  47033. _webGLTexture: Nullable<WebGLTexture>;
  47034. /** @hidden */
  47035. _references: number;
  47036. private _engine;
  47037. /**
  47038. * Gets the Engine the texture belongs to.
  47039. * @returns The babylon engine
  47040. */
  47041. getEngine(): Engine;
  47042. /**
  47043. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  47044. */
  47045. readonly dataSource: number;
  47046. /**
  47047. * Creates a new InternalTexture
  47048. * @param engine defines the engine to use
  47049. * @param dataSource defines the type of data that will be used
  47050. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47051. */
  47052. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  47053. /**
  47054. * Increments the number of references (ie. the number of Texture that point to it)
  47055. */
  47056. incrementReferences(): void;
  47057. /**
  47058. * Change the size of the texture (not the size of the content)
  47059. * @param width defines the new width
  47060. * @param height defines the new height
  47061. * @param depth defines the new depth (1 by default)
  47062. */
  47063. updateSize(width: int, height: int, depth?: int): void;
  47064. /** @hidden */
  47065. _rebuild(): void;
  47066. /** @hidden */
  47067. _swapAndDie(target: InternalTexture): void;
  47068. /**
  47069. * Dispose the current allocated resources
  47070. */
  47071. dispose(): void;
  47072. }
  47073. }
  47074. declare module BABYLON {
  47075. /**
  47076. * This represents the required contract to create a new type of texture loader.
  47077. */
  47078. interface IInternalTextureLoader {
  47079. /**
  47080. * Defines wether the loader supports cascade loading the different faces.
  47081. */
  47082. supportCascades: boolean;
  47083. /**
  47084. * This returns if the loader support the current file information.
  47085. * @param extension defines the file extension of the file being loaded
  47086. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47087. * @param fallback defines the fallback internal texture if any
  47088. * @param isBase64 defines whether the texture is encoded as a base64
  47089. * @param isBuffer defines whether the texture data are stored as a buffer
  47090. * @returns true if the loader can load the specified file
  47091. */
  47092. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47093. /**
  47094. * Transform the url before loading if required.
  47095. * @param rootUrl the url of the texture
  47096. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47097. * @returns the transformed texture
  47098. */
  47099. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47100. /**
  47101. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47102. * @param rootUrl the url of the texture
  47103. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47104. * @returns the fallback texture
  47105. */
  47106. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47107. /**
  47108. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47109. * @param data contains the texture data
  47110. * @param texture defines the BabylonJS internal texture
  47111. * @param createPolynomials will be true if polynomials have been requested
  47112. * @param onLoad defines the callback to trigger once the texture is ready
  47113. * @param onError defines the callback to trigger in case of error
  47114. */
  47115. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47116. /**
  47117. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47118. * @param data contains the texture data
  47119. * @param texture defines the BabylonJS internal texture
  47120. * @param callback defines the method to call once ready to upload
  47121. */
  47122. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  47123. }
  47124. }
  47125. declare module BABYLON {
  47126. /**
  47127. * Internal interface used to track InternalTexture already bound to the GL context
  47128. */
  47129. interface IInternalTextureTracker {
  47130. /**
  47131. * Gets or set the previous tracker in the list
  47132. */
  47133. previous: Nullable<IInternalTextureTracker>;
  47134. /**
  47135. * Gets or set the next tracker in the list
  47136. */
  47137. next: Nullable<IInternalTextureTracker>;
  47138. }
  47139. /**
  47140. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  47141. */
  47142. class DummyInternalTextureTracker {
  47143. /**
  47144. * Gets or set the previous tracker in the list
  47145. */
  47146. previous: Nullable<IInternalTextureTracker>;
  47147. /**
  47148. * Gets or set the next tracker in the list
  47149. */
  47150. next: Nullable<IInternalTextureTracker>;
  47151. }
  47152. }
  47153. declare module BABYLON {
  47154. /**
  47155. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47156. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47157. * You can then easily use it as a reflectionTexture on a flat surface.
  47158. * In case the surface is not a plane, please consider relying on reflection probes.
  47159. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47160. */
  47161. class MirrorTexture extends RenderTargetTexture {
  47162. private scene;
  47163. /**
  47164. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  47165. * 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.
  47166. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47167. */
  47168. mirrorPlane: Plane;
  47169. /**
  47170. * Define the blur ratio used to blur the reflection if needed.
  47171. */
  47172. blurRatio: number;
  47173. /**
  47174. * Define the adaptive blur kernel used to blur the reflection if needed.
  47175. * This will autocompute the closest best match for the `blurKernel`
  47176. */
  47177. adaptiveBlurKernel: number;
  47178. /**
  47179. * Define the blur kernel used to blur the reflection if needed.
  47180. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47181. */
  47182. blurKernel: number;
  47183. /**
  47184. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  47185. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47186. */
  47187. blurKernelX: number;
  47188. /**
  47189. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  47190. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47191. */
  47192. blurKernelY: number;
  47193. private _autoComputeBlurKernel;
  47194. protected _onRatioRescale(): void;
  47195. private _updateGammaSpace;
  47196. private _imageProcessingConfigChangeObserver;
  47197. private _transformMatrix;
  47198. private _mirrorMatrix;
  47199. private _savedViewMatrix;
  47200. private _blurX;
  47201. private _blurY;
  47202. private _adaptiveBlurKernel;
  47203. private _blurKernelX;
  47204. private _blurKernelY;
  47205. private _blurRatio;
  47206. /**
  47207. * Instantiates a Mirror Texture.
  47208. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47209. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47210. * You can then easily use it as a reflectionTexture on a flat surface.
  47211. * In case the surface is not a plane, please consider relying on reflection probes.
  47212. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47213. * @param name
  47214. * @param size
  47215. * @param scene
  47216. * @param generateMipMaps
  47217. * @param type
  47218. * @param samplingMode
  47219. * @param generateDepthBuffer
  47220. */
  47221. constructor(name: string, size: number | {
  47222. width: number;
  47223. height: number;
  47224. } | {
  47225. ratio: number;
  47226. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  47227. private _preparePostProcesses;
  47228. /**
  47229. * Clone the mirror texture.
  47230. * @returns the cloned texture
  47231. */
  47232. clone(): MirrorTexture;
  47233. /**
  47234. * Serialize the texture to a JSON representation you could use in Parse later on
  47235. * @returns the serialized JSON representation
  47236. */
  47237. serialize(): any;
  47238. /**
  47239. * Dispose the texture and release its associated resources.
  47240. */
  47241. dispose(): void;
  47242. }
  47243. }
  47244. declare module BABYLON {
  47245. /**
  47246. * Creation options of the multi render target texture.
  47247. */
  47248. interface IMultiRenderTargetOptions {
  47249. /**
  47250. * Define if the texture needs to create mip maps after render.
  47251. */
  47252. generateMipMaps?: boolean;
  47253. /**
  47254. * Define the types of all the draw buffers we want to create
  47255. */
  47256. types?: number[];
  47257. /**
  47258. * Define the sampling modes of all the draw buffers we want to create
  47259. */
  47260. samplingModes?: number[];
  47261. /**
  47262. * Define if a depth buffer is required
  47263. */
  47264. generateDepthBuffer?: boolean;
  47265. /**
  47266. * Define if a stencil buffer is required
  47267. */
  47268. generateStencilBuffer?: boolean;
  47269. /**
  47270. * Define if a depth texture is required instead of a depth buffer
  47271. */
  47272. generateDepthTexture?: boolean;
  47273. /**
  47274. * Define the number of desired draw buffers
  47275. */
  47276. textureCount?: number;
  47277. /**
  47278. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47279. */
  47280. doNotChangeAspectRatio?: boolean;
  47281. /**
  47282. * Define the default type of the buffers we are creating
  47283. */
  47284. defaultType?: number;
  47285. }
  47286. /**
  47287. * A multi render target, like a render target provides the ability to render to a texture.
  47288. * Unlike the render target, it can render to several draw buffers in one draw.
  47289. * This is specially interesting in deferred rendering or for any effects requiring more than
  47290. * just one color from a single pass.
  47291. */
  47292. class MultiRenderTarget extends RenderTargetTexture {
  47293. private _internalTextures;
  47294. private _textures;
  47295. private _multiRenderTargetOptions;
  47296. /**
  47297. * Get if draw buffers are currently supported by the used hardware and browser.
  47298. */
  47299. readonly isSupported: boolean;
  47300. /**
  47301. * Get the list of textures generated by the multi render target.
  47302. */
  47303. readonly textures: Texture[];
  47304. /**
  47305. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47306. */
  47307. readonly depthTexture: Texture;
  47308. /**
  47309. * Set the wrapping mode on U of all the textures we are rendering to.
  47310. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47311. */
  47312. wrapU: number;
  47313. /**
  47314. * Set the wrapping mode on V of all the textures we are rendering to.
  47315. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47316. */
  47317. wrapV: number;
  47318. /**
  47319. * Instantiate a new multi render target texture.
  47320. * A multi render target, like a render target provides the ability to render to a texture.
  47321. * Unlike the render target, it can render to several draw buffers in one draw.
  47322. * This is specially interesting in deferred rendering or for any effects requiring more than
  47323. * just one color from a single pass.
  47324. * @param name Define the name of the texture
  47325. * @param size Define the size of the buffers to render to
  47326. * @param count Define the number of target we are rendering into
  47327. * @param scene Define the scene the texture belongs to
  47328. * @param options Define the options used to create the multi render target
  47329. */
  47330. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47331. /** @hidden */
  47332. _rebuild(): void;
  47333. private _createInternalTextures;
  47334. private _createTextures;
  47335. /**
  47336. * Define the number of samples used if MSAA is enabled.
  47337. */
  47338. samples: number;
  47339. /**
  47340. * Resize all the textures in the multi render target.
  47341. * Be carrefull as it will recreate all the data in the new texture.
  47342. * @param size Define the new size
  47343. */
  47344. resize(size: any): void;
  47345. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47346. /**
  47347. * Dispose the render targets and their associated resources
  47348. */
  47349. dispose(): void;
  47350. /**
  47351. * Release all the underlying texture used as draw buffers.
  47352. */
  47353. releaseInternalTextures(): void;
  47354. }
  47355. }
  47356. declare module BABYLON {
  47357. /**
  47358. * Raw cube texture where the raw buffers are passed in
  47359. */
  47360. class RawCubeTexture extends CubeTexture {
  47361. /**
  47362. * Creates a cube texture where the raw buffers are passed in.
  47363. * @param scene defines the scene the texture is attached to
  47364. * @param data defines the array of data to use to create each face
  47365. * @param size defines the size of the textures
  47366. * @param format defines the format of the data
  47367. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  47368. * @param generateMipMaps defines if the engine should generate the mip levels
  47369. * @param invertY defines if data must be stored with Y axis inverted
  47370. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  47371. * @param compression defines the compression used (null by default)
  47372. */
  47373. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  47374. /**
  47375. * Updates the raw cube texture.
  47376. * @param data defines the data to store
  47377. * @param format defines the data format
  47378. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47379. * @param invertY defines if data must be stored with Y axis inverted
  47380. * @param compression defines the compression used (null by default)
  47381. * @param level defines which level of the texture to update
  47382. */
  47383. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  47384. /**
  47385. * Updates a raw cube texture with RGBD encoded data.
  47386. * @param data defines the array of data [mipmap][face] to use to create each face
  47387. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  47388. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47389. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47390. * @returns a promsie that resolves when the operation is complete
  47391. */
  47392. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  47393. /**
  47394. * Clones the raw cube texture.
  47395. * @return a new cube texture
  47396. */
  47397. clone(): CubeTexture;
  47398. /** @hidden */
  47399. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47400. }
  47401. }
  47402. declare module BABYLON {
  47403. /**
  47404. * Raw texture can help creating a texture directly from an array of data.
  47405. * This can be super useful if you either get the data from an uncompressed source or
  47406. * if you wish to create your texture pixel by pixel.
  47407. */
  47408. class RawTexture extends Texture {
  47409. /**
  47410. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47411. */
  47412. format: number;
  47413. private _engine;
  47414. /**
  47415. * Instantiates a new RawTexture.
  47416. * Raw texture can help creating a texture directly from an array of data.
  47417. * This can be super useful if you either get the data from an uncompressed source or
  47418. * if you wish to create your texture pixel by pixel.
  47419. * @param data define the array of data to use to create the texture
  47420. * @param width define the width of the texture
  47421. * @param height define the height of the texture
  47422. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47423. * @param scene define the scene the texture belongs to
  47424. * @param generateMipMaps define whether mip maps should be generated or not
  47425. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47426. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47427. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47428. */
  47429. constructor(data: ArrayBufferView, width: number, height: number,
  47430. /**
  47431. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47432. */
  47433. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  47434. /**
  47435. * Updates the texture underlying data.
  47436. * @param data Define the new data of the texture
  47437. */
  47438. update(data: ArrayBufferView): void;
  47439. /**
  47440. * Creates a luminance texture from some data.
  47441. * @param data Define the texture data
  47442. * @param width Define the width of the texture
  47443. * @param height Define the height of the texture
  47444. * @param scene Define the scene the texture belongs to
  47445. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47446. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47447. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47448. * @returns the luminance texture
  47449. */
  47450. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47451. /**
  47452. * Creates a luminance alpha texture from some data.
  47453. * @param data Define the texture data
  47454. * @param width Define the width of the texture
  47455. * @param height Define the height of the texture
  47456. * @param scene Define the scene the texture belongs to
  47457. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47458. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47459. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47460. * @returns the luminance alpha texture
  47461. */
  47462. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47463. /**
  47464. * Creates an alpha texture from some data.
  47465. * @param data Define the texture data
  47466. * @param width Define the width of the texture
  47467. * @param height Define the height of the texture
  47468. * @param scene Define the scene the texture belongs to
  47469. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47470. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47471. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47472. * @returns the alpha texture
  47473. */
  47474. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47475. /**
  47476. * Creates a RGB texture from some data.
  47477. * @param data Define the texture data
  47478. * @param width Define the width of the texture
  47479. * @param height Define the height of the texture
  47480. * @param scene Define the scene the texture belongs to
  47481. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47482. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47483. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47484. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47485. * @returns the RGB alpha texture
  47486. */
  47487. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47488. /**
  47489. * Creates a RGBA texture from some data.
  47490. * @param data Define the texture data
  47491. * @param width Define the width of the texture
  47492. * @param height Define the height of the texture
  47493. * @param scene Define the scene the texture belongs to
  47494. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47495. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47496. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47497. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47498. * @returns the RGBA texture
  47499. */
  47500. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47501. /**
  47502. * Creates a R texture from some data.
  47503. * @param data Define the texture data
  47504. * @param width Define the width of the texture
  47505. * @param height Define the height of the texture
  47506. * @param scene Define the scene the texture belongs to
  47507. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47508. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47509. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47510. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47511. * @returns the R texture
  47512. */
  47513. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47514. }
  47515. }
  47516. declare module BABYLON {
  47517. /**
  47518. * Class used to store 3D textures containing user data
  47519. */
  47520. class RawTexture3D extends Texture {
  47521. /** Gets or sets the texture format to use */
  47522. format: number;
  47523. private _engine;
  47524. /**
  47525. * Create a new RawTexture3D
  47526. * @param data defines the data of the texture
  47527. * @param width defines the width of the texture
  47528. * @param height defines the height of the texture
  47529. * @param depth defines the depth of the texture
  47530. * @param format defines the texture format to use
  47531. * @param scene defines the hosting scene
  47532. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47533. * @param invertY defines if texture must be stored with Y axis inverted
  47534. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  47535. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47536. */
  47537. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47538. /** Gets or sets the texture format to use */
  47539. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47540. /**
  47541. * Update the texture with new data
  47542. * @param data defines the data to store in the texture
  47543. */
  47544. update(data: ArrayBufferView): void;
  47545. }
  47546. }
  47547. declare module BABYLON {
  47548. /**
  47549. * Creates a refraction texture used by refraction channel of the standard material.
  47550. * It is like a mirror but to see through a material.
  47551. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47552. */
  47553. class RefractionTexture extends RenderTargetTexture {
  47554. /**
  47555. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47556. * 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.
  47557. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47558. */
  47559. refractionPlane: Plane;
  47560. /**
  47561. * Define how deep under the surface we should see.
  47562. */
  47563. depth: number;
  47564. /**
  47565. * Creates a refraction texture used by refraction channel of the standard material.
  47566. * It is like a mirror but to see through a material.
  47567. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47568. * @param name Define the texture name
  47569. * @param size Define the size of the underlying texture
  47570. * @param scene Define the scene the refraction belongs to
  47571. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47572. */
  47573. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47574. /**
  47575. * Clone the refraction texture.
  47576. * @returns the cloned texture
  47577. */
  47578. clone(): RefractionTexture;
  47579. /**
  47580. * Serialize the texture to a JSON representation you could use in Parse later on
  47581. * @returns the serialized JSON representation
  47582. */
  47583. serialize(): any;
  47584. }
  47585. }
  47586. declare module BABYLON {
  47587. /**
  47588. * This Helps creating a texture that will be created from a camera in your scene.
  47589. * It is basically a dynamic texture that could be used to create special effects for instance.
  47590. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  47591. */
  47592. class RenderTargetTexture extends Texture {
  47593. isCube: boolean;
  47594. /**
  47595. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  47596. */
  47597. static readonly REFRESHRATE_RENDER_ONCE: number;
  47598. /**
  47599. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  47600. */
  47601. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  47602. /**
  47603. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  47604. * the central point of your effect and can save a lot of performances.
  47605. */
  47606. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  47607. /**
  47608. * Use this predicate to dynamically define the list of mesh you want to render.
  47609. * If set, the renderList property will be overwritten.
  47610. */
  47611. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  47612. private _renderList;
  47613. /**
  47614. * Use this list to define the list of mesh you want to render.
  47615. */
  47616. renderList: Nullable<Array<AbstractMesh>>;
  47617. private _hookArray;
  47618. /**
  47619. * Define if particles should be rendered in your texture.
  47620. */
  47621. renderParticles: boolean;
  47622. /**
  47623. * Define if sprites should be rendered in your texture.
  47624. */
  47625. renderSprites: boolean;
  47626. /**
  47627. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  47628. */
  47629. coordinatesMode: number;
  47630. /**
  47631. * Define the camera used to render the texture.
  47632. */
  47633. activeCamera: Nullable<Camera>;
  47634. /**
  47635. * Override the render function of the texture with your own one.
  47636. */
  47637. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  47638. /**
  47639. * Define if camera post processes should be use while rendering the texture.
  47640. */
  47641. useCameraPostProcesses: boolean;
  47642. /**
  47643. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  47644. */
  47645. ignoreCameraViewport: boolean;
  47646. private _postProcessManager;
  47647. private _postProcesses;
  47648. private _resizeObserver;
  47649. /**
  47650. * An event triggered when the texture is unbind.
  47651. */
  47652. onBeforeBindObservable: Observable<RenderTargetTexture>;
  47653. /**
  47654. * An event triggered when the texture is unbind.
  47655. */
  47656. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  47657. private _onAfterUnbindObserver;
  47658. /**
  47659. * Set a after unbind callback in the texture.
  47660. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  47661. */
  47662. onAfterUnbind: () => void;
  47663. /**
  47664. * An event triggered before rendering the texture
  47665. */
  47666. onBeforeRenderObservable: Observable<number>;
  47667. private _onBeforeRenderObserver;
  47668. /**
  47669. * Set a before render callback in the texture.
  47670. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  47671. */
  47672. onBeforeRender: (faceIndex: number) => void;
  47673. /**
  47674. * An event triggered after rendering the texture
  47675. */
  47676. onAfterRenderObservable: Observable<number>;
  47677. private _onAfterRenderObserver;
  47678. /**
  47679. * Set a after render callback in the texture.
  47680. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  47681. */
  47682. onAfterRender: (faceIndex: number) => void;
  47683. /**
  47684. * An event triggered after the texture clear
  47685. */
  47686. onClearObservable: Observable<Engine>;
  47687. private _onClearObserver;
  47688. /**
  47689. * Set a clear callback in the texture.
  47690. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  47691. */
  47692. onClear: (Engine: Engine) => void;
  47693. /**
  47694. * Define the clear color of the Render Target if it should be different from the scene.
  47695. */
  47696. clearColor: Color4;
  47697. protected _size: number | {
  47698. width: number;
  47699. height: number;
  47700. };
  47701. protected _initialSizeParameter: number | {
  47702. width: number;
  47703. height: number;
  47704. } | {
  47705. ratio: number;
  47706. };
  47707. protected _sizeRatio: Nullable<number>;
  47708. /** @hidden */
  47709. _generateMipMaps: boolean;
  47710. protected _renderingManager: RenderingManager;
  47711. /** @hidden */
  47712. _waitingRenderList: string[];
  47713. protected _doNotChangeAspectRatio: boolean;
  47714. protected _currentRefreshId: number;
  47715. protected _refreshRate: number;
  47716. protected _textureMatrix: Matrix;
  47717. protected _samples: number;
  47718. protected _renderTargetOptions: RenderTargetCreationOptions;
  47719. /**
  47720. * Gets render target creation options that were used.
  47721. */
  47722. readonly renderTargetOptions: RenderTargetCreationOptions;
  47723. protected _engine: Engine;
  47724. protected _onRatioRescale(): void;
  47725. /**
  47726. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  47727. * It must define where the camera used to render the texture is set
  47728. */
  47729. boundingBoxPosition: Vector3;
  47730. private _boundingBoxSize;
  47731. /**
  47732. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  47733. * When defined, the cubemap will switch to local mode
  47734. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47735. * @example https://www.babylonjs-playground.com/#RNASML
  47736. */
  47737. boundingBoxSize: Vector3;
  47738. /**
  47739. * In case the RTT has been created with a depth texture, get the associated
  47740. * depth texture.
  47741. * Otherwise, return null.
  47742. */
  47743. depthStencilTexture: Nullable<InternalTexture>;
  47744. /**
  47745. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  47746. * or used a shadow, depth texture...
  47747. * @param name The friendly name of the texture
  47748. * @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)
  47749. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  47750. * @param generateMipMaps True if mip maps need to be generated after render.
  47751. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  47752. * @param type The type of the buffer in the RTT (int, half float, float...)
  47753. * @param isCube True if a cube texture needs to be created
  47754. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  47755. * @param generateDepthBuffer True to generate a depth buffer
  47756. * @param generateStencilBuffer True to generate a stencil buffer
  47757. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  47758. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  47759. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47760. */
  47761. constructor(name: string, size: number | {
  47762. width: number;
  47763. height: number;
  47764. } | {
  47765. ratio: number;
  47766. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  47767. /**
  47768. * Creates a depth stencil texture.
  47769. * This is only available in WebGL 2 or with the depth texture extension available.
  47770. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  47771. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  47772. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  47773. */
  47774. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  47775. private _processSizeParameter;
  47776. /**
  47777. * Define the number of samples to use in case of MSAA.
  47778. * It defaults to one meaning no MSAA has been enabled.
  47779. */
  47780. samples: number;
  47781. /**
  47782. * Resets the refresh counter of the texture and start bak from scratch.
  47783. * Could be usefull to regenerate the texture if it is setup to render only once.
  47784. */
  47785. resetRefreshCounter(): void;
  47786. /**
  47787. * Define the refresh rate of the texture or the rendering frequency.
  47788. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  47789. */
  47790. refreshRate: number;
  47791. /**
  47792. * Adds a post process to the render target rendering passes.
  47793. * @param postProcess define the post process to add
  47794. */
  47795. addPostProcess(postProcess: PostProcess): void;
  47796. /**
  47797. * Clear all the post processes attached to the render target
  47798. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  47799. */
  47800. clearPostProcesses(dispose?: boolean): void;
  47801. /**
  47802. * Remove one of the post process from the list of attached post processes to the texture
  47803. * @param postProcess define the post process to remove from the list
  47804. */
  47805. removePostProcess(postProcess: PostProcess): void;
  47806. /** @hidden */
  47807. _shouldRender(): boolean;
  47808. /**
  47809. * Gets the actual render size of the texture.
  47810. * @returns the width of the render size
  47811. */
  47812. getRenderSize(): number;
  47813. /**
  47814. * Gets the actual render width of the texture.
  47815. * @returns the width of the render size
  47816. */
  47817. getRenderWidth(): number;
  47818. /**
  47819. * Gets the actual render height of the texture.
  47820. * @returns the height of the render size
  47821. */
  47822. getRenderHeight(): number;
  47823. /**
  47824. * Get if the texture can be rescaled or not.
  47825. */
  47826. readonly canRescale: boolean;
  47827. /**
  47828. * Resize the texture using a ratio.
  47829. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  47830. */
  47831. scale(ratio: number): void;
  47832. /**
  47833. * Get the texture reflection matrix used to rotate/transform the reflection.
  47834. * @returns the reflection matrix
  47835. */
  47836. getReflectionTextureMatrix(): Matrix;
  47837. /**
  47838. * Resize the texture to a new desired size.
  47839. * Be carrefull as it will recreate all the data in the new texture.
  47840. * @param size Define the new size. It can be:
  47841. * - a number for squared texture,
  47842. * - an object containing { width: number, height: number }
  47843. * - or an object containing a ratio { ratio: number }
  47844. */
  47845. resize(size: number | {
  47846. width: number;
  47847. height: number;
  47848. } | {
  47849. ratio: number;
  47850. }): void;
  47851. /**
  47852. * Renders all the objects from the render list into the texture.
  47853. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  47854. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  47855. */
  47856. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  47857. private _bestReflectionRenderTargetDimension;
  47858. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47859. private renderToTarget;
  47860. /**
  47861. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47862. * This allowed control for front to back rendering or reversly depending of the special needs.
  47863. *
  47864. * @param renderingGroupId The rendering group id corresponding to its index
  47865. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47866. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47867. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47868. */
  47869. 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;
  47870. /**
  47871. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47872. *
  47873. * @param renderingGroupId The rendering group id corresponding to its index
  47874. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47875. */
  47876. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47877. /**
  47878. * Clones the texture.
  47879. * @returns the cloned texture
  47880. */
  47881. clone(): RenderTargetTexture;
  47882. /**
  47883. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  47884. * @returns The JSON representation of the texture
  47885. */
  47886. serialize(): any;
  47887. /**
  47888. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  47889. */
  47890. disposeFramebufferObjects(): void;
  47891. /**
  47892. * Dispose the texture and release its associated resources.
  47893. */
  47894. dispose(): void;
  47895. /** @hidden */
  47896. _rebuild(): void;
  47897. /**
  47898. * Clear the info related to rendering groups preventing retention point in material dispose.
  47899. */
  47900. freeRenderingGroups(): void;
  47901. }
  47902. }
  47903. declare module BABYLON {
  47904. /**
  47905. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  47906. * @see http://doc.babylonjs.com/babylon101/materials#texture
  47907. */
  47908. class Texture extends BaseTexture {
  47909. /** nearest is mag = nearest and min = nearest and mip = linear */
  47910. static readonly NEAREST_SAMPLINGMODE: number;
  47911. /** nearest is mag = nearest and min = nearest and mip = linear */
  47912. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  47913. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47914. static readonly BILINEAR_SAMPLINGMODE: number;
  47915. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47916. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  47917. /** Trilinear is mag = linear and min = linear and mip = linear */
  47918. static readonly TRILINEAR_SAMPLINGMODE: number;
  47919. /** Trilinear is mag = linear and min = linear and mip = linear */
  47920. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  47921. /** mag = nearest and min = nearest and mip = nearest */
  47922. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  47923. /** mag = nearest and min = linear and mip = nearest */
  47924. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  47925. /** mag = nearest and min = linear and mip = linear */
  47926. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  47927. /** mag = nearest and min = linear and mip = none */
  47928. static readonly NEAREST_LINEAR: number;
  47929. /** mag = nearest and min = nearest and mip = none */
  47930. static readonly NEAREST_NEAREST: number;
  47931. /** mag = linear and min = nearest and mip = nearest */
  47932. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  47933. /** mag = linear and min = nearest and mip = linear */
  47934. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  47935. /** mag = linear and min = linear and mip = none */
  47936. static readonly LINEAR_LINEAR: number;
  47937. /** mag = linear and min = nearest and mip = none */
  47938. static readonly LINEAR_NEAREST: number;
  47939. /** Explicit coordinates mode */
  47940. static readonly EXPLICIT_MODE: number;
  47941. /** Spherical coordinates mode */
  47942. static readonly SPHERICAL_MODE: number;
  47943. /** Planar coordinates mode */
  47944. static readonly PLANAR_MODE: number;
  47945. /** Cubic coordinates mode */
  47946. static readonly CUBIC_MODE: number;
  47947. /** Projection coordinates mode */
  47948. static readonly PROJECTION_MODE: number;
  47949. /** Inverse Cubic coordinates mode */
  47950. static readonly SKYBOX_MODE: number;
  47951. /** Inverse Cubic coordinates mode */
  47952. static readonly INVCUBIC_MODE: number;
  47953. /** Equirectangular coordinates mode */
  47954. static readonly EQUIRECTANGULAR_MODE: number;
  47955. /** Equirectangular Fixed coordinates mode */
  47956. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  47957. /** Equirectangular Fixed Mirrored coordinates mode */
  47958. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  47959. /** Texture is not repeating outside of 0..1 UVs */
  47960. static readonly CLAMP_ADDRESSMODE: number;
  47961. /** Texture is repeating outside of 0..1 UVs */
  47962. static readonly WRAP_ADDRESSMODE: number;
  47963. /** Texture is repeating and mirrored */
  47964. static readonly MIRROR_ADDRESSMODE: number;
  47965. /**
  47966. * 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
  47967. */
  47968. static UseSerializedUrlIfAny: boolean;
  47969. /**
  47970. * Define the url of the texture.
  47971. */
  47972. url: Nullable<string>;
  47973. /**
  47974. * Define an offset on the texture to offset the u coordinates of the UVs
  47975. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  47976. */
  47977. uOffset: number;
  47978. /**
  47979. * Define an offset on the texture to offset the v coordinates of the UVs
  47980. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  47981. */
  47982. vOffset: number;
  47983. /**
  47984. * Define an offset on the texture to scale the u coordinates of the UVs
  47985. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  47986. */
  47987. uScale: number;
  47988. /**
  47989. * Define an offset on the texture to scale the v coordinates of the UVs
  47990. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  47991. */
  47992. vScale: number;
  47993. /**
  47994. * Define an offset on the texture to rotate around the u coordinates of the UVs
  47995. * @see http://doc.babylonjs.com/how_to/more_materials
  47996. */
  47997. uAng: number;
  47998. /**
  47999. * Define an offset on the texture to rotate around the v coordinates of the UVs
  48000. * @see http://doc.babylonjs.com/how_to/more_materials
  48001. */
  48002. vAng: number;
  48003. /**
  48004. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  48005. * @see http://doc.babylonjs.com/how_to/more_materials
  48006. */
  48007. wAng: number;
  48008. /**
  48009. * Defines the center of rotation (U)
  48010. */
  48011. uRotationCenter: number;
  48012. /**
  48013. * Defines the center of rotation (V)
  48014. */
  48015. vRotationCenter: number;
  48016. /**
  48017. * Defines the center of rotation (W)
  48018. */
  48019. wRotationCenter: number;
  48020. /**
  48021. * Are mip maps generated for this texture or not.
  48022. */
  48023. readonly noMipmap: boolean;
  48024. private _noMipmap;
  48025. /** @hidden */
  48026. _invertY: boolean;
  48027. private _rowGenerationMatrix;
  48028. private _cachedTextureMatrix;
  48029. private _projectionModeMatrix;
  48030. private _t0;
  48031. private _t1;
  48032. private _t2;
  48033. private _cachedUOffset;
  48034. private _cachedVOffset;
  48035. private _cachedUScale;
  48036. private _cachedVScale;
  48037. private _cachedUAng;
  48038. private _cachedVAng;
  48039. private _cachedWAng;
  48040. private _cachedProjectionMatrixId;
  48041. private _cachedCoordinatesMode;
  48042. /** @hidden */
  48043. _samplingMode: number;
  48044. /** @hidden */
  48045. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  48046. private _deleteBuffer;
  48047. protected _format: Nullable<number>;
  48048. private _delayedOnLoad;
  48049. private _delayedOnError;
  48050. /**
  48051. * Observable triggered once the texture has been loaded.
  48052. */
  48053. onLoadObservable: Observable<Texture>;
  48054. protected _isBlocking: boolean;
  48055. /**
  48056. * Is the texture preventing material to render while loading.
  48057. * If false, a default texture will be used instead of the loading one during the preparation step.
  48058. */
  48059. isBlocking: boolean;
  48060. /**
  48061. * Get the current sampling mode associated with the texture.
  48062. */
  48063. readonly samplingMode: number;
  48064. /**
  48065. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  48066. */
  48067. readonly invertY: boolean;
  48068. /**
  48069. * Instantiates a new texture.
  48070. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48071. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48072. * @param url define the url of the picture to load as a texture
  48073. * @param scene define the scene the texture will belong to
  48074. * @param noMipmap define if the texture will require mip maps or not
  48075. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48076. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48077. * @param onLoad define a callback triggered when the texture has been loaded
  48078. * @param onError define a callback triggered when an error occurred during the loading session
  48079. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48080. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48081. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48082. */
  48083. 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);
  48084. /**
  48085. * Update the url (and optional buffer) of this texture if url was null during construction.
  48086. * @param url the url of the texture
  48087. * @param buffer the buffer of the texture (defaults to null)
  48088. */
  48089. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  48090. /**
  48091. * Finish the loading sequence of a texture flagged as delayed load.
  48092. * @hidden
  48093. */
  48094. delayLoad(): void;
  48095. /**
  48096. * Update the sampling mode of the texture.
  48097. * Default is Trilinear mode.
  48098. *
  48099. * | Value | Type | Description |
  48100. * | ----- | ------------------ | ----------- |
  48101. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  48102. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  48103. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  48104. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  48105. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  48106. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  48107. * | 7 | NEAREST_LINEAR | |
  48108. * | 8 | NEAREST_NEAREST | |
  48109. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  48110. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  48111. * | 11 | LINEAR_LINEAR | |
  48112. * | 12 | LINEAR_NEAREST | |
  48113. *
  48114. * > _mag_: magnification filter (close to the viewer)
  48115. * > _min_: minification filter (far from the viewer)
  48116. * > _mip_: filter used between mip map levels
  48117. *@param samplingMode Define the new sampling mode of the texture
  48118. */
  48119. updateSamplingMode(samplingMode: number): void;
  48120. private _prepareRowForTextureGeneration;
  48121. /**
  48122. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  48123. * @returns the transform matrix of the texture.
  48124. */
  48125. getTextureMatrix(): Matrix;
  48126. /**
  48127. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  48128. * @returns The reflection texture transform
  48129. */
  48130. getReflectionTextureMatrix(): Matrix;
  48131. /**
  48132. * Clones the texture.
  48133. * @returns the cloned texture
  48134. */
  48135. clone(): Texture;
  48136. /**
  48137. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48138. * @returns The JSON representation of the texture
  48139. */
  48140. serialize(): any;
  48141. /**
  48142. * Get the current class name of the texture usefull for serialization or dynamic coding.
  48143. * @returns "Texture"
  48144. */
  48145. getClassName(): string;
  48146. /**
  48147. * Dispose the texture and release its associated resources.
  48148. */
  48149. dispose(): void;
  48150. /**
  48151. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  48152. * @param parsedTexture Define the JSON representation of the texture
  48153. * @param scene Define the scene the parsed texture should be instantiated in
  48154. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48155. * @returns The parsed texture if successful
  48156. */
  48157. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  48158. /**
  48159. * Creates a texture from its base 64 representation.
  48160. * @param data Define the base64 payload without the data: prefix
  48161. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48162. * @param scene Define the scene the texture should belong to
  48163. * @param noMipmap Forces the texture to not create mip map information if true
  48164. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48165. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48166. * @param onLoad define a callback triggered when the texture has been loaded
  48167. * @param onError define a callback triggered when an error occurred during the loading session
  48168. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48169. * @returns the created texture
  48170. */
  48171. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  48172. /**
  48173. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  48174. * @param data Define the base64 payload without the data: prefix
  48175. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48176. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48177. * @param scene Define the scene the texture should belong to
  48178. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48179. * @param noMipmap Forces the texture to not create mip map information if true
  48180. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48181. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48182. * @param onLoad define a callback triggered when the texture has been loaded
  48183. * @param onError define a callback triggered when an error occurred during the loading session
  48184. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48185. * @returns the created texture
  48186. */
  48187. 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;
  48188. }
  48189. }
  48190. declare module BABYLON {
  48191. /**
  48192. * Settings for finer control over video usage
  48193. */
  48194. interface VideoTextureSettings {
  48195. /**
  48196. * Applies `autoplay` to video, if specified
  48197. */
  48198. autoPlay?: boolean;
  48199. /**
  48200. * Applies `loop` to video, if specified
  48201. */
  48202. loop?: boolean;
  48203. /**
  48204. * Automatically updates internal texture from video at every frame in the render loop
  48205. */
  48206. autoUpdateTexture: boolean;
  48207. /**
  48208. * Image src displayed during the video loading or until the user interacts with the video.
  48209. */
  48210. poster?: string;
  48211. }
  48212. /**
  48213. * If you want to display a video in your scene, this is the special texture for that.
  48214. * This special texture works similar to other textures, with the exception of a few parameters.
  48215. * @see https://doc.babylonjs.com/how_to/video_texture
  48216. */
  48217. class VideoTexture extends Texture {
  48218. /**
  48219. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  48220. */
  48221. readonly autoUpdateTexture: boolean;
  48222. /**
  48223. * The video instance used by the texture internally
  48224. */
  48225. readonly video: HTMLVideoElement;
  48226. private _onUserActionRequestedObservable;
  48227. /**
  48228. * Event triggerd when a dom action is required by the user to play the video.
  48229. * This happens due to recent changes in browser policies preventing video to auto start.
  48230. */
  48231. readonly onUserActionRequestedObservable: Observable<Texture>;
  48232. private _generateMipMaps;
  48233. private _engine;
  48234. private _stillImageCaptured;
  48235. private _displayingPosterTexture;
  48236. private _settings;
  48237. private _createInternalTextureOnEvent;
  48238. /**
  48239. * Creates a video texture.
  48240. * If you want to display a video in your scene, this is the special texture for that.
  48241. * This special texture works similar to other textures, with the exception of a few parameters.
  48242. * @see https://doc.babylonjs.com/how_to/video_texture
  48243. * @param name optional name, will detect from video source, if not defined
  48244. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  48245. * @param scene is obviously the current scene.
  48246. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  48247. * @param invertY is false by default but can be used to invert video on Y axis
  48248. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  48249. * @param settings allows finer control over video usage
  48250. */
  48251. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  48252. private _getName;
  48253. private _getVideo;
  48254. private _createInternalTexture;
  48255. private reset;
  48256. /**
  48257. * @hidden Internal method to initiate `update`.
  48258. */
  48259. _rebuild(): void;
  48260. /**
  48261. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  48262. */
  48263. update(): void;
  48264. /**
  48265. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  48266. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  48267. */
  48268. updateTexture(isVisible: boolean): void;
  48269. protected _updateInternalTexture: (e?: Event | undefined) => void;
  48270. /**
  48271. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  48272. * @param url New url.
  48273. */
  48274. updateURL(url: string): void;
  48275. /**
  48276. * Dispose the texture and release its associated resources.
  48277. */
  48278. dispose(): void;
  48279. /**
  48280. * Creates a video texture straight from your WebCam video feed.
  48281. * @param scene Define the scene the texture should be created in
  48282. * @param onReady Define a callback to triggered once the texture will be ready
  48283. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  48284. */
  48285. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  48286. minWidth: number;
  48287. maxWidth: number;
  48288. minHeight: number;
  48289. maxHeight: number;
  48290. deviceId: string;
  48291. }): void;
  48292. }
  48293. }
  48294. declare var DracoDecoderModule: any;
  48295. declare var WebAssembly: any;
  48296. declare module BABYLON {
  48297. /**
  48298. * Configuration for Draco compression
  48299. */
  48300. interface IDracoCompressionConfiguration {
  48301. /**
  48302. * Configuration for the decoder.
  48303. */
  48304. decoder?: {
  48305. /**
  48306. * The url to the WebAssembly module.
  48307. */
  48308. wasmUrl?: string;
  48309. /**
  48310. * The url to the WebAssembly binary.
  48311. */
  48312. wasmBinaryUrl?: string;
  48313. /**
  48314. * The url to the fallback JavaScript module.
  48315. */
  48316. fallbackUrl?: string;
  48317. };
  48318. }
  48319. /**
  48320. * Draco compression (https://google.github.io/draco/)
  48321. *
  48322. * This class wraps the Draco module.
  48323. *
  48324. * **Encoder**
  48325. *
  48326. * The encoder is not currently implemented.
  48327. *
  48328. * **Decoder**
  48329. *
  48330. * 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.
  48331. *
  48332. * To update the configuration, use the following code:
  48333. * ```javascript
  48334. * BABYLON.DracoCompression.Configuration = {
  48335. * decoder: {
  48336. * wasmUrl: "<url to the WebAssembly library>",
  48337. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48338. * fallbackUrl: "<url to the fallback JavaScript library>",
  48339. * }
  48340. * };
  48341. * ```
  48342. *
  48343. * 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.
  48344. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48345. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48346. *
  48347. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48348. * ```javascript
  48349. * var dracoCompression = new BABYLON.DracoCompression();
  48350. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48351. * [BABYLON.VertexBuffer.PositionKind]: 0
  48352. * });
  48353. * ```
  48354. *
  48355. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48356. */
  48357. class DracoCompression implements IDisposable {
  48358. private static _DecoderModulePromise;
  48359. /**
  48360. * The configuration. Defaults to the following urls:
  48361. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48362. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48363. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48364. */
  48365. static Configuration: IDracoCompressionConfiguration;
  48366. /**
  48367. * Returns true if the decoder is available.
  48368. */
  48369. static readonly DecoderAvailable: boolean;
  48370. /**
  48371. * Constructor
  48372. */
  48373. constructor();
  48374. /**
  48375. * Stop all async operations and release resources.
  48376. */
  48377. dispose(): void;
  48378. /**
  48379. * Decode Draco compressed mesh data to vertex data.
  48380. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48381. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48382. * @returns A promise that resolves with the decoded vertex data
  48383. */
  48384. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48385. [kind: string]: number;
  48386. }): Promise<VertexData>;
  48387. private static _GetDecoderModule;
  48388. private static _LoadScriptAsync;
  48389. private static _LoadFileAsync;
  48390. }
  48391. }
  48392. declare module BABYLON {
  48393. /**
  48394. * Particle emitter emitting particles from the inside of a box.
  48395. * It emits the particles randomly between 2 given directions.
  48396. */
  48397. class BoxParticleEmitter implements IParticleEmitterType {
  48398. /**
  48399. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48400. */
  48401. direction1: Vector3;
  48402. /**
  48403. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48404. */
  48405. direction2: Vector3;
  48406. /**
  48407. * 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.
  48408. */
  48409. minEmitBox: Vector3;
  48410. /**
  48411. * 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.
  48412. */
  48413. maxEmitBox: Vector3;
  48414. /**
  48415. * Creates a new instance BoxParticleEmitter
  48416. */
  48417. constructor();
  48418. /**
  48419. * Called by the particle System when the direction is computed for the created particle.
  48420. * @param worldMatrix is the world matrix of the particle system
  48421. * @param directionToUpdate is the direction vector to update with the result
  48422. * @param particle is the particle we are computed the direction for
  48423. */
  48424. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48425. /**
  48426. * Called by the particle System when the position is computed for the created particle.
  48427. * @param worldMatrix is the world matrix of the particle system
  48428. * @param positionToUpdate is the position vector to update with the result
  48429. * @param particle is the particle we are computed the position for
  48430. */
  48431. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48432. /**
  48433. * Clones the current emitter and returns a copy of it
  48434. * @returns the new emitter
  48435. */
  48436. clone(): BoxParticleEmitter;
  48437. /**
  48438. * Called by the GPUParticleSystem to setup the update shader
  48439. * @param effect defines the update shader
  48440. */
  48441. applyToShader(effect: Effect): void;
  48442. /**
  48443. * Returns a string to use to update the GPU particles update shader
  48444. * @returns a string containng the defines string
  48445. */
  48446. getEffectDefines(): string;
  48447. /**
  48448. * Returns the string "BoxParticleEmitter"
  48449. * @returns a string containing the class name
  48450. */
  48451. getClassName(): string;
  48452. /**
  48453. * Serializes the particle system to a JSON object.
  48454. * @returns the JSON object
  48455. */
  48456. serialize(): any;
  48457. /**
  48458. * Parse properties from a JSON object
  48459. * @param serializationObject defines the JSON object
  48460. */
  48461. parse(serializationObject: any): void;
  48462. }
  48463. }
  48464. declare module BABYLON {
  48465. /**
  48466. * Particle emitter emitting particles from the inside of a cone.
  48467. * It emits the particles alongside the cone volume from the base to the particle.
  48468. * The emission direction might be randomized.
  48469. */
  48470. class ConeParticleEmitter implements IParticleEmitterType {
  48471. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48472. directionRandomizer: number;
  48473. private _radius;
  48474. private _angle;
  48475. private _height;
  48476. /**
  48477. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  48478. */
  48479. radiusRange: number;
  48480. /**
  48481. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  48482. */
  48483. heightRange: number;
  48484. /**
  48485. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  48486. */
  48487. emitFromSpawnPointOnly: boolean;
  48488. /**
  48489. * Gets or sets the radius of the emission cone
  48490. */
  48491. radius: number;
  48492. /**
  48493. * Gets or sets the angle of the emission cone
  48494. */
  48495. angle: number;
  48496. private _buildHeight;
  48497. /**
  48498. * Creates a new instance ConeParticleEmitter
  48499. * @param radius the radius of the emission cone (1 by default)
  48500. * @param angles the cone base angle (PI by default)
  48501. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  48502. */
  48503. constructor(radius?: number, angle?: number,
  48504. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48505. directionRandomizer?: number);
  48506. /**
  48507. * Called by the particle System when the direction is computed for the created particle.
  48508. * @param worldMatrix is the world matrix of the particle system
  48509. * @param directionToUpdate is the direction vector to update with the result
  48510. * @param particle is the particle we are computed the direction for
  48511. */
  48512. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48513. /**
  48514. * Called by the particle System when the position is computed for the created particle.
  48515. * @param worldMatrix is the world matrix of the particle system
  48516. * @param positionToUpdate is the position vector to update with the result
  48517. * @param particle is the particle we are computed the position for
  48518. */
  48519. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48520. /**
  48521. * Clones the current emitter and returns a copy of it
  48522. * @returns the new emitter
  48523. */
  48524. clone(): ConeParticleEmitter;
  48525. /**
  48526. * Called by the GPUParticleSystem to setup the update shader
  48527. * @param effect defines the update shader
  48528. */
  48529. applyToShader(effect: Effect): void;
  48530. /**
  48531. * Returns a string to use to update the GPU particles update shader
  48532. * @returns a string containng the defines string
  48533. */
  48534. getEffectDefines(): string;
  48535. /**
  48536. * Returns the string "ConeParticleEmitter"
  48537. * @returns a string containing the class name
  48538. */
  48539. getClassName(): string;
  48540. /**
  48541. * Serializes the particle system to a JSON object.
  48542. * @returns the JSON object
  48543. */
  48544. serialize(): any;
  48545. /**
  48546. * Parse properties from a JSON object
  48547. * @param serializationObject defines the JSON object
  48548. */
  48549. parse(serializationObject: any): void;
  48550. }
  48551. }
  48552. declare module BABYLON {
  48553. /**
  48554. * Particle emitter emitting particles from the inside of a cylinder.
  48555. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  48556. */
  48557. class CylinderParticleEmitter implements IParticleEmitterType {
  48558. /**
  48559. * The radius of the emission cylinder.
  48560. */
  48561. radius: number;
  48562. /**
  48563. * The height of the emission cylinder.
  48564. */
  48565. height: number;
  48566. /**
  48567. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48568. */
  48569. radiusRange: number;
  48570. /**
  48571. * How much to randomize the particle direction [0-1].
  48572. */
  48573. directionRandomizer: number;
  48574. /**
  48575. * Creates a new instance CylinderParticleEmitter
  48576. * @param radius the radius of the emission cylinder (1 by default)
  48577. * @param height the height of the emission cylinder (1 by default)
  48578. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48579. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48580. */
  48581. constructor(
  48582. /**
  48583. * The radius of the emission cylinder.
  48584. */
  48585. radius?: number,
  48586. /**
  48587. * The height of the emission cylinder.
  48588. */
  48589. height?: number,
  48590. /**
  48591. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48592. */
  48593. radiusRange?: number,
  48594. /**
  48595. * How much to randomize the particle direction [0-1].
  48596. */
  48597. directionRandomizer?: number);
  48598. /**
  48599. * Called by the particle System when the direction is computed for the created particle.
  48600. * @param worldMatrix is the world matrix of the particle system
  48601. * @param directionToUpdate is the direction vector to update with the result
  48602. * @param particle is the particle we are computed the direction for
  48603. */
  48604. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48605. /**
  48606. * Called by the particle System when the position is computed for the created particle.
  48607. * @param worldMatrix is the world matrix of the particle system
  48608. * @param positionToUpdate is the position vector to update with the result
  48609. * @param particle is the particle we are computed the position for
  48610. */
  48611. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48612. /**
  48613. * Clones the current emitter and returns a copy of it
  48614. * @returns the new emitter
  48615. */
  48616. clone(): CylinderParticleEmitter;
  48617. /**
  48618. * Called by the GPUParticleSystem to setup the update shader
  48619. * @param effect defines the update shader
  48620. */
  48621. applyToShader(effect: Effect): void;
  48622. /**
  48623. * Returns a string to use to update the GPU particles update shader
  48624. * @returns a string containng the defines string
  48625. */
  48626. getEffectDefines(): string;
  48627. /**
  48628. * Returns the string "CylinderParticleEmitter"
  48629. * @returns a string containing the class name
  48630. */
  48631. getClassName(): string;
  48632. /**
  48633. * Serializes the particle system to a JSON object.
  48634. * @returns the JSON object
  48635. */
  48636. serialize(): any;
  48637. /**
  48638. * Parse properties from a JSON object
  48639. * @param serializationObject defines the JSON object
  48640. */
  48641. parse(serializationObject: any): void;
  48642. }
  48643. /**
  48644. * Particle emitter emitting particles from the inside of a cylinder.
  48645. * It emits the particles randomly between two vectors.
  48646. */
  48647. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  48648. /**
  48649. * The min limit of the emission direction.
  48650. */
  48651. direction1: Vector3;
  48652. /**
  48653. * The max limit of the emission direction.
  48654. */
  48655. direction2: Vector3;
  48656. /**
  48657. * Creates a new instance CylinderDirectedParticleEmitter
  48658. * @param radius the radius of the emission cylinder (1 by default)
  48659. * @param height the height of the emission cylinder (1 by default)
  48660. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48661. * @param direction1 the min limit of the emission direction (up vector by default)
  48662. * @param direction2 the max limit of the emission direction (up vector by default)
  48663. */
  48664. constructor(radius?: number, height?: number, radiusRange?: number,
  48665. /**
  48666. * The min limit of the emission direction.
  48667. */
  48668. direction1?: Vector3,
  48669. /**
  48670. * The max limit of the emission direction.
  48671. */
  48672. direction2?: Vector3);
  48673. /**
  48674. * Called by the particle System when the direction is computed for the created particle.
  48675. * @param worldMatrix is the world matrix of the particle system
  48676. * @param directionToUpdate is the direction vector to update with the result
  48677. * @param particle is the particle we are computed the direction for
  48678. */
  48679. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48680. /**
  48681. * Clones the current emitter and returns a copy of it
  48682. * @returns the new emitter
  48683. */
  48684. clone(): CylinderDirectedParticleEmitter;
  48685. /**
  48686. * Called by the GPUParticleSystem to setup the update shader
  48687. * @param effect defines the update shader
  48688. */
  48689. applyToShader(effect: Effect): void;
  48690. /**
  48691. * Returns a string to use to update the GPU particles update shader
  48692. * @returns a string containng the defines string
  48693. */
  48694. getEffectDefines(): string;
  48695. /**
  48696. * Returns the string "CylinderDirectedParticleEmitter"
  48697. * @returns a string containing the class name
  48698. */
  48699. getClassName(): string;
  48700. /**
  48701. * Serializes the particle system to a JSON object.
  48702. * @returns the JSON object
  48703. */
  48704. serialize(): any;
  48705. /**
  48706. * Parse properties from a JSON object
  48707. * @param serializationObject defines the JSON object
  48708. */
  48709. parse(serializationObject: any): void;
  48710. }
  48711. }
  48712. declare module BABYLON {
  48713. /**
  48714. * Particle emitter emitting particles from the inside of a hemisphere.
  48715. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  48716. */
  48717. class HemisphericParticleEmitter implements IParticleEmitterType {
  48718. /**
  48719. * The radius of the emission hemisphere.
  48720. */
  48721. radius: number;
  48722. /**
  48723. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48724. */
  48725. radiusRange: number;
  48726. /**
  48727. * How much to randomize the particle direction [0-1].
  48728. */
  48729. directionRandomizer: number;
  48730. /**
  48731. * Creates a new instance HemisphericParticleEmitter
  48732. * @param radius the radius of the emission hemisphere (1 by default)
  48733. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48734. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48735. */
  48736. constructor(
  48737. /**
  48738. * The radius of the emission hemisphere.
  48739. */
  48740. radius?: number,
  48741. /**
  48742. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48743. */
  48744. radiusRange?: number,
  48745. /**
  48746. * How much to randomize the particle direction [0-1].
  48747. */
  48748. directionRandomizer?: number);
  48749. /**
  48750. * Called by the particle System when the direction is computed for the created particle.
  48751. * @param worldMatrix is the world matrix of the particle system
  48752. * @param directionToUpdate is the direction vector to update with the result
  48753. * @param particle is the particle we are computed the direction for
  48754. */
  48755. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48756. /**
  48757. * Called by the particle System when the position is computed for the created particle.
  48758. * @param worldMatrix is the world matrix of the particle system
  48759. * @param positionToUpdate is the position vector to update with the result
  48760. * @param particle is the particle we are computed the position for
  48761. */
  48762. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48763. /**
  48764. * Clones the current emitter and returns a copy of it
  48765. * @returns the new emitter
  48766. */
  48767. clone(): HemisphericParticleEmitter;
  48768. /**
  48769. * Called by the GPUParticleSystem to setup the update shader
  48770. * @param effect defines the update shader
  48771. */
  48772. applyToShader(effect: Effect): void;
  48773. /**
  48774. * Returns a string to use to update the GPU particles update shader
  48775. * @returns a string containng the defines string
  48776. */
  48777. getEffectDefines(): string;
  48778. /**
  48779. * Returns the string "HemisphericParticleEmitter"
  48780. * @returns a string containing the class name
  48781. */
  48782. getClassName(): string;
  48783. /**
  48784. * Serializes the particle system to a JSON object.
  48785. * @returns the JSON object
  48786. */
  48787. serialize(): any;
  48788. /**
  48789. * Parse properties from a JSON object
  48790. * @param serializationObject defines the JSON object
  48791. */
  48792. parse(serializationObject: any): void;
  48793. }
  48794. }
  48795. declare module BABYLON {
  48796. /**
  48797. * Particle emitter represents a volume emitting particles.
  48798. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  48799. */
  48800. interface IParticleEmitterType {
  48801. /**
  48802. * Called by the particle System when the direction is computed for the created particle.
  48803. * @param worldMatrix is the world matrix of the particle system
  48804. * @param directionToUpdate is the direction vector to update with the result
  48805. * @param particle is the particle we are computed the direction for
  48806. */
  48807. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48808. /**
  48809. * Called by the particle System when the position is computed for the created particle.
  48810. * @param worldMatrix is the world matrix of the particle system
  48811. * @param positionToUpdate is the position vector to update with the result
  48812. * @param particle is the particle we are computed the position for
  48813. */
  48814. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48815. /**
  48816. * Clones the current emitter and returns a copy of it
  48817. * @returns the new emitter
  48818. */
  48819. clone(): IParticleEmitterType;
  48820. /**
  48821. * Called by the GPUParticleSystem to setup the update shader
  48822. * @param effect defines the update shader
  48823. */
  48824. applyToShader(effect: Effect): void;
  48825. /**
  48826. * Returns a string to use to update the GPU particles update shader
  48827. * @returns the effect defines string
  48828. */
  48829. getEffectDefines(): string;
  48830. /**
  48831. * Returns a string representing the class name
  48832. * @returns a string containing the class name
  48833. */
  48834. getClassName(): string;
  48835. /**
  48836. * Serializes the particle system to a JSON object.
  48837. * @returns the JSON object
  48838. */
  48839. serialize(): any;
  48840. /**
  48841. * Parse properties from a JSON object
  48842. * @param serializationObject defines the JSON object
  48843. */
  48844. parse(serializationObject: any): void;
  48845. }
  48846. }
  48847. declare module BABYLON {
  48848. /**
  48849. * Particle emitter emitting particles from a point.
  48850. * It emits the particles randomly between 2 given directions.
  48851. */
  48852. class PointParticleEmitter implements IParticleEmitterType {
  48853. /**
  48854. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48855. */
  48856. direction1: Vector3;
  48857. /**
  48858. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48859. */
  48860. direction2: Vector3;
  48861. /**
  48862. * Creates a new instance PointParticleEmitter
  48863. */
  48864. constructor();
  48865. /**
  48866. * Called by the particle System when the direction is computed for the created particle.
  48867. * @param worldMatrix is the world matrix of the particle system
  48868. * @param directionToUpdate is the direction vector to update with the result
  48869. * @param particle is the particle we are computed the direction for
  48870. */
  48871. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48872. /**
  48873. * Called by the particle System when the position is computed for the created particle.
  48874. * @param worldMatrix is the world matrix of the particle system
  48875. * @param positionToUpdate is the position vector to update with the result
  48876. * @param particle is the particle we are computed the position for
  48877. */
  48878. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48879. /**
  48880. * Clones the current emitter and returns a copy of it
  48881. * @returns the new emitter
  48882. */
  48883. clone(): PointParticleEmitter;
  48884. /**
  48885. * Called by the GPUParticleSystem to setup the update shader
  48886. * @param effect defines the update shader
  48887. */
  48888. applyToShader(effect: Effect): void;
  48889. /**
  48890. * Returns a string to use to update the GPU particles update shader
  48891. * @returns a string containng the defines string
  48892. */
  48893. getEffectDefines(): string;
  48894. /**
  48895. * Returns the string "PointParticleEmitter"
  48896. * @returns a string containing the class name
  48897. */
  48898. getClassName(): string;
  48899. /**
  48900. * Serializes the particle system to a JSON object.
  48901. * @returns the JSON object
  48902. */
  48903. serialize(): any;
  48904. /**
  48905. * Parse properties from a JSON object
  48906. * @param serializationObject defines the JSON object
  48907. */
  48908. parse(serializationObject: any): void;
  48909. }
  48910. }
  48911. declare module BABYLON {
  48912. /**
  48913. * Particle emitter emitting particles from the inside of a sphere.
  48914. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  48915. */
  48916. class SphereParticleEmitter implements IParticleEmitterType {
  48917. /**
  48918. * The radius of the emission sphere.
  48919. */
  48920. radius: number;
  48921. /**
  48922. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48923. */
  48924. radiusRange: number;
  48925. /**
  48926. * How much to randomize the particle direction [0-1].
  48927. */
  48928. directionRandomizer: number;
  48929. /**
  48930. * Creates a new instance SphereParticleEmitter
  48931. * @param radius the radius of the emission sphere (1 by default)
  48932. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48933. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48934. */
  48935. constructor(
  48936. /**
  48937. * The radius of the emission sphere.
  48938. */
  48939. radius?: number,
  48940. /**
  48941. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48942. */
  48943. radiusRange?: number,
  48944. /**
  48945. * How much to randomize the particle direction [0-1].
  48946. */
  48947. directionRandomizer?: number);
  48948. /**
  48949. * Called by the particle System when the direction is computed for the created particle.
  48950. * @param worldMatrix is the world matrix of the particle system
  48951. * @param directionToUpdate is the direction vector to update with the result
  48952. * @param particle is the particle we are computed the direction for
  48953. */
  48954. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48955. /**
  48956. * Called by the particle System when the position is computed for the created particle.
  48957. * @param worldMatrix is the world matrix of the particle system
  48958. * @param positionToUpdate is the position vector to update with the result
  48959. * @param particle is the particle we are computed the position for
  48960. */
  48961. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48962. /**
  48963. * Clones the current emitter and returns a copy of it
  48964. * @returns the new emitter
  48965. */
  48966. clone(): SphereParticleEmitter;
  48967. /**
  48968. * Called by the GPUParticleSystem to setup the update shader
  48969. * @param effect defines the update shader
  48970. */
  48971. applyToShader(effect: Effect): void;
  48972. /**
  48973. * Returns a string to use to update the GPU particles update shader
  48974. * @returns a string containng the defines string
  48975. */
  48976. getEffectDefines(): string;
  48977. /**
  48978. * Returns the string "SphereParticleEmitter"
  48979. * @returns a string containing the class name
  48980. */
  48981. getClassName(): string;
  48982. /**
  48983. * Serializes the particle system to a JSON object.
  48984. * @returns the JSON object
  48985. */
  48986. serialize(): any;
  48987. /**
  48988. * Parse properties from a JSON object
  48989. * @param serializationObject defines the JSON object
  48990. */
  48991. parse(serializationObject: any): void;
  48992. }
  48993. /**
  48994. * Particle emitter emitting particles from the inside of a sphere.
  48995. * It emits the particles randomly between two vectors.
  48996. */
  48997. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  48998. /**
  48999. * The min limit of the emission direction.
  49000. */
  49001. direction1: Vector3;
  49002. /**
  49003. * The max limit of the emission direction.
  49004. */
  49005. direction2: Vector3;
  49006. /**
  49007. * Creates a new instance SphereDirectedParticleEmitter
  49008. * @param radius the radius of the emission sphere (1 by default)
  49009. * @param direction1 the min limit of the emission direction (up vector by default)
  49010. * @param direction2 the max limit of the emission direction (up vector by default)
  49011. */
  49012. constructor(radius?: number,
  49013. /**
  49014. * The min limit of the emission direction.
  49015. */
  49016. direction1?: Vector3,
  49017. /**
  49018. * The max limit of the emission direction.
  49019. */
  49020. direction2?: Vector3);
  49021. /**
  49022. * Called by the particle System when the direction is computed for the created particle.
  49023. * @param worldMatrix is the world matrix of the particle system
  49024. * @param directionToUpdate is the direction vector to update with the result
  49025. * @param particle is the particle we are computed the direction for
  49026. */
  49027. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49028. /**
  49029. * Clones the current emitter and returns a copy of it
  49030. * @returns the new emitter
  49031. */
  49032. clone(): SphereDirectedParticleEmitter;
  49033. /**
  49034. * Called by the GPUParticleSystem to setup the update shader
  49035. * @param effect defines the update shader
  49036. */
  49037. applyToShader(effect: Effect): void;
  49038. /**
  49039. * Returns a string to use to update the GPU particles update shader
  49040. * @returns a string containng the defines string
  49041. */
  49042. getEffectDefines(): string;
  49043. /**
  49044. * Returns the string "SphereDirectedParticleEmitter"
  49045. * @returns a string containing the class name
  49046. */
  49047. getClassName(): string;
  49048. /**
  49049. * Serializes the particle system to a JSON object.
  49050. * @returns the JSON object
  49051. */
  49052. serialize(): any;
  49053. /**
  49054. * Parse properties from a JSON object
  49055. * @param serializationObject defines the JSON object
  49056. */
  49057. parse(serializationObject: any): void;
  49058. }
  49059. }
  49060. declare module BABYLON {
  49061. /** @hidden */
  49062. class CannonJSPlugin implements IPhysicsEnginePlugin {
  49063. private _useDeltaForWorldStep;
  49064. world: any;
  49065. name: string;
  49066. private _physicsMaterials;
  49067. private _fixedTimeStep;
  49068. BJSCANNON: any;
  49069. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  49070. setGravity(gravity: Vector3): void;
  49071. setTimeStep(timeStep: number): void;
  49072. getTimeStep(): number;
  49073. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49074. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49075. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49076. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49077. private _processChildMeshes;
  49078. removePhysicsBody(impostor: PhysicsImpostor): void;
  49079. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49080. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49081. private _addMaterial;
  49082. private _checkWithEpsilon;
  49083. private _createShape;
  49084. private _createHeightmap;
  49085. private _minus90X;
  49086. private _plus90X;
  49087. private _tmpPosition;
  49088. private _tmpDeltaPosition;
  49089. private _tmpUnityRotation;
  49090. private _updatePhysicsBodyTransformation;
  49091. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49092. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49093. isSupported(): boolean;
  49094. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49095. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49096. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49097. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49098. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49099. getBodyMass(impostor: PhysicsImpostor): number;
  49100. getBodyFriction(impostor: PhysicsImpostor): number;
  49101. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49102. getBodyRestitution(impostor: PhysicsImpostor): number;
  49103. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49104. sleepBody(impostor: PhysicsImpostor): void;
  49105. wakeUpBody(impostor: PhysicsImpostor): void;
  49106. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49107. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49108. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49109. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49110. getRadius(impostor: PhysicsImpostor): number;
  49111. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49112. dispose(): void;
  49113. private _extendNamespace;
  49114. }
  49115. }
  49116. declare module BABYLON {
  49117. /** @hidden */
  49118. class OimoJSPlugin implements IPhysicsEnginePlugin {
  49119. world: any;
  49120. name: string;
  49121. BJSOIMO: any;
  49122. constructor(iterations?: number);
  49123. setGravity(gravity: Vector3): void;
  49124. setTimeStep(timeStep: number): void;
  49125. getTimeStep(): number;
  49126. private _tmpImpostorsArray;
  49127. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49128. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49129. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49130. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49131. private _tmpPositionVector;
  49132. removePhysicsBody(impostor: PhysicsImpostor): void;
  49133. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49134. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49135. isSupported(): boolean;
  49136. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49137. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49138. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49139. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49140. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49141. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49142. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49143. getBodyMass(impostor: PhysicsImpostor): number;
  49144. getBodyFriction(impostor: PhysicsImpostor): number;
  49145. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49146. getBodyRestitution(impostor: PhysicsImpostor): number;
  49147. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49148. sleepBody(impostor: PhysicsImpostor): void;
  49149. wakeUpBody(impostor: PhysicsImpostor): void;
  49150. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49151. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  49152. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49153. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49154. getRadius(impostor: PhysicsImpostor): number;
  49155. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49156. dispose(): void;
  49157. }
  49158. }
  49159. declare module BABYLON {
  49160. /**
  49161. * This represents a set of one or more post processes in Babylon.
  49162. * A post process can be used to apply a shader to a texture after it is rendered.
  49163. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49164. */
  49165. class PostProcessRenderEffect {
  49166. private _postProcesses;
  49167. private _getPostProcesses;
  49168. private _singleInstance;
  49169. private _cameras;
  49170. private _indicesForCamera;
  49171. /**
  49172. * Name of the effect
  49173. * @hidden
  49174. */
  49175. _name: string;
  49176. /**
  49177. * Instantiates a post process render effect.
  49178. * A post process can be used to apply a shader to a texture after it is rendered.
  49179. * @param engine The engine the effect is tied to
  49180. * @param name The name of the effect
  49181. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49182. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49183. */
  49184. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49185. /**
  49186. * Checks if all the post processes in the effect are supported.
  49187. */
  49188. readonly isSupported: boolean;
  49189. /**
  49190. * Updates the current state of the effect
  49191. * @hidden
  49192. */
  49193. _update(): void;
  49194. /**
  49195. * Attaches the effect on cameras
  49196. * @param cameras The camera to attach to.
  49197. * @hidden
  49198. */
  49199. _attachCameras(cameras: Camera): void;
  49200. /**
  49201. * Attaches the effect on cameras
  49202. * @param cameras The camera to attach to.
  49203. * @hidden
  49204. */
  49205. _attachCameras(cameras: Camera[]): void;
  49206. /**
  49207. * Detatches the effect on cameras
  49208. * @param cameras The camera to detatch from.
  49209. * @hidden
  49210. */
  49211. _detachCameras(cameras: Camera): void;
  49212. /**
  49213. * Detatches the effect on cameras
  49214. * @param cameras The camera to detatch from.
  49215. * @hidden
  49216. */
  49217. _detachCameras(cameras: Camera[]): void;
  49218. /**
  49219. * Enables the effect on given cameras
  49220. * @param cameras The camera to enable.
  49221. * @hidden
  49222. */
  49223. _enable(cameras: Camera): void;
  49224. /**
  49225. * Enables the effect on given cameras
  49226. * @param cameras The camera to enable.
  49227. * @hidden
  49228. */
  49229. _enable(cameras: Nullable<Camera[]>): void;
  49230. /**
  49231. * Disables the effect on the given cameras
  49232. * @param cameras The camera to disable.
  49233. * @hidden
  49234. */
  49235. _disable(cameras: Camera): void;
  49236. /**
  49237. * Disables the effect on the given cameras
  49238. * @param cameras The camera to disable.
  49239. * @hidden
  49240. */
  49241. _disable(cameras: Nullable<Camera[]>): void;
  49242. /**
  49243. * Gets a list of the post processes contained in the effect.
  49244. * @param camera The camera to get the post processes on.
  49245. * @returns The list of the post processes in the effect.
  49246. */
  49247. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  49248. }
  49249. }
  49250. declare module BABYLON {
  49251. /**
  49252. * PostProcessRenderPipeline
  49253. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49254. */
  49255. class PostProcessRenderPipeline {
  49256. private engine;
  49257. private _renderEffects;
  49258. private _renderEffectsForIsolatedPass;
  49259. /**
  49260. * @hidden
  49261. */
  49262. protected _cameras: Camera[];
  49263. /** @hidden */
  49264. _name: string;
  49265. /**
  49266. * Initializes a PostProcessRenderPipeline
  49267. * @param engine engine to add the pipeline to
  49268. * @param name name of the pipeline
  49269. */
  49270. constructor(engine: Engine, name: string);
  49271. /**
  49272. * "PostProcessRenderPipeline"
  49273. * @returns "PostProcessRenderPipeline"
  49274. */
  49275. getClassName(): string;
  49276. /**
  49277. * If all the render effects in the pipeline are support
  49278. */
  49279. readonly isSupported: boolean;
  49280. /**
  49281. * Adds an effect to the pipeline
  49282. * @param renderEffect the effect to add
  49283. */
  49284. addEffect(renderEffect: PostProcessRenderEffect): void;
  49285. /** @hidden */
  49286. _rebuild(): void;
  49287. /** @hidden */
  49288. _enableEffect(renderEffectName: string, cameras: Camera): void;
  49289. /** @hidden */
  49290. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49291. /** @hidden */
  49292. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49293. /** @hidden */
  49294. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49295. /** @hidden */
  49296. _attachCameras(cameras: Camera, unique: boolean): void;
  49297. /** @hidden */
  49298. _attachCameras(cameras: Camera[], unique: boolean): void;
  49299. /** @hidden */
  49300. _detachCameras(cameras: Camera): void;
  49301. /** @hidden */
  49302. _detachCameras(cameras: Nullable<Camera[]>): void;
  49303. /** @hidden */
  49304. _update(): void;
  49305. /** @hidden */
  49306. _reset(): void;
  49307. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49308. /**
  49309. * Disposes of the pipeline
  49310. */
  49311. dispose(): void;
  49312. }
  49313. }
  49314. declare module BABYLON {
  49315. /**
  49316. * PostProcessRenderPipelineManager class
  49317. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49318. */
  49319. class PostProcessRenderPipelineManager {
  49320. private _renderPipelines;
  49321. /**
  49322. * Initializes a PostProcessRenderPipelineManager
  49323. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49324. */
  49325. constructor();
  49326. /**
  49327. * Adds a pipeline to the manager
  49328. * @param renderPipeline The pipeline to add
  49329. */
  49330. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  49331. /**
  49332. * Attaches a camera to the pipeline
  49333. * @param renderPipelineName The name of the pipeline to attach to
  49334. * @param cameras the camera to attach
  49335. * @param unique if the camera can be attached multiple times to the pipeline
  49336. */
  49337. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  49338. /**
  49339. * Detaches a camera from the pipeline
  49340. * @param renderPipelineName The name of the pipeline to detach from
  49341. * @param cameras the camera to detach
  49342. */
  49343. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  49344. /**
  49345. * Enables an effect by name on a pipeline
  49346. * @param renderPipelineName the name of the pipeline to enable the effect in
  49347. * @param renderEffectName the name of the effect to enable
  49348. * @param cameras the cameras that the effect should be enabled on
  49349. */
  49350. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49351. /**
  49352. * Disables an effect by name on a pipeline
  49353. * @param renderPipelineName the name of the pipeline to disable the effect in
  49354. * @param renderEffectName the name of the effect to disable
  49355. * @param cameras the cameras that the effect should be disabled on
  49356. */
  49357. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49358. /**
  49359. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  49360. */
  49361. update(): void;
  49362. /** @hidden */
  49363. _rebuild(): void;
  49364. /**
  49365. * Disposes of the manager and pipelines
  49366. */
  49367. dispose(): void;
  49368. }
  49369. }
  49370. declare module BABYLON {
  49371. interface Scene {
  49372. /** @hidden (Backing field) */
  49373. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49374. /**
  49375. * Gets the postprocess render pipeline manager
  49376. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49377. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49378. */
  49379. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49380. }
  49381. /**
  49382. * Defines the Render Pipeline scene component responsible to rendering pipelines
  49383. */
  49384. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  49385. /**
  49386. * The component name helpfull to identify the component in the list of scene components.
  49387. */
  49388. readonly name: string;
  49389. /**
  49390. * The scene the component belongs to.
  49391. */
  49392. scene: Scene;
  49393. /**
  49394. * Creates a new instance of the component for the given scene
  49395. * @param scene Defines the scene to register the component in
  49396. */
  49397. constructor(scene: Scene);
  49398. /**
  49399. * Registers the component in a given scene
  49400. */
  49401. register(): void;
  49402. /**
  49403. * Rebuilds the elements related to this component in case of
  49404. * context lost for instance.
  49405. */
  49406. rebuild(): void;
  49407. /**
  49408. * Disposes the component and the associated ressources
  49409. */
  49410. dispose(): void;
  49411. private _gatherRenderTargets;
  49412. }
  49413. }
  49414. declare module BABYLON {
  49415. /**
  49416. * Helper class dealing with the extraction of spherical polynomial dataArray
  49417. * from a cube map.
  49418. */
  49419. class CubeMapToSphericalPolynomialTools {
  49420. private static FileFaces;
  49421. /**
  49422. * Converts a texture to the according Spherical Polynomial data.
  49423. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49424. *
  49425. * @param texture The texture to extract the information from.
  49426. * @return The Spherical Polynomial data.
  49427. */
  49428. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49429. /**
  49430. * Converts a cubemap to the according Spherical Polynomial data.
  49431. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49432. *
  49433. * @param cubeInfo The Cube map to extract the information from.
  49434. * @return The Spherical Polynomial data.
  49435. */
  49436. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49437. }
  49438. }
  49439. declare module BABYLON {
  49440. /**
  49441. * Header information of HDR texture files.
  49442. */
  49443. interface HDRInfo {
  49444. /**
  49445. * The height of the texture in pixels.
  49446. */
  49447. height: number;
  49448. /**
  49449. * The width of the texture in pixels.
  49450. */
  49451. width: number;
  49452. /**
  49453. * The index of the beginning of the data in the binary file.
  49454. */
  49455. dataPosition: number;
  49456. }
  49457. /**
  49458. * This groups tools to convert HDR texture to native colors array.
  49459. */
  49460. class HDRTools {
  49461. private static Ldexp;
  49462. private static Rgbe2float;
  49463. private static readStringLine;
  49464. /**
  49465. * Reads header information from an RGBE texture stored in a native array.
  49466. * More information on this format are available here:
  49467. * https://en.wikipedia.org/wiki/RGBE_image_format
  49468. *
  49469. * @param uint8array The binary file stored in native array.
  49470. * @return The header information.
  49471. */
  49472. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49473. /**
  49474. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49475. * This RGBE texture needs to store the information as a panorama.
  49476. *
  49477. * More information on this format are available here:
  49478. * https://en.wikipedia.org/wiki/RGBE_image_format
  49479. *
  49480. * @param buffer The binary file stored in an array buffer.
  49481. * @param size The expected size of the extracted cubemap.
  49482. * @return The Cube Map information.
  49483. */
  49484. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49485. /**
  49486. * Returns the pixels data extracted from an RGBE texture.
  49487. * This pixels will be stored left to right up to down in the R G B order in one array.
  49488. *
  49489. * More information on this format are available here:
  49490. * https://en.wikipedia.org/wiki/RGBE_image_format
  49491. *
  49492. * @param uint8array The binary file stored in an array buffer.
  49493. * @param hdrInfo The header information of the file.
  49494. * @return The pixels data in RGB right to left up to down order.
  49495. */
  49496. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49497. private static RGBE_ReadPixels_RLE;
  49498. }
  49499. }
  49500. declare module BABYLON {
  49501. /**
  49502. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49503. */
  49504. interface CubeMapInfo {
  49505. /**
  49506. * The pixel array for the front face.
  49507. * This is stored in format, left to right, up to down format.
  49508. */
  49509. front: Nullable<ArrayBufferView>;
  49510. /**
  49511. * The pixel array for the back face.
  49512. * This is stored in format, left to right, up to down format.
  49513. */
  49514. back: Nullable<ArrayBufferView>;
  49515. /**
  49516. * The pixel array for the left face.
  49517. * This is stored in format, left to right, up to down format.
  49518. */
  49519. left: Nullable<ArrayBufferView>;
  49520. /**
  49521. * The pixel array for the right face.
  49522. * This is stored in format, left to right, up to down format.
  49523. */
  49524. right: Nullable<ArrayBufferView>;
  49525. /**
  49526. * The pixel array for the up face.
  49527. * This is stored in format, left to right, up to down format.
  49528. */
  49529. up: Nullable<ArrayBufferView>;
  49530. /**
  49531. * The pixel array for the down face.
  49532. * This is stored in format, left to right, up to down format.
  49533. */
  49534. down: Nullable<ArrayBufferView>;
  49535. /**
  49536. * The size of the cubemap stored.
  49537. *
  49538. * Each faces will be size * size pixels.
  49539. */
  49540. size: number;
  49541. /**
  49542. * The format of the texture.
  49543. *
  49544. * RGBA, RGB.
  49545. */
  49546. format: number;
  49547. /**
  49548. * The type of the texture data.
  49549. *
  49550. * UNSIGNED_INT, FLOAT.
  49551. */
  49552. type: number;
  49553. /**
  49554. * Specifies whether the texture is in gamma space.
  49555. */
  49556. gammaSpace: boolean;
  49557. }
  49558. /**
  49559. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  49560. */
  49561. class PanoramaToCubeMapTools {
  49562. private static FACE_FRONT;
  49563. private static FACE_BACK;
  49564. private static FACE_RIGHT;
  49565. private static FACE_LEFT;
  49566. private static FACE_DOWN;
  49567. private static FACE_UP;
  49568. /**
  49569. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49570. *
  49571. * @param float32Array The source data.
  49572. * @param inputWidth The width of the input panorama.
  49573. * @param inputHeight The height of the input panorama.
  49574. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49575. * @return The cubemap data
  49576. */
  49577. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49578. private static CreateCubemapTexture;
  49579. private static CalcProjectionSpherical;
  49580. }
  49581. }
  49582. declare module BABYLON {
  49583. /**
  49584. * 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.
  49585. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49586. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49587. */
  49588. class CustomProceduralTexture extends ProceduralTexture {
  49589. private _animate;
  49590. private _time;
  49591. private _config;
  49592. private _texturePath;
  49593. /**
  49594. * Instantiates a new Custom Procedural Texture.
  49595. * 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.
  49596. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49597. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49598. * @param name Define the name of the texture
  49599. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49600. * @param size Define the size of the texture to create
  49601. * @param scene Define the scene the texture belongs to
  49602. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49603. * @param generateMipMaps Define if the texture should creates mip maps or not
  49604. */
  49605. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49606. private _loadJson;
  49607. /**
  49608. * Is the texture ready to be used ? (rendered at least once)
  49609. * @returns true if ready, otherwise, false.
  49610. */
  49611. isReady(): boolean;
  49612. /**
  49613. * Render the texture to its associated render target.
  49614. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49615. */
  49616. render(useCameraPostProcess?: boolean): void;
  49617. /**
  49618. * Update the list of dependant textures samplers in the shader.
  49619. */
  49620. updateTextures(): void;
  49621. /**
  49622. * Update the uniform values of the procedural texture in the shader.
  49623. */
  49624. updateShaderUniforms(): void;
  49625. /**
  49626. * Define if the texture animates or not.
  49627. */
  49628. animate: boolean;
  49629. }
  49630. }
  49631. declare module BABYLON {
  49632. /**
  49633. * Class used to generate noise procedural textures
  49634. */
  49635. class NoiseProceduralTexture extends ProceduralTexture {
  49636. private _time;
  49637. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49638. brightness: number;
  49639. /** Defines the number of octaves to process */
  49640. octaves: number;
  49641. /** Defines the level of persistence (0.8 by default) */
  49642. persistence: number;
  49643. /** Gets or sets animation speed factor (default is 1) */
  49644. animationSpeedFactor: number;
  49645. /**
  49646. * Creates a new NoiseProceduralTexture
  49647. * @param name defines the name fo the texture
  49648. * @param size defines the size of the texture (default is 256)
  49649. * @param scene defines the hosting scene
  49650. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49651. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49652. */
  49653. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49654. private _updateShaderUniforms;
  49655. protected _getDefines(): string;
  49656. /** Generate the current state of the procedural texture */
  49657. render(useCameraPostProcess?: boolean): void;
  49658. /**
  49659. * Serializes this noise procedural texture
  49660. * @returns a serialized noise procedural texture object
  49661. */
  49662. serialize(): any;
  49663. /**
  49664. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49665. * @param parsedTexture defines parsed texture data
  49666. * @param scene defines the current scene
  49667. * @param rootUrl defines the root URL containing noise procedural texture information
  49668. * @returns a parsed NoiseProceduralTexture
  49669. */
  49670. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  49671. }
  49672. }
  49673. declare module BABYLON {
  49674. /**
  49675. * 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.
  49676. * This is the base class of any Procedural texture and contains most of the shareable code.
  49677. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49678. */
  49679. class ProceduralTexture extends Texture {
  49680. isCube: boolean;
  49681. /**
  49682. * Define if the texture is enabled or not (disabled texture will not render)
  49683. */
  49684. isEnabled: boolean;
  49685. /**
  49686. * Define if the texture must be cleared before rendering (default is true)
  49687. */
  49688. autoClear: boolean;
  49689. /**
  49690. * Callback called when the texture is generated
  49691. */
  49692. onGenerated: () => void;
  49693. /**
  49694. * Event raised when the texture is generated
  49695. */
  49696. onGeneratedObservable: Observable<ProceduralTexture>;
  49697. /** @hidden */
  49698. _generateMipMaps: boolean;
  49699. /** @hidden **/
  49700. _effect: Effect;
  49701. /** @hidden */
  49702. _textures: {
  49703. [key: string]: Texture;
  49704. };
  49705. private _size;
  49706. private _currentRefreshId;
  49707. private _refreshRate;
  49708. private _vertexBuffers;
  49709. private _indexBuffer;
  49710. private _uniforms;
  49711. private _samplers;
  49712. private _fragment;
  49713. private _floats;
  49714. private _ints;
  49715. private _floatsArrays;
  49716. private _colors3;
  49717. private _colors4;
  49718. private _vectors2;
  49719. private _vectors3;
  49720. private _matrices;
  49721. private _fallbackTexture;
  49722. private _fallbackTextureUsed;
  49723. private _engine;
  49724. private _cachedDefines;
  49725. private _contentUpdateId;
  49726. private _contentData;
  49727. /**
  49728. * Instantiates a new procedural texture.
  49729. * 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.
  49730. * This is the base class of any Procedural texture and contains most of the shareable code.
  49731. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49732. * @param name Define the name of the texture
  49733. * @param size Define the size of the texture to create
  49734. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  49735. * @param scene Define the scene the texture belongs to
  49736. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49737. * @param generateMipMaps Define if the texture should creates mip maps or not
  49738. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  49739. */
  49740. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  49741. /**
  49742. * The effect that is created when initializing the post process.
  49743. * @returns The created effect corrisponding the the postprocess.
  49744. */
  49745. getEffect(): Effect;
  49746. /**
  49747. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  49748. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  49749. */
  49750. getContent(): Nullable<ArrayBufferView>;
  49751. private _createIndexBuffer;
  49752. /** @hidden */
  49753. _rebuild(): void;
  49754. /**
  49755. * Resets the texture in order to recreate its associated resources.
  49756. * This can be called in case of context loss
  49757. */
  49758. reset(): void;
  49759. protected _getDefines(): string;
  49760. /**
  49761. * Is the texture ready to be used ? (rendered at least once)
  49762. * @returns true if ready, otherwise, false.
  49763. */
  49764. isReady(): boolean;
  49765. /**
  49766. * Resets the refresh counter of the texture and start bak from scratch.
  49767. * Could be usefull to regenerate the texture if it is setup to render only once.
  49768. */
  49769. resetRefreshCounter(): void;
  49770. /**
  49771. * Set the fragment shader to use in order to render the texture.
  49772. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  49773. */
  49774. setFragment(fragment: any): void;
  49775. /**
  49776. * Define the refresh rate of the texture or the rendering frequency.
  49777. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  49778. */
  49779. refreshRate: number;
  49780. /** @hidden */
  49781. _shouldRender(): boolean;
  49782. /**
  49783. * Get the size the texture is rendering at.
  49784. * @returns the size (texture is always squared)
  49785. */
  49786. getRenderSize(): number;
  49787. /**
  49788. * Resize the texture to new value.
  49789. * @param size Define the new size the texture should have
  49790. * @param generateMipMaps Define whether the new texture should create mip maps
  49791. */
  49792. resize(size: number, generateMipMaps: boolean): void;
  49793. private _checkUniform;
  49794. /**
  49795. * Set a texture in the shader program used to render.
  49796. * @param name Define the name of the uniform samplers as defined in the shader
  49797. * @param texture Define the texture to bind to this sampler
  49798. * @return the texture itself allowing "fluent" like uniform updates
  49799. */
  49800. setTexture(name: string, texture: Texture): ProceduralTexture;
  49801. /**
  49802. * Set a float in the shader.
  49803. * @param name Define the name of the uniform as defined in the shader
  49804. * @param value Define the value to give to the uniform
  49805. * @return the texture itself allowing "fluent" like uniform updates
  49806. */
  49807. setFloat(name: string, value: number): ProceduralTexture;
  49808. /**
  49809. * Set a int in the shader.
  49810. * @param name Define the name of the uniform as defined in the shader
  49811. * @param value Define the value to give to the uniform
  49812. * @return the texture itself allowing "fluent" like uniform updates
  49813. */
  49814. setInt(name: string, value: number): ProceduralTexture;
  49815. /**
  49816. * Set an array of floats in the shader.
  49817. * @param name Define the name of the uniform as defined in the shader
  49818. * @param value Define the value to give to the uniform
  49819. * @return the texture itself allowing "fluent" like uniform updates
  49820. */
  49821. setFloats(name: string, value: number[]): ProceduralTexture;
  49822. /**
  49823. * Set a vec3 in the shader from a Color3.
  49824. * @param name Define the name of the uniform as defined in the shader
  49825. * @param value Define the value to give to the uniform
  49826. * @return the texture itself allowing "fluent" like uniform updates
  49827. */
  49828. setColor3(name: string, value: Color3): ProceduralTexture;
  49829. /**
  49830. * Set a vec4 in the shader from a Color4.
  49831. * @param name Define the name of the uniform as defined in the shader
  49832. * @param value Define the value to give to the uniform
  49833. * @return the texture itself allowing "fluent" like uniform updates
  49834. */
  49835. setColor4(name: string, value: Color4): ProceduralTexture;
  49836. /**
  49837. * Set a vec2 in the shader from a Vector2.
  49838. * @param name Define the name of the uniform as defined in the shader
  49839. * @param value Define the value to give to the uniform
  49840. * @return the texture itself allowing "fluent" like uniform updates
  49841. */
  49842. setVector2(name: string, value: Vector2): ProceduralTexture;
  49843. /**
  49844. * Set a vec3 in the shader from a Vector3.
  49845. * @param name Define the name of the uniform as defined in the shader
  49846. * @param value Define the value to give to the uniform
  49847. * @return the texture itself allowing "fluent" like uniform updates
  49848. */
  49849. setVector3(name: string, value: Vector3): ProceduralTexture;
  49850. /**
  49851. * Set a mat4 in the shader from a MAtrix.
  49852. * @param name Define the name of the uniform as defined in the shader
  49853. * @param value Define the value to give to the uniform
  49854. * @return the texture itself allowing "fluent" like uniform updates
  49855. */
  49856. setMatrix(name: string, value: Matrix): ProceduralTexture;
  49857. /**
  49858. * Render the texture to its associated render target.
  49859. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49860. */
  49861. render(useCameraPostProcess?: boolean): void;
  49862. /**
  49863. * Clone the texture.
  49864. * @returns the cloned texture
  49865. */
  49866. clone(): ProceduralTexture;
  49867. /**
  49868. * Dispose the texture and release its asoociated resources.
  49869. */
  49870. dispose(): void;
  49871. }
  49872. }
  49873. declare module BABYLON {
  49874. interface AbstractScene {
  49875. /**
  49876. * The list of procedural textures added to the scene
  49877. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49878. */
  49879. proceduralTextures: Array<ProceduralTexture>;
  49880. }
  49881. /**
  49882. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  49883. * in a given scene.
  49884. */
  49885. class ProceduralTextureSceneComponent implements ISceneComponent {
  49886. /**
  49887. * The component name helpfull to identify the component in the list of scene components.
  49888. */
  49889. readonly name: string;
  49890. /**
  49891. * The scene the component belongs to.
  49892. */
  49893. scene: Scene;
  49894. /**
  49895. * Creates a new instance of the component for the given scene
  49896. * @param scene Defines the scene to register the component in
  49897. */
  49898. constructor(scene: Scene);
  49899. /**
  49900. * Registers the component in a given scene
  49901. */
  49902. register(): void;
  49903. /**
  49904. * Rebuilds the elements related to this component in case of
  49905. * context lost for instance.
  49906. */
  49907. rebuild(): void;
  49908. /**
  49909. * Disposes the component and the associated ressources.
  49910. */
  49911. dispose(): void;
  49912. private _beforeClear;
  49913. }
  49914. }
  49915. declare module BABYLON {
  49916. }
  49917. declare module BABYLON {
  49918. }
  49919. declare module BABYLON {
  49920. }
  49921. declare module BABYLON {
  49922. }
  49923. declare module BABYLON {
  49924. /**
  49925. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  49926. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49927. */
  49928. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49929. private _scene;
  49930. private _camerasToBeAttached;
  49931. /**
  49932. * ID of the sharpen post process,
  49933. */
  49934. private readonly SharpenPostProcessId;
  49935. /**
  49936. * @ignore
  49937. * ID of the image processing post process;
  49938. */
  49939. readonly ImageProcessingPostProcessId: string;
  49940. /**
  49941. * @ignore
  49942. * ID of the Fast Approximate Anti-Aliasing post process;
  49943. */
  49944. readonly FxaaPostProcessId: string;
  49945. /**
  49946. * ID of the chromatic aberration post process,
  49947. */
  49948. private readonly ChromaticAberrationPostProcessId;
  49949. /**
  49950. * ID of the grain post process
  49951. */
  49952. private readonly GrainPostProcessId;
  49953. /**
  49954. * Sharpen post process which will apply a sharpen convolution to enhance edges
  49955. */
  49956. sharpen: SharpenPostProcess;
  49957. private _sharpenEffect;
  49958. private bloom;
  49959. /**
  49960. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  49961. */
  49962. depthOfField: DepthOfFieldEffect;
  49963. /**
  49964. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  49965. */
  49966. fxaa: FxaaPostProcess;
  49967. /**
  49968. * Image post processing pass used to perform operations such as tone mapping or color grading.
  49969. */
  49970. imageProcessing: ImageProcessingPostProcess;
  49971. /**
  49972. * Chromatic aberration post process which will shift rgb colors in the image
  49973. */
  49974. chromaticAberration: ChromaticAberrationPostProcess;
  49975. private _chromaticAberrationEffect;
  49976. /**
  49977. * Grain post process which add noise to the image
  49978. */
  49979. grain: GrainPostProcess;
  49980. private _grainEffect;
  49981. /**
  49982. * Glow post process which adds a glow to emmisive areas of the image
  49983. */
  49984. private _glowLayer;
  49985. /**
  49986. * Animations which can be used to tweak settings over a period of time
  49987. */
  49988. animations: Animation[];
  49989. private _imageProcessingConfigurationObserver;
  49990. private _sharpenEnabled;
  49991. private _bloomEnabled;
  49992. private _depthOfFieldEnabled;
  49993. private _depthOfFieldBlurLevel;
  49994. private _fxaaEnabled;
  49995. private _imageProcessingEnabled;
  49996. private _defaultPipelineTextureType;
  49997. private _bloomScale;
  49998. private _chromaticAberrationEnabled;
  49999. private _grainEnabled;
  50000. private _buildAllowed;
  50001. /**
  50002. * Enable or disable the sharpen process from the pipeline
  50003. */
  50004. sharpenEnabled: boolean;
  50005. private _resizeObserver;
  50006. private _hardwareScaleLevel;
  50007. private _bloomKernel;
  50008. /**
  50009. * Specifies the size of the bloom blur kernel, relative to the final output size
  50010. */
  50011. bloomKernel: number;
  50012. /**
  50013. * Specifies the weight of the bloom in the final rendering
  50014. */
  50015. private _bloomWeight;
  50016. /**
  50017. * Specifies the luma threshold for the area that will be blurred by the bloom
  50018. */
  50019. private _bloomThreshold;
  50020. private _hdr;
  50021. /**
  50022. * The strength of the bloom.
  50023. */
  50024. bloomWeight: number;
  50025. /**
  50026. * The strength of the bloom.
  50027. */
  50028. bloomThreshold: number;
  50029. /**
  50030. * The scale of the bloom, lower value will provide better performance.
  50031. */
  50032. bloomScale: number;
  50033. /**
  50034. * Enable or disable the bloom from the pipeline
  50035. */
  50036. bloomEnabled: boolean;
  50037. private _rebuildBloom;
  50038. /**
  50039. * If the depth of field is enabled.
  50040. */
  50041. depthOfFieldEnabled: boolean;
  50042. /**
  50043. * Blur level of the depth of field effect. (Higher blur will effect performance)
  50044. */
  50045. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  50046. /**
  50047. * If the anti aliasing is enabled.
  50048. */
  50049. fxaaEnabled: boolean;
  50050. private _samples;
  50051. /**
  50052. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50053. */
  50054. samples: number;
  50055. /**
  50056. * If image processing is enabled.
  50057. */
  50058. imageProcessingEnabled: boolean;
  50059. /**
  50060. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  50061. */
  50062. glowLayerEnabled: boolean;
  50063. /**
  50064. * Enable or disable the chromaticAberration process from the pipeline
  50065. */
  50066. chromaticAberrationEnabled: boolean;
  50067. /**
  50068. * Enable or disable the grain process from the pipeline
  50069. */
  50070. grainEnabled: boolean;
  50071. /**
  50072. * @constructor
  50073. * @param name - The rendering pipeline name (default: "")
  50074. * @param hdr - If high dynamic range textures should be used (default: true)
  50075. * @param scene - The scene linked to this pipeline (default: the last created scene)
  50076. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  50077. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  50078. */
  50079. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  50080. /**
  50081. * Force the compilation of the entire pipeline.
  50082. */
  50083. prepare(): void;
  50084. private _hasCleared;
  50085. private _prevPostProcess;
  50086. private _prevPrevPostProcess;
  50087. private _setAutoClearAndTextureSharing;
  50088. private _depthOfFieldSceneObserver;
  50089. private _buildPipeline;
  50090. private _disposePostProcesses;
  50091. /**
  50092. * Adds a camera to the pipeline
  50093. * @param camera the camera to be added
  50094. */
  50095. addCamera(camera: Camera): void;
  50096. /**
  50097. * Removes a camera from the pipeline
  50098. * @param camera the camera to remove
  50099. */
  50100. removeCamera(camera: Camera): void;
  50101. /**
  50102. * Dispose of the pipeline and stop all post processes
  50103. */
  50104. dispose(): void;
  50105. /**
  50106. * Serialize the rendering pipeline (Used when exporting)
  50107. * @returns the serialized object
  50108. */
  50109. serialize(): any;
  50110. /**
  50111. * Parse the serialized pipeline
  50112. * @param source Source pipeline.
  50113. * @param scene The scene to load the pipeline to.
  50114. * @param rootUrl The URL of the serialized pipeline.
  50115. * @returns An instantiated pipeline from the serialized object.
  50116. */
  50117. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  50118. }
  50119. }
  50120. declare module BABYLON {
  50121. /**
  50122. * BABYLON.JS Chromatic Aberration GLSL Shader
  50123. * Author: Olivier Guyot
  50124. * Separates very slightly R, G and B colors on the edges of the screen
  50125. * Inspired by Francois Tarlier & Martins Upitis
  50126. */
  50127. class LensRenderingPipeline extends PostProcessRenderPipeline {
  50128. /**
  50129. * @ignore
  50130. * The chromatic aberration PostProcess id in the pipeline
  50131. */
  50132. LensChromaticAberrationEffect: string;
  50133. /**
  50134. * @ignore
  50135. * The highlights enhancing PostProcess id in the pipeline
  50136. */
  50137. HighlightsEnhancingEffect: string;
  50138. /**
  50139. * @ignore
  50140. * The depth-of-field PostProcess id in the pipeline
  50141. */
  50142. LensDepthOfFieldEffect: string;
  50143. private _scene;
  50144. private _depthTexture;
  50145. private _grainTexture;
  50146. private _chromaticAberrationPostProcess;
  50147. private _highlightsPostProcess;
  50148. private _depthOfFieldPostProcess;
  50149. private _edgeBlur;
  50150. private _grainAmount;
  50151. private _chromaticAberration;
  50152. private _distortion;
  50153. private _highlightsGain;
  50154. private _highlightsThreshold;
  50155. private _dofDistance;
  50156. private _dofAperture;
  50157. private _dofDarken;
  50158. private _dofPentagon;
  50159. private _blurNoise;
  50160. /**
  50161. * @constructor
  50162. *
  50163. * Effect parameters are as follow:
  50164. * {
  50165. * chromatic_aberration: number; // from 0 to x (1 for realism)
  50166. * edge_blur: number; // from 0 to x (1 for realism)
  50167. * distortion: number; // from 0 to x (1 for realism)
  50168. * grain_amount: number; // from 0 to 1
  50169. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  50170. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  50171. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  50172. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  50173. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  50174. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  50175. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  50176. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  50177. * }
  50178. * Note: if an effect parameter is unset, effect is disabled
  50179. *
  50180. * @param name The rendering pipeline name
  50181. * @param parameters - An object containing all parameters (see above)
  50182. * @param scene The scene linked to this pipeline
  50183. * @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)
  50184. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50185. */
  50186. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  50187. /**
  50188. * Sets the amount of blur at the edges
  50189. * @param amount blur amount
  50190. */
  50191. setEdgeBlur(amount: number): void;
  50192. /**
  50193. * Sets edge blur to 0
  50194. */
  50195. disableEdgeBlur(): void;
  50196. /**
  50197. * Sets the amout of grain
  50198. * @param amount Amount of grain
  50199. */
  50200. setGrainAmount(amount: number): void;
  50201. /**
  50202. * Set grain amount to 0
  50203. */
  50204. disableGrain(): void;
  50205. /**
  50206. * Sets the chromatic aberration amount
  50207. * @param amount amount of chromatic aberration
  50208. */
  50209. setChromaticAberration(amount: number): void;
  50210. /**
  50211. * Sets chromatic aberration amount to 0
  50212. */
  50213. disableChromaticAberration(): void;
  50214. /**
  50215. * Sets the EdgeDistortion amount
  50216. * @param amount amount of EdgeDistortion
  50217. */
  50218. setEdgeDistortion(amount: number): void;
  50219. /**
  50220. * Sets edge distortion to 0
  50221. */
  50222. disableEdgeDistortion(): void;
  50223. /**
  50224. * Sets the FocusDistance amount
  50225. * @param amount amount of FocusDistance
  50226. */
  50227. setFocusDistance(amount: number): void;
  50228. /**
  50229. * Disables depth of field
  50230. */
  50231. disableDepthOfField(): void;
  50232. /**
  50233. * Sets the Aperture amount
  50234. * @param amount amount of Aperture
  50235. */
  50236. setAperture(amount: number): void;
  50237. /**
  50238. * Sets the DarkenOutOfFocus amount
  50239. * @param amount amount of DarkenOutOfFocus
  50240. */
  50241. setDarkenOutOfFocus(amount: number): void;
  50242. /**
  50243. * Creates a pentagon bokeh effect
  50244. */
  50245. enablePentagonBokeh(): void;
  50246. /**
  50247. * Disables the pentagon bokeh effect
  50248. */
  50249. disablePentagonBokeh(): void;
  50250. /**
  50251. * Enables noise blur
  50252. */
  50253. enableNoiseBlur(): void;
  50254. /**
  50255. * Disables noise blur
  50256. */
  50257. disableNoiseBlur(): void;
  50258. /**
  50259. * Sets the HighlightsGain amount
  50260. * @param amount amount of HighlightsGain
  50261. */
  50262. setHighlightsGain(amount: number): void;
  50263. /**
  50264. * Sets the HighlightsThreshold amount
  50265. * @param amount amount of HighlightsThreshold
  50266. */
  50267. setHighlightsThreshold(amount: number): void;
  50268. /**
  50269. * Disables highlights
  50270. */
  50271. disableHighlights(): void;
  50272. /**
  50273. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50274. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50275. */
  50276. dispose(disableDepthRender?: boolean): void;
  50277. private _createChromaticAberrationPostProcess;
  50278. private _createHighlightsPostProcess;
  50279. private _createDepthOfFieldPostProcess;
  50280. private _createGrainTexture;
  50281. }
  50282. }
  50283. declare module BABYLON {
  50284. /**
  50285. * Render pipeline to produce ssao effect
  50286. */
  50287. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50288. /**
  50289. * @ignore
  50290. * The PassPostProcess id in the pipeline that contains the original scene color
  50291. */
  50292. SSAOOriginalSceneColorEffect: string;
  50293. /**
  50294. * @ignore
  50295. * The SSAO PostProcess id in the pipeline
  50296. */
  50297. SSAORenderEffect: string;
  50298. /**
  50299. * @ignore
  50300. * The horizontal blur PostProcess id in the pipeline
  50301. */
  50302. SSAOBlurHRenderEffect: string;
  50303. /**
  50304. * @ignore
  50305. * The vertical blur PostProcess id in the pipeline
  50306. */
  50307. SSAOBlurVRenderEffect: string;
  50308. /**
  50309. * @ignore
  50310. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50311. */
  50312. SSAOCombineRenderEffect: string;
  50313. /**
  50314. * The output strength of the SSAO post-process. Default value is 1.0.
  50315. */
  50316. totalStrength: number;
  50317. /**
  50318. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50319. */
  50320. maxZ: number;
  50321. /**
  50322. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50323. */
  50324. minZAspect: number;
  50325. private _samples;
  50326. /**
  50327. * Number of samples used for the SSAO calculations. Default value is 8
  50328. */
  50329. samples: number;
  50330. private _textureSamples;
  50331. /**
  50332. * Number of samples to use for antialiasing
  50333. */
  50334. textureSamples: number;
  50335. /**
  50336. * Ratio object used for SSAO ratio and blur ratio
  50337. */
  50338. private _ratio;
  50339. /**
  50340. * Dynamically generated sphere sampler.
  50341. */
  50342. private _sampleSphere;
  50343. /**
  50344. * Blur filter offsets
  50345. */
  50346. private _samplerOffsets;
  50347. private _expensiveBlur;
  50348. /**
  50349. * If bilateral blur should be used
  50350. */
  50351. expensiveBlur: boolean;
  50352. /**
  50353. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50354. */
  50355. radius: number;
  50356. /**
  50357. * The base color of the SSAO post-process
  50358. * The final result is "base + ssao" between [0, 1]
  50359. */
  50360. base: number;
  50361. /**
  50362. * Support test.
  50363. */
  50364. static readonly IsSupported: boolean;
  50365. private _scene;
  50366. private _depthTexture;
  50367. private _normalTexture;
  50368. private _randomTexture;
  50369. private _originalColorPostProcess;
  50370. private _ssaoPostProcess;
  50371. private _blurHPostProcess;
  50372. private _blurVPostProcess;
  50373. private _ssaoCombinePostProcess;
  50374. private _firstUpdate;
  50375. /**
  50376. * @constructor
  50377. * @param name The rendering pipeline name
  50378. * @param scene The scene linked to this pipeline
  50379. * @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 }
  50380. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50381. */
  50382. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50383. /**
  50384. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50385. */
  50386. dispose(disableGeometryBufferRenderer?: boolean): void;
  50387. private _createBlurPostProcess;
  50388. /** @hidden */
  50389. _rebuild(): void;
  50390. private _bits;
  50391. private _radicalInverse_VdC;
  50392. private _hammersley;
  50393. private _hemisphereSample_uniform;
  50394. private _generateHemisphere;
  50395. private _createSSAOPostProcess;
  50396. private _createSSAOCombinePostProcess;
  50397. private _createRandomTexture;
  50398. /**
  50399. * Serialize the rendering pipeline (Used when exporting)
  50400. * @returns the serialized object
  50401. */
  50402. serialize(): any;
  50403. /**
  50404. * Parse the serialized pipeline
  50405. * @param source Source pipeline.
  50406. * @param scene The scene to load the pipeline to.
  50407. * @param rootUrl The URL of the serialized pipeline.
  50408. * @returns An instantiated pipeline from the serialized object.
  50409. */
  50410. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50411. }
  50412. }
  50413. declare module BABYLON {
  50414. /**
  50415. * Render pipeline to produce ssao effect
  50416. */
  50417. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50418. /**
  50419. * @ignore
  50420. * The PassPostProcess id in the pipeline that contains the original scene color
  50421. */
  50422. SSAOOriginalSceneColorEffect: string;
  50423. /**
  50424. * @ignore
  50425. * The SSAO PostProcess id in the pipeline
  50426. */
  50427. SSAORenderEffect: string;
  50428. /**
  50429. * @ignore
  50430. * The horizontal blur PostProcess id in the pipeline
  50431. */
  50432. SSAOBlurHRenderEffect: string;
  50433. /**
  50434. * @ignore
  50435. * The vertical blur PostProcess id in the pipeline
  50436. */
  50437. SSAOBlurVRenderEffect: string;
  50438. /**
  50439. * @ignore
  50440. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50441. */
  50442. SSAOCombineRenderEffect: string;
  50443. /**
  50444. * The output strength of the SSAO post-process. Default value is 1.0.
  50445. */
  50446. totalStrength: number;
  50447. /**
  50448. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50449. */
  50450. radius: number;
  50451. /**
  50452. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50453. * Must not be equal to fallOff and superior to fallOff.
  50454. * Default value is 0.975
  50455. */
  50456. area: number;
  50457. /**
  50458. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50459. * Must not be equal to area and inferior to area.
  50460. * Default value is 0.0
  50461. */
  50462. fallOff: number;
  50463. /**
  50464. * The base color of the SSAO post-process
  50465. * The final result is "base + ssao" between [0, 1]
  50466. */
  50467. base: number;
  50468. private _scene;
  50469. private _depthTexture;
  50470. private _randomTexture;
  50471. private _originalColorPostProcess;
  50472. private _ssaoPostProcess;
  50473. private _blurHPostProcess;
  50474. private _blurVPostProcess;
  50475. private _ssaoCombinePostProcess;
  50476. private _firstUpdate;
  50477. /**
  50478. * @constructor
  50479. * @param name - The rendering pipeline name
  50480. * @param scene - The scene linked to this pipeline
  50481. * @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 }
  50482. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50483. */
  50484. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50485. /**
  50486. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50487. */
  50488. dispose(disableDepthRender?: boolean): void;
  50489. private _createBlurPostProcess;
  50490. /** @hidden */
  50491. _rebuild(): void;
  50492. private _createSSAOPostProcess;
  50493. private _createSSAOCombinePostProcess;
  50494. private _createRandomTexture;
  50495. }
  50496. }
  50497. declare module BABYLON {
  50498. /**
  50499. * Standard rendering pipeline
  50500. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50501. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  50502. */
  50503. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50504. /**
  50505. * Public members
  50506. */
  50507. /**
  50508. * Post-process which contains the original scene color before the pipeline applies all the effects
  50509. */
  50510. originalPostProcess: Nullable<PostProcess>;
  50511. /**
  50512. * Post-process used to down scale an image x4
  50513. */
  50514. downSampleX4PostProcess: Nullable<PostProcess>;
  50515. /**
  50516. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  50517. */
  50518. brightPassPostProcess: Nullable<PostProcess>;
  50519. /**
  50520. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  50521. */
  50522. blurHPostProcesses: PostProcess[];
  50523. /**
  50524. * Post-process array storing all the vertical blur post-processes used by the pipeline
  50525. */
  50526. blurVPostProcesses: PostProcess[];
  50527. /**
  50528. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  50529. */
  50530. textureAdderPostProcess: Nullable<PostProcess>;
  50531. /**
  50532. * Post-process used to create volumetric lighting effect
  50533. */
  50534. volumetricLightPostProcess: Nullable<PostProcess>;
  50535. /**
  50536. * Post-process used to smooth the previous volumetric light post-process on the X axis
  50537. */
  50538. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  50539. /**
  50540. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  50541. */
  50542. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  50543. /**
  50544. * Post-process used to merge the volumetric light effect and the real scene color
  50545. */
  50546. volumetricLightMergePostProces: Nullable<PostProcess>;
  50547. /**
  50548. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  50549. */
  50550. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  50551. /**
  50552. * Base post-process used to calculate the average luminance of the final image for HDR
  50553. */
  50554. luminancePostProcess: Nullable<PostProcess>;
  50555. /**
  50556. * Post-processes used to create down sample post-processes in order to get
  50557. * the average luminance of the final image for HDR
  50558. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  50559. */
  50560. luminanceDownSamplePostProcesses: PostProcess[];
  50561. /**
  50562. * Post-process used to create a HDR effect (light adaptation)
  50563. */
  50564. hdrPostProcess: Nullable<PostProcess>;
  50565. /**
  50566. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  50567. */
  50568. textureAdderFinalPostProcess: Nullable<PostProcess>;
  50569. /**
  50570. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  50571. */
  50572. lensFlareFinalPostProcess: Nullable<PostProcess>;
  50573. /**
  50574. * Post-process used to merge the final HDR post-process and the real scene color
  50575. */
  50576. hdrFinalPostProcess: Nullable<PostProcess>;
  50577. /**
  50578. * Post-process used to create a lens flare effect
  50579. */
  50580. lensFlarePostProcess: Nullable<PostProcess>;
  50581. /**
  50582. * Post-process that merges the result of the lens flare post-process and the real scene color
  50583. */
  50584. lensFlareComposePostProcess: Nullable<PostProcess>;
  50585. /**
  50586. * Post-process used to create a motion blur effect
  50587. */
  50588. motionBlurPostProcess: Nullable<PostProcess>;
  50589. /**
  50590. * Post-process used to create a depth of field effect
  50591. */
  50592. depthOfFieldPostProcess: Nullable<PostProcess>;
  50593. /**
  50594. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50595. */
  50596. fxaaPostProcess: Nullable<FxaaPostProcess>;
  50597. /**
  50598. * Represents the brightness threshold in order to configure the illuminated surfaces
  50599. */
  50600. brightThreshold: number;
  50601. /**
  50602. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  50603. */
  50604. blurWidth: number;
  50605. /**
  50606. * Sets if the blur for highlighted surfaces must be only horizontal
  50607. */
  50608. horizontalBlur: boolean;
  50609. /**
  50610. * Sets the overall exposure used by the pipeline
  50611. */
  50612. exposure: number;
  50613. /**
  50614. * Texture used typically to simulate "dirty" on camera lens
  50615. */
  50616. lensTexture: Nullable<Texture>;
  50617. /**
  50618. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  50619. */
  50620. volumetricLightCoefficient: number;
  50621. /**
  50622. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  50623. */
  50624. volumetricLightPower: number;
  50625. /**
  50626. * Used the set the blur intensity to smooth the volumetric lights
  50627. */
  50628. volumetricLightBlurScale: number;
  50629. /**
  50630. * Light (spot or directional) used to generate the volumetric lights rays
  50631. * The source light must have a shadow generate so the pipeline can get its
  50632. * depth map
  50633. */
  50634. sourceLight: Nullable<SpotLight | DirectionalLight>;
  50635. /**
  50636. * For eye adaptation, represents the minimum luminance the eye can see
  50637. */
  50638. hdrMinimumLuminance: number;
  50639. /**
  50640. * For eye adaptation, represents the decrease luminance speed
  50641. */
  50642. hdrDecreaseRate: number;
  50643. /**
  50644. * For eye adaptation, represents the increase luminance speed
  50645. */
  50646. hdrIncreaseRate: number;
  50647. /**
  50648. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  50649. */
  50650. lensColorTexture: Nullable<Texture>;
  50651. /**
  50652. * The overall strengh for the lens flare effect
  50653. */
  50654. lensFlareStrength: number;
  50655. /**
  50656. * Dispersion coefficient for lens flare ghosts
  50657. */
  50658. lensFlareGhostDispersal: number;
  50659. /**
  50660. * Main lens flare halo width
  50661. */
  50662. lensFlareHaloWidth: number;
  50663. /**
  50664. * Based on the lens distortion effect, defines how much the lens flare result
  50665. * is distorted
  50666. */
  50667. lensFlareDistortionStrength: number;
  50668. /**
  50669. * Lens star texture must be used to simulate rays on the flares and is available
  50670. * in the documentation
  50671. */
  50672. lensStarTexture: Nullable<Texture>;
  50673. /**
  50674. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  50675. * flare effect by taking account of the dirt texture
  50676. */
  50677. lensFlareDirtTexture: Nullable<Texture>;
  50678. /**
  50679. * Represents the focal length for the depth of field effect
  50680. */
  50681. depthOfFieldDistance: number;
  50682. /**
  50683. * Represents the blur intensity for the blurred part of the depth of field effect
  50684. */
  50685. depthOfFieldBlurWidth: number;
  50686. /**
  50687. * For motion blur, defines how much the image is blurred by the movement
  50688. */
  50689. motionStrength: number;
  50690. /**
  50691. * List of animations for the pipeline (IAnimatable implementation)
  50692. */
  50693. animations: Animation[];
  50694. /**
  50695. * Private members
  50696. */
  50697. private _scene;
  50698. private _currentDepthOfFieldSource;
  50699. private _basePostProcess;
  50700. private _hdrCurrentLuminance;
  50701. private _floatTextureType;
  50702. private _ratio;
  50703. private _bloomEnabled;
  50704. private _depthOfFieldEnabled;
  50705. private _vlsEnabled;
  50706. private _lensFlareEnabled;
  50707. private _hdrEnabled;
  50708. private _motionBlurEnabled;
  50709. private _fxaaEnabled;
  50710. private _motionBlurSamples;
  50711. private _volumetricLightStepsCount;
  50712. private _samples;
  50713. /**
  50714. * @ignore
  50715. * Specifies if the bloom pipeline is enabled
  50716. */
  50717. BloomEnabled: boolean;
  50718. /**
  50719. * @ignore
  50720. * Specifies if the depth of field pipeline is enabed
  50721. */
  50722. DepthOfFieldEnabled: boolean;
  50723. /**
  50724. * @ignore
  50725. * Specifies if the lens flare pipeline is enabed
  50726. */
  50727. LensFlareEnabled: boolean;
  50728. /**
  50729. * @ignore
  50730. * Specifies if the HDR pipeline is enabled
  50731. */
  50732. HDREnabled: boolean;
  50733. /**
  50734. * @ignore
  50735. * Specifies if the volumetric lights scattering effect is enabled
  50736. */
  50737. VLSEnabled: boolean;
  50738. /**
  50739. * @ignore
  50740. * Specifies if the motion blur effect is enabled
  50741. */
  50742. MotionBlurEnabled: boolean;
  50743. /**
  50744. * Specifies if anti-aliasing is enabled
  50745. */
  50746. fxaaEnabled: boolean;
  50747. /**
  50748. * Specifies the number of steps used to calculate the volumetric lights
  50749. * Typically in interval [50, 200]
  50750. */
  50751. volumetricLightStepsCount: number;
  50752. /**
  50753. * Specifies the number of samples used for the motion blur effect
  50754. * Typically in interval [16, 64]
  50755. */
  50756. motionBlurSamples: number;
  50757. /**
  50758. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50759. */
  50760. samples: number;
  50761. /**
  50762. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50763. * @constructor
  50764. * @param name The rendering pipeline name
  50765. * @param scene The scene linked to this pipeline
  50766. * @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)
  50767. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  50768. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50769. */
  50770. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  50771. private _buildPipeline;
  50772. private _createDownSampleX4PostProcess;
  50773. private _createBrightPassPostProcess;
  50774. private _createBlurPostProcesses;
  50775. private _createTextureAdderPostProcess;
  50776. private _createVolumetricLightPostProcess;
  50777. private _createLuminancePostProcesses;
  50778. private _createHdrPostProcess;
  50779. private _createLensFlarePostProcess;
  50780. private _createDepthOfFieldPostProcess;
  50781. private _createMotionBlurPostProcess;
  50782. private _getDepthTexture;
  50783. private _disposePostProcesses;
  50784. /**
  50785. * Dispose of the pipeline and stop all post processes
  50786. */
  50787. dispose(): void;
  50788. /**
  50789. * Serialize the rendering pipeline (Used when exporting)
  50790. * @returns the serialized object
  50791. */
  50792. serialize(): any;
  50793. /**
  50794. * Parse the serialized pipeline
  50795. * @param source Source pipeline.
  50796. * @param scene The scene to load the pipeline to.
  50797. * @param rootUrl The URL of the serialized pipeline.
  50798. * @returns An instantiated pipeline from the serialized object.
  50799. */
  50800. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  50801. /**
  50802. * Luminance steps
  50803. */
  50804. static LuminanceSteps: number;
  50805. }
  50806. }