babylon.d.ts 2.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /**
  62. * Gets the list of root nodes (ie. nodes with no parent)
  63. */
  64. rootNodes: Node[];
  65. /** All of the cameras added to this scene
  66. * @see http://doc.babylonjs.com/babylon101/cameras
  67. */
  68. cameras: Camera[];
  69. /**
  70. * All of the lights added to this scene
  71. * @see http://doc.babylonjs.com/babylon101/lights
  72. */
  73. lights: Light[];
  74. /**
  75. * All of the (abstract) meshes added to this scene
  76. */
  77. meshes: AbstractMesh[];
  78. /**
  79. * The list of skeletons added to the scene
  80. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81. */
  82. skeletons: Skeleton[];
  83. /**
  84. * All of the particle systems added to this scene
  85. * @see http://doc.babylonjs.com/babylon101/particles
  86. */
  87. particleSystems: IParticleSystem[];
  88. /**
  89. * Gets a list of Animations associated with the scene
  90. */
  91. animations: Animation[];
  92. /**
  93. * All of the animation groups added to this scene
  94. * @see http://doc.babylonjs.com/how_to/group
  95. */
  96. animationGroups: AnimationGroup[];
  97. /**
  98. * All of the multi-materials added to this scene
  99. * @see http://doc.babylonjs.com/how_to/multi_materials
  100. */
  101. multiMaterials: MultiMaterial[];
  102. /**
  103. * All of the materials added to this scene
  104. * In the context of a Scene, it is not supposed to be modified manually.
  105. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  106. * Note also that the order of the Material wihin the array is not significant and might change.
  107. * @see http://doc.babylonjs.com/babylon101/materials
  108. */
  109. materials: Material[];
  110. /**
  111. * The list of morph target managers added to the scene
  112. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  113. */
  114. morphTargetManagers: MorphTargetManager[];
  115. /**
  116. * The list of geometries used in the scene.
  117. */
  118. geometries: Geometry[];
  119. /**
  120. * All of the tranform nodes added to this scene
  121. * In the context of a Scene, it is not supposed to be modified manually.
  122. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  123. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  124. * @see http://doc.babylonjs.com/how_to/transformnode
  125. */
  126. transformNodes: TransformNode[];
  127. /**
  128. * ActionManagers available on the scene.
  129. */
  130. actionManagers: ActionManager[];
  131. /**
  132. * Textures to keep.
  133. */
  134. textures: BaseTexture[];
  135. }
  136. }
  137. declare module BABYLON {
  138. /**
  139. * Set of assets to keep when moving a scene into an asset container.
  140. */
  141. class KeepAssets extends AbstractScene {
  142. }
  143. /**
  144. * Container with a set of assets that can be added or removed from a scene.
  145. */
  146. class AssetContainer extends AbstractScene {
  147. /**
  148. * The scene the AssetContainer belongs to.
  149. */
  150. scene: Scene;
  151. /**
  152. * Instantiates an AssetContainer.
  153. * @param scene The scene the AssetContainer belongs to.
  154. */
  155. constructor(scene: Scene);
  156. /**
  157. * Adds all the assets from the container to the scene.
  158. */
  159. addAllToScene(): void;
  160. /**
  161. * Removes all the assets in the container from the scene
  162. */
  163. removeAllFromScene(): void;
  164. /**
  165. * Disposes all the assets in the container
  166. */
  167. dispose(): void;
  168. private _moveAssets;
  169. /**
  170. * Removes all the assets contained in the scene and adds them to the container.
  171. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  172. */
  173. moveAllFromScene(keepAssets?: KeepAssets): void;
  174. /**
  175. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  176. * @returns the root mesh
  177. */
  178. createRootMesh(): Mesh;
  179. }
  180. }
  181. interface Window {
  182. mozIndexedDB: IDBFactory;
  183. webkitIndexedDB: IDBFactory;
  184. msIndexedDB: IDBFactory;
  185. webkitURL: typeof URL;
  186. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  187. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  188. WebGLRenderingContext: WebGLRenderingContext;
  189. MSGesture: MSGesture;
  190. CANNON: any;
  191. AudioContext: AudioContext;
  192. webkitAudioContext: AudioContext;
  193. PointerEvent: any;
  194. Math: Math;
  195. Uint8Array: Uint8ArrayConstructor;
  196. Float32Array: Float32ArrayConstructor;
  197. mozURL: typeof URL;
  198. msURL: typeof URL;
  199. VRFrameData: any;
  200. DracoDecoderModule: any;
  201. setImmediate(handler: (...args: any[]) => void): number;
  202. }
  203. interface WebGLProgram {
  204. context?: WebGLRenderingContext;
  205. vertexShader?: WebGLShader;
  206. fragmentShader?: WebGLShader;
  207. isParallelCompiled: boolean;
  208. onCompiled?: () => void;
  209. }
  210. interface WebGLRenderingContext {
  211. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  212. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  213. vertexAttribDivisor(index: number, divisor: number): void;
  214. createVertexArray(): any;
  215. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  216. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  217. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  218. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  219. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  220. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  221. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  222. createQuery(): WebGLQuery;
  223. deleteQuery(query: WebGLQuery): void;
  224. beginQuery(target: number, query: WebGLQuery): void;
  225. endQuery(target: number): void;
  226. getQueryParameter(query: WebGLQuery, pname: number): any;
  227. getQuery(target: number, pname: number): any;
  228. MAX_SAMPLES: number;
  229. RGBA8: number;
  230. READ_FRAMEBUFFER: number;
  231. DRAW_FRAMEBUFFER: number;
  232. UNIFORM_BUFFER: number;
  233. HALF_FLOAT_OES: number;
  234. RGBA16F: number;
  235. RGBA32F: number;
  236. R32F: number;
  237. RG32F: number;
  238. RGB32F: number;
  239. R16F: number;
  240. RG16F: number;
  241. RGB16F: number;
  242. RED: number;
  243. RG: number;
  244. R8: number;
  245. RG8: number;
  246. UNSIGNED_INT_24_8: number;
  247. DEPTH24_STENCIL8: number;
  248. drawBuffers(buffers: number[]): void;
  249. readBuffer(src: number): void;
  250. readonly COLOR_ATTACHMENT0: number;
  251. readonly COLOR_ATTACHMENT1: number;
  252. readonly COLOR_ATTACHMENT2: number;
  253. readonly COLOR_ATTACHMENT3: number;
  254. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  255. ANY_SAMPLES_PASSED: number;
  256. QUERY_RESULT_AVAILABLE: number;
  257. QUERY_RESULT: number;
  258. }
  259. interface Document {
  260. mozCancelFullScreen(): void;
  261. msCancelFullScreen(): void;
  262. webkitCancelFullScreen(): void;
  263. requestPointerLock(): void;
  264. exitPointerLock(): void;
  265. mozFullScreen: boolean;
  266. msIsFullScreen: boolean;
  267. readonly webkitIsFullScreen: boolean;
  268. readonly pointerLockElement: Element;
  269. mozPointerLockElement: HTMLElement;
  270. msPointerLockElement: HTMLElement;
  271. webkitPointerLockElement: HTMLElement;
  272. }
  273. interface HTMLCanvasElement {
  274. requestPointerLock(): void;
  275. msRequestPointerLock?(): void;
  276. mozRequestPointerLock?(): void;
  277. webkitRequestPointerLock?(): void;
  278. }
  279. interface CanvasRenderingContext2D {
  280. msImageSmoothingEnabled: boolean;
  281. }
  282. interface WebGLBuffer {
  283. references: number;
  284. capacity: number;
  285. is32Bits: boolean;
  286. }
  287. interface WebGLProgram {
  288. transformFeedback?: WebGLTransformFeedback | null;
  289. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  290. }
  291. interface MouseEvent {
  292. mozMovementX: number;
  293. mozMovementY: number;
  294. webkitMovementX: number;
  295. webkitMovementY: number;
  296. msMovementX: number;
  297. msMovementY: number;
  298. }
  299. interface Navigator {
  300. mozGetVRDevices: (any: any) => any;
  301. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  302. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  303. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  304. webkitGetGamepads(): Gamepad[];
  305. msGetGamepads(): Gamepad[];
  306. webkitGamepads(): Gamepad[];
  307. }
  308. interface HTMLVideoElement {
  309. mozSrcObject: any;
  310. }
  311. interface Math {
  312. fround(x: number): number;
  313. imul(a: number, b: number): number;
  314. }
  315. interface EXT_disjoint_timer_query {
  316. QUERY_COUNTER_BITS_EXT: number;
  317. TIME_ELAPSED_EXT: number;
  318. TIMESTAMP_EXT: number;
  319. GPU_DISJOINT_EXT: number;
  320. QUERY_RESULT_EXT: number;
  321. QUERY_RESULT_AVAILABLE_EXT: number;
  322. queryCounterEXT(query: WebGLQuery, target: number): void;
  323. createQueryEXT(): WebGLQuery;
  324. beginQueryEXT(target: number, query: WebGLQuery): void;
  325. endQueryEXT(target: number): void;
  326. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  327. deleteQueryEXT(query: WebGLQuery): void;
  328. }
  329. interface WebGLUniformLocation {
  330. _currentState: any;
  331. }
  332. interface XRDevice {
  333. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  334. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  335. }
  336. interface XRSession {
  337. getInputSources(): Array<any>;
  338. baseLayer: XRWebGLLayer;
  339. requestFrameOfReference(type: string): Promise<void>;
  340. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  341. end(): Promise<void>;
  342. requestAnimationFrame: Function;
  343. addEventListener: Function;
  344. }
  345. interface XRSessionCreationOptions {
  346. outputContext?: WebGLRenderingContext | null;
  347. immersive?: boolean;
  348. environmentIntegration?: boolean;
  349. }
  350. interface XRLayer {
  351. getViewport: Function;
  352. framebufferWidth: number;
  353. framebufferHeight: number;
  354. }
  355. interface XRView {
  356. projectionMatrix: Float32Array;
  357. }
  358. interface XRFrame {
  359. getDevicePose: Function;
  360. getInputPose: Function;
  361. views: Array<XRView>;
  362. baseLayer: XRLayer;
  363. }
  364. interface XRFrameOfReference {
  365. }
  366. interface XRWebGLLayer extends XRLayer {
  367. framebuffer: WebGLFramebuffer;
  368. }
  369. declare var XRWebGLLayer: {
  370. prototype: XRWebGLLayer;
  371. new (session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  372. };
  373. declare module BABYLON {
  374. /**
  375. * Defines how a node can be built from a string name.
  376. */
  377. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  378. /**
  379. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  380. */
  381. class Node implements IBehaviorAware<Node> {
  382. private static _NodeConstructors;
  383. /**
  384. * Add a new node constructor
  385. * @param type defines the type name of the node to construct
  386. * @param constructorFunc defines the constructor function
  387. */
  388. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  389. /**
  390. * Returns a node constructor based on type name
  391. * @param type defines the type name
  392. * @param name defines the new node name
  393. * @param scene defines the hosting scene
  394. * @param options defines optional options to transmit to constructors
  395. * @returns the new constructor or null
  396. */
  397. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  398. /**
  399. * Gets or sets the name of the node
  400. */
  401. name: string;
  402. /**
  403. * Gets or sets the id of the node
  404. */
  405. id: string;
  406. /**
  407. * Gets or sets the unique id of the node
  408. */
  409. uniqueId: number;
  410. /**
  411. * Gets or sets a string used to store user defined state for the node
  412. */
  413. state: string;
  414. /**
  415. * Gets or sets an object used to store user defined information for the node
  416. */
  417. metadata: any;
  418. /**
  419. * For internal use only. Please do not use.
  420. */
  421. reservedDataStore: any;
  422. /**
  423. * Gets or sets a boolean used to define if the node must be serialized
  424. */
  425. doNotSerialize: boolean;
  426. /** @hidden */
  427. _isDisposed: boolean;
  428. /**
  429. * Gets a list of Animations associated with the node
  430. */
  431. animations: Animation[];
  432. protected _ranges: {
  433. [name: string]: Nullable<AnimationRange>;
  434. };
  435. /**
  436. * Callback raised when the node is ready to be used
  437. */
  438. onReady: (node: Node) => void;
  439. private _isEnabled;
  440. private _isParentEnabled;
  441. private _isReady;
  442. /** @hidden */
  443. _currentRenderId: number;
  444. private _parentRenderId;
  445. protected _childRenderId: number;
  446. /** @hidden */
  447. _waitingParentId: Nullable<string>;
  448. /** @hidden */
  449. _scene: Scene;
  450. /** @hidden */
  451. _cache: any;
  452. private _parentNode;
  453. private _children;
  454. /** @hidden */
  455. _worldMatrix: Matrix;
  456. /** @hidden */
  457. _worldMatrixDeterminant: number;
  458. /** @hidden */
  459. private _sceneRootNodesIndex;
  460. /**
  461. * Gets a boolean indicating if the node has been disposed
  462. * @returns true if the node was disposed
  463. */
  464. isDisposed(): boolean;
  465. /**
  466. * Gets or sets the parent of the node
  467. */
  468. parent: Nullable<Node>;
  469. private addToSceneRootNodes;
  470. private removeFromSceneRootNodes;
  471. private _animationPropertiesOverride;
  472. /**
  473. * Gets or sets the animation properties override
  474. */
  475. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  476. /**
  477. * Gets a string idenfifying the name of the class
  478. * @returns "Node" string
  479. */
  480. getClassName(): string;
  481. /**
  482. * An event triggered when the mesh is disposed
  483. */
  484. onDisposeObservable: Observable<Node>;
  485. private _onDisposeObserver;
  486. /**
  487. * Sets a callback that will be raised when the node will be disposed
  488. */
  489. onDispose: () => void;
  490. /**
  491. * Creates a new Node
  492. * @param name the name and id to be given to this node
  493. * @param scene the scene this node will be added to
  494. * @param addToRootNodes the node will be added to scene.rootNodes
  495. */
  496. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  497. /**
  498. * Gets the scene of the node
  499. * @returns a scene
  500. */
  501. getScene(): Scene;
  502. /**
  503. * Gets the engine of the node
  504. * @returns a Engine
  505. */
  506. getEngine(): Engine;
  507. private _behaviors;
  508. /**
  509. * Attach a behavior to the node
  510. * @see http://doc.babylonjs.com/features/behaviour
  511. * @param behavior defines the behavior to attach
  512. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  513. * @returns the current Node
  514. */
  515. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  516. /**
  517. * Remove an attached behavior
  518. * @see http://doc.babylonjs.com/features/behaviour
  519. * @param behavior defines the behavior to attach
  520. * @returns the current Node
  521. */
  522. removeBehavior(behavior: Behavior<Node>): Node;
  523. /**
  524. * Gets the list of attached behaviors
  525. * @see http://doc.babylonjs.com/features/behaviour
  526. */
  527. readonly behaviors: Behavior<Node>[];
  528. /**
  529. * Gets an attached behavior by name
  530. * @param name defines the name of the behavior to look for
  531. * @see http://doc.babylonjs.com/features/behaviour
  532. * @returns null if behavior was not found else the requested behavior
  533. */
  534. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  535. /**
  536. * Returns the latest update of the World matrix
  537. * @returns a Matrix
  538. */
  539. getWorldMatrix(): Matrix;
  540. /** @hidden */
  541. _getWorldMatrixDeterminant(): number;
  542. /**
  543. * Returns directly the latest state of the mesh World matrix.
  544. * A Matrix is returned.
  545. */
  546. readonly worldMatrixFromCache: Matrix;
  547. /** @hidden */
  548. _initCache(): void;
  549. /** @hidden */
  550. updateCache(force?: boolean): void;
  551. /** @hidden */
  552. _updateCache(ignoreParentClass?: boolean): void;
  553. /** @hidden */
  554. _isSynchronized(): boolean;
  555. /** @hidden */
  556. _markSyncedWithParent(): void;
  557. /** @hidden */
  558. isSynchronizedWithParent(): boolean;
  559. /** @hidden */
  560. isSynchronized(): boolean;
  561. /**
  562. * Is this node ready to be used/rendered
  563. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  564. * @return true if the node is ready
  565. */
  566. isReady(completeCheck?: boolean): boolean;
  567. /**
  568. * Is this node enabled?
  569. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  570. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  571. * @return whether this node (and its parent) is enabled
  572. */
  573. isEnabled(checkAncestors?: boolean): boolean;
  574. /** @hidden */
  575. protected _syncParentEnabledState(): void;
  576. /**
  577. * Set the enabled state of this node
  578. * @param value defines the new enabled state
  579. */
  580. setEnabled(value: boolean): void;
  581. /**
  582. * Is this node a descendant of the given node?
  583. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  584. * @param ancestor defines the parent node to inspect
  585. * @returns a boolean indicating if this node is a descendant of the given node
  586. */
  587. isDescendantOf(ancestor: Node): boolean;
  588. /** @hidden */
  589. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  590. /**
  591. * Will return all nodes that have this node as ascendant
  592. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  593. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  594. * @return all children nodes of all types
  595. */
  596. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  597. /**
  598. * Get all child-meshes of this node
  599. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  600. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  601. * @returns an array of AbstractMesh
  602. */
  603. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  604. /**
  605. * Get all child-transformNodes of this node
  606. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  607. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  608. * @returns an array of TransformNode
  609. */
  610. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  611. /**
  612. * Get all direct children of this node
  613. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  614. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  615. * @returns an array of Node
  616. */
  617. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  618. /** @hidden */
  619. _setReady(state: boolean): void;
  620. /**
  621. * Get an animation by name
  622. * @param name defines the name of the animation to look for
  623. * @returns null if not found else the requested animation
  624. */
  625. getAnimationByName(name: string): Nullable<Animation>;
  626. /**
  627. * Creates an animation range for this node
  628. * @param name defines the name of the range
  629. * @param from defines the starting key
  630. * @param to defines the end key
  631. */
  632. createAnimationRange(name: string, from: number, to: number): void;
  633. /**
  634. * Delete a specific animation range
  635. * @param name defines the name of the range to delete
  636. * @param deleteFrames defines if animation frames from the range must be deleted as well
  637. */
  638. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  639. /**
  640. * Get an animation range by name
  641. * @param name defines the name of the animation range to look for
  642. * @returns null if not found else the requested animation range
  643. */
  644. getAnimationRange(name: string): Nullable<AnimationRange>;
  645. /**
  646. * Will start the animation sequence
  647. * @param name defines the range frames for animation sequence
  648. * @param loop defines if the animation should loop (false by default)
  649. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  650. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  651. * @returns the object created for this animation. If range does not exist, it will return null
  652. */
  653. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  654. /**
  655. * Serialize animation ranges into a JSON compatible object
  656. * @returns serialization object
  657. */
  658. serializeAnimationRanges(): any;
  659. /**
  660. * Computes the world matrix of the node
  661. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  662. * @returns the world matrix
  663. */
  664. computeWorldMatrix(force?: boolean): Matrix;
  665. /**
  666. * Releases resources associated with this node.
  667. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  668. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  669. */
  670. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  671. /**
  672. * Parse animation range data from a serialization object and store them into a given node
  673. * @param node defines where to store the animation ranges
  674. * @param parsedNode defines the serialization object to read data from
  675. * @param scene defines the hosting scene
  676. */
  677. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  678. }
  679. }
  680. declare module BABYLON {
  681. /**
  682. * Define an interface for all classes that will hold resources
  683. */
  684. interface IDisposable {
  685. /**
  686. * Releases all held resources
  687. */
  688. dispose(): void;
  689. }
  690. /**
  691. * This class is used by the onRenderingGroupObservable
  692. */
  693. class RenderingGroupInfo {
  694. /**
  695. * The Scene that being rendered
  696. */
  697. scene: Scene;
  698. /**
  699. * The camera currently used for the rendering pass
  700. */
  701. camera: Nullable<Camera>;
  702. /**
  703. * The ID of the renderingGroup being processed
  704. */
  705. renderingGroupId: number;
  706. }
  707. /** Interface defining initialization parameters for Scene class */
  708. interface SceneOptions {
  709. /**
  710. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by Id
  711. * It will improve performance when the number of geometries becomes important.
  712. */
  713. useGeometryIdsMap?: boolean;
  714. /**
  715. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  716. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  717. */
  718. useMaterialMeshMap?: boolean;
  719. /**
  720. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  721. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  722. */
  723. useClonedMeshhMap?: boolean;
  724. }
  725. /**
  726. * Represents a scene to be rendered by the engine.
  727. * @see http://doc.babylonjs.com/features/scene
  728. */
  729. class Scene extends AbstractScene implements IAnimatable {
  730. private static _uniqueIdCounter;
  731. /** The fog is deactivated */
  732. static readonly FOGMODE_NONE: number;
  733. /** The fog density is following an exponential function */
  734. static readonly FOGMODE_EXP: number;
  735. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  736. static readonly FOGMODE_EXP2: number;
  737. /** The fog density is following a linear function. */
  738. static readonly FOGMODE_LINEAR: number;
  739. /**
  740. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  741. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  742. */
  743. static MinDeltaTime: number;
  744. /**
  745. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  746. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  747. */
  748. static MaxDeltaTime: number;
  749. /**
  750. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  751. */
  752. autoClear: boolean;
  753. /**
  754. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  755. */
  756. autoClearDepthAndStencil: boolean;
  757. /**
  758. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  759. */
  760. clearColor: Color4;
  761. /**
  762. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  763. */
  764. ambientColor: Color3;
  765. /** @hidden */
  766. _environmentBRDFTexture: BaseTexture;
  767. /** @hidden */
  768. protected _environmentTexture: Nullable<BaseTexture>;
  769. /**
  770. * Texture used in all pbr material as the reflection texture.
  771. * As in the majority of the scene they are the same (exception for multi room and so on),
  772. * this is easier to reference from here than from all the materials.
  773. */
  774. /**
  775. * Texture used in all pbr material as the reflection texture.
  776. * As in the majority of the scene they are the same (exception for multi room and so on),
  777. * this is easier to set here than in all the materials.
  778. */
  779. environmentTexture: Nullable<BaseTexture>;
  780. /** @hidden */
  781. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  782. /**
  783. * Default image processing configuration used either in the rendering
  784. * Forward main pass or through the imageProcessingPostProcess if present.
  785. * As in the majority of the scene they are the same (exception for multi camera),
  786. * this is easier to reference from here than from all the materials and post process.
  787. *
  788. * No setter as we it is a shared configuration, you can set the values instead.
  789. */
  790. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  791. private _forceWireframe;
  792. /**
  793. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  794. */
  795. forceWireframe: boolean;
  796. private _forcePointsCloud;
  797. /**
  798. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  799. */
  800. forcePointsCloud: boolean;
  801. /**
  802. * Gets or sets the active clipplane 1
  803. */
  804. clipPlane: Nullable<Plane>;
  805. /**
  806. * Gets or sets the active clipplane 2
  807. */
  808. clipPlane2: Nullable<Plane>;
  809. /**
  810. * Gets or sets the active clipplane 3
  811. */
  812. clipPlane3: Nullable<Plane>;
  813. /**
  814. * Gets or sets the active clipplane 4
  815. */
  816. clipPlane4: Nullable<Plane>;
  817. /**
  818. * Gets or sets a boolean indicating if animations are enabled
  819. */
  820. animationsEnabled: boolean;
  821. private _animationPropertiesOverride;
  822. /**
  823. * Gets or sets the animation properties override
  824. */
  825. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  826. /**
  827. * Gets or sets a boolean indicating if a constant deltatime has to be used
  828. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  829. */
  830. useConstantAnimationDeltaTime: boolean;
  831. /**
  832. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  833. * Please note that it requires to run a ray cast through the scene on every frame
  834. */
  835. constantlyUpdateMeshUnderPointer: boolean;
  836. /**
  837. * Defines the HTML cursor to use when hovering over interactive elements
  838. */
  839. hoverCursor: string;
  840. /**
  841. * Defines the HTML default cursor to use (empty by default)
  842. */
  843. defaultCursor: string;
  844. /**
  845. * This is used to call preventDefault() on pointer down
  846. * in order to block unwanted artifacts like system double clicks
  847. */
  848. preventDefaultOnPointerDown: boolean;
  849. /**
  850. * This is used to call preventDefault() on pointer up
  851. * in order to block unwanted artifacts like system double clicks
  852. */
  853. preventDefaultOnPointerUp: boolean;
  854. /**
  855. * Gets or sets user defined metadata
  856. */
  857. metadata: any;
  858. /**
  859. * For internal use only. Please do not use.
  860. */
  861. reservedDataStore: any;
  862. /**
  863. * Gets the name of the plugin used to load this scene (null by default)
  864. */
  865. loadingPluginName: string;
  866. /**
  867. * Use this array to add regular expressions used to disable offline support for specific urls
  868. */
  869. disableOfflineSupportExceptionRules: RegExp[];
  870. /**
  871. * An event triggered when the scene is disposed.
  872. */
  873. onDisposeObservable: Observable<Scene>;
  874. private _onDisposeObserver;
  875. /** Sets a function to be executed when this scene is disposed. */
  876. onDispose: () => void;
  877. /**
  878. * An event triggered before rendering the scene (right after animations and physics)
  879. */
  880. onBeforeRenderObservable: Observable<Scene>;
  881. private _onBeforeRenderObserver;
  882. /** Sets a function to be executed before rendering this scene */
  883. beforeRender: Nullable<() => void>;
  884. /**
  885. * An event triggered after rendering the scene
  886. */
  887. onAfterRenderObservable: Observable<Scene>;
  888. private _onAfterRenderObserver;
  889. /** Sets a function to be executed after rendering this scene */
  890. afterRender: Nullable<() => void>;
  891. /**
  892. * An event triggered before animating the scene
  893. */
  894. onBeforeAnimationsObservable: Observable<Scene>;
  895. /**
  896. * An event triggered after animations processing
  897. */
  898. onAfterAnimationsObservable: Observable<Scene>;
  899. /**
  900. * An event triggered before draw calls are ready to be sent
  901. */
  902. onBeforeDrawPhaseObservable: Observable<Scene>;
  903. /**
  904. * An event triggered after draw calls have been sent
  905. */
  906. onAfterDrawPhaseObservable: Observable<Scene>;
  907. /**
  908. * An event triggered when the scene is ready
  909. */
  910. onReadyObservable: Observable<Scene>;
  911. /**
  912. * An event triggered before rendering a camera
  913. */
  914. onBeforeCameraRenderObservable: Observable<Camera>;
  915. private _onBeforeCameraRenderObserver;
  916. /** Sets a function to be executed before rendering a camera*/
  917. beforeCameraRender: () => void;
  918. /**
  919. * An event triggered after rendering a camera
  920. */
  921. onAfterCameraRenderObservable: Observable<Camera>;
  922. private _onAfterCameraRenderObserver;
  923. /** Sets a function to be executed after rendering a camera*/
  924. afterCameraRender: () => void;
  925. /**
  926. * An event triggered when active meshes evaluation is about to start
  927. */
  928. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  929. /**
  930. * An event triggered when active meshes evaluation is done
  931. */
  932. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  933. /**
  934. * An event triggered when particles rendering is about to start
  935. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  936. */
  937. onBeforeParticlesRenderingObservable: Observable<Scene>;
  938. /**
  939. * An event triggered when particles rendering is done
  940. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  941. */
  942. onAfterParticlesRenderingObservable: Observable<Scene>;
  943. /**
  944. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  945. */
  946. onDataLoadedObservable: Observable<Scene>;
  947. /**
  948. * An event triggered when a camera is created
  949. */
  950. onNewCameraAddedObservable: Observable<Camera>;
  951. /**
  952. * An event triggered when a camera is removed
  953. */
  954. onCameraRemovedObservable: Observable<Camera>;
  955. /**
  956. * An event triggered when a light is created
  957. */
  958. onNewLightAddedObservable: Observable<Light>;
  959. /**
  960. * An event triggered when a light is removed
  961. */
  962. onLightRemovedObservable: Observable<Light>;
  963. /**
  964. * An event triggered when a geometry is created
  965. */
  966. onNewGeometryAddedObservable: Observable<Geometry>;
  967. /**
  968. * An event triggered when a geometry is removed
  969. */
  970. onGeometryRemovedObservable: Observable<Geometry>;
  971. /**
  972. * An event triggered when a transform node is created
  973. */
  974. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  975. /**
  976. * An event triggered when a transform node is removed
  977. */
  978. onTransformNodeRemovedObservable: Observable<TransformNode>;
  979. /**
  980. * An event triggered when a mesh is created
  981. */
  982. onNewMeshAddedObservable: Observable<AbstractMesh>;
  983. /**
  984. * An event triggered when a mesh is removed
  985. */
  986. onMeshRemovedObservable: Observable<AbstractMesh>;
  987. /**
  988. * An event triggered when a material is created
  989. */
  990. onNewMaterialAddedObservable: Observable<Material>;
  991. /**
  992. * An event triggered when a material is removed
  993. */
  994. onMaterialRemovedObservable: Observable<Material>;
  995. /**
  996. * An event triggered when a texture is created
  997. */
  998. onNewTextureAddedObservable: Observable<BaseTexture>;
  999. /**
  1000. * An event triggered when a texture is removed
  1001. */
  1002. onTextureRemovedObservable: Observable<BaseTexture>;
  1003. /**
  1004. * An event triggered when render targets are about to be rendered
  1005. * Can happen multiple times per frame.
  1006. */
  1007. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  1008. /**
  1009. * An event triggered when render targets were rendered.
  1010. * Can happen multiple times per frame.
  1011. */
  1012. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  1013. /**
  1014. * An event triggered before calculating deterministic simulation step
  1015. */
  1016. onBeforeStepObservable: Observable<Scene>;
  1017. /**
  1018. * An event triggered after calculating deterministic simulation step
  1019. */
  1020. onAfterStepObservable: Observable<Scene>;
  1021. /**
  1022. * An event triggered when the activeCamera property is updated
  1023. */
  1024. onActiveCameraChanged: Observable<Scene>;
  1025. /**
  1026. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  1027. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1028. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  1029. */
  1030. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1031. /**
  1032. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  1033. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1034. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  1035. */
  1036. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1037. /**
  1038. * This Observable will when a mesh has been imported into the scene.
  1039. */
  1040. onMeshImportedObservable: Observable<AbstractMesh>;
  1041. private _registeredForLateAnimationBindings;
  1042. /**
  1043. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  1044. */
  1045. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  1046. /**
  1047. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  1048. */
  1049. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  1050. /**
  1051. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  1052. */
  1053. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  1054. private _onPointerMove;
  1055. private _onPointerDown;
  1056. private _onPointerUp;
  1057. /** Callback called when a pointer move is detected */
  1058. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1059. /** Callback called when a pointer down is detected */
  1060. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1061. /** Callback called when a pointer up is detected */
  1062. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  1063. /** Callback called when a pointer pick is detected */
  1064. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  1065. /**
  1066. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  1067. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  1068. */
  1069. onPrePointerObservable: Observable<PointerInfoPre>;
  1070. /**
  1071. * Observable event triggered each time an input event is received from the rendering canvas
  1072. */
  1073. onPointerObservable: Observable<PointerInfo>;
  1074. /**
  1075. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  1076. */
  1077. readonly unTranslatedPointer: Vector2;
  1078. /** The distance in pixel that you have to move to prevent some events */
  1079. static DragMovementThreshold: number;
  1080. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1081. static LongPressDelay: number;
  1082. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1083. static DoubleClickDelay: number;
  1084. /** If you need to check double click without raising a single click at first click, enable this flag */
  1085. static ExclusiveDoubleClickMode: boolean;
  1086. private _initClickEvent;
  1087. private _initActionManager;
  1088. private _delayedSimpleClick;
  1089. private _delayedSimpleClickTimeout;
  1090. private _previousDelayedSimpleClickTimeout;
  1091. private _meshPickProceed;
  1092. private _previousButtonPressed;
  1093. private _currentPickResult;
  1094. private _previousPickResult;
  1095. private _totalPointersPressed;
  1096. private _doubleClickOccured;
  1097. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1098. cameraToUseForPointers: Nullable<Camera>;
  1099. private _pointerX;
  1100. private _pointerY;
  1101. private _unTranslatedPointerX;
  1102. private _unTranslatedPointerY;
  1103. private _startingPointerPosition;
  1104. private _previousStartingPointerPosition;
  1105. private _startingPointerTime;
  1106. private _previousStartingPointerTime;
  1107. private _pointerCaptures;
  1108. private _timeAccumulator;
  1109. private _currentStepId;
  1110. private _currentInternalStep;
  1111. /** @hidden */
  1112. _mirroredCameraPosition: Nullable<Vector3>;
  1113. /**
  1114. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1115. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1116. */
  1117. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1118. /**
  1119. * Observable event triggered each time an keyboard event is received from the hosting window
  1120. */
  1121. onKeyboardObservable: Observable<KeyboardInfo>;
  1122. private _onKeyDown;
  1123. private _onKeyUp;
  1124. private _onCanvasFocusObserver;
  1125. private _onCanvasBlurObserver;
  1126. private _useRightHandedSystem;
  1127. /**
  1128. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1129. */
  1130. useRightHandedSystem: boolean;
  1131. /**
  1132. * Sets the step Id used by deterministic lock step
  1133. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1134. * @param newStepId defines the step Id
  1135. */
  1136. setStepId(newStepId: number): void;
  1137. /**
  1138. * Gets the step Id used by deterministic lock step
  1139. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1140. * @returns the step Id
  1141. */
  1142. getStepId(): number;
  1143. /**
  1144. * Gets the internal step used by deterministic lock step
  1145. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1146. * @returns the internal step
  1147. */
  1148. getInternalStep(): number;
  1149. private _fogEnabled;
  1150. /**
  1151. * Gets or sets a boolean indicating if fog is enabled on this scene
  1152. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1153. * (Default is true)
  1154. */
  1155. fogEnabled: boolean;
  1156. private _fogMode;
  1157. /**
  1158. * Gets or sets the fog mode to use
  1159. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1160. * | mode | value |
  1161. * | --- | --- |
  1162. * | FOGMODE_NONE | 0 |
  1163. * | FOGMODE_EXP | 1 |
  1164. * | FOGMODE_EXP2 | 2 |
  1165. * | FOGMODE_LINEAR | 3 |
  1166. */
  1167. fogMode: number;
  1168. /**
  1169. * Gets or sets the fog color to use
  1170. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1171. * (Default is Color3(0.2, 0.2, 0.3))
  1172. */
  1173. fogColor: Color3;
  1174. /**
  1175. * Gets or sets the fog density to use
  1176. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1177. * (Default is 0.1)
  1178. */
  1179. fogDensity: number;
  1180. /**
  1181. * Gets or sets the fog start distance to use
  1182. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1183. * (Default is 0)
  1184. */
  1185. fogStart: number;
  1186. /**
  1187. * Gets or sets the fog end distance to use
  1188. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1189. * (Default is 1000)
  1190. */
  1191. fogEnd: number;
  1192. private _shadowsEnabled;
  1193. /**
  1194. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1195. */
  1196. shadowsEnabled: boolean;
  1197. private _lightsEnabled;
  1198. /**
  1199. * Gets or sets a boolean indicating if lights are enabled on this scene
  1200. */
  1201. lightsEnabled: boolean;
  1202. /** All of the active cameras added to this scene. */
  1203. activeCameras: Camera[];
  1204. private _activeCamera;
  1205. /** Gets or sets the current active camera */
  1206. activeCamera: Nullable<Camera>;
  1207. private _defaultMaterial;
  1208. /** The default material used on meshes when no material is affected */
  1209. /** The default material used on meshes when no material is affected */
  1210. defaultMaterial: Material;
  1211. private _texturesEnabled;
  1212. /**
  1213. * Gets or sets a boolean indicating if textures are enabled on this scene
  1214. */
  1215. texturesEnabled: boolean;
  1216. /**
  1217. * Gets or sets a boolean indicating if particles are enabled on this scene
  1218. */
  1219. particlesEnabled: boolean;
  1220. /**
  1221. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1222. */
  1223. spritesEnabled: boolean;
  1224. private _skeletonsEnabled;
  1225. /**
  1226. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1227. */
  1228. skeletonsEnabled: boolean;
  1229. /**
  1230. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1231. */
  1232. lensFlaresEnabled: boolean;
  1233. /**
  1234. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1235. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1236. */
  1237. collisionsEnabled: boolean;
  1238. private _workerCollisions;
  1239. /** @hidden */
  1240. collisionCoordinator: ICollisionCoordinator;
  1241. /**
  1242. * Defines the gravity applied to this scene (used only for collisions)
  1243. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1244. */
  1245. gravity: Vector3;
  1246. /**
  1247. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1248. */
  1249. postProcessesEnabled: boolean;
  1250. /**
  1251. * The list of postprocesses added to the scene
  1252. */
  1253. postProcesses: PostProcess[];
  1254. /**
  1255. * Gets the current postprocess manager
  1256. */
  1257. postProcessManager: PostProcessManager;
  1258. /**
  1259. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1260. */
  1261. renderTargetsEnabled: boolean;
  1262. /**
  1263. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1264. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1265. */
  1266. dumpNextRenderTargets: boolean;
  1267. /**
  1268. * The list of user defined render targets added to the scene
  1269. */
  1270. customRenderTargets: RenderTargetTexture[];
  1271. /**
  1272. * Defines if texture loading must be delayed
  1273. * If true, textures will only be loaded when they need to be rendered
  1274. */
  1275. useDelayedTextureLoading: boolean;
  1276. /**
  1277. * Gets the list of meshes imported to the scene through SceneLoader
  1278. */
  1279. importedMeshesFiles: String[];
  1280. /**
  1281. * Gets or sets a boolean indicating if probes are enabled on this scene
  1282. */
  1283. probesEnabled: boolean;
  1284. /**
  1285. * Gets or sets the current offline provider to use to store scene data
  1286. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1287. */
  1288. offlineProvider: IOfflineProvider;
  1289. /**
  1290. * Gets or sets the action manager associated with the scene
  1291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1292. */
  1293. actionManager: ActionManager;
  1294. private _meshesForIntersections;
  1295. /**
  1296. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1297. */
  1298. proceduralTexturesEnabled: boolean;
  1299. private _engine;
  1300. private _totalVertices;
  1301. /** @hidden */
  1302. _activeIndices: PerfCounter;
  1303. /** @hidden */
  1304. _activeParticles: PerfCounter;
  1305. /** @hidden */
  1306. _activeBones: PerfCounter;
  1307. private _animationRatio;
  1308. private _animationTimeLast;
  1309. private _animationTime;
  1310. /**
  1311. * Gets or sets a general scale for animation speed
  1312. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1313. */
  1314. animationTimeScale: number;
  1315. /** @hidden */
  1316. _cachedMaterial: Nullable<Material>;
  1317. /** @hidden */
  1318. _cachedEffect: Nullable<Effect>;
  1319. /** @hidden */
  1320. _cachedVisibility: Nullable<number>;
  1321. private _renderId;
  1322. private _frameId;
  1323. private _executeWhenReadyTimeoutId;
  1324. private _intermediateRendering;
  1325. private _viewUpdateFlag;
  1326. private _projectionUpdateFlag;
  1327. private _alternateViewUpdateFlag;
  1328. private _alternateProjectionUpdateFlag;
  1329. /** @hidden */
  1330. _toBeDisposed: Nullable<IDisposable>[];
  1331. private _activeRequests;
  1332. private _pendingData;
  1333. private _isDisposed;
  1334. /**
  1335. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1336. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1337. */
  1338. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1339. private _activeMeshes;
  1340. private _processedMaterials;
  1341. private _renderTargets;
  1342. /** @hidden */
  1343. _activeParticleSystems: SmartArray<IParticleSystem>;
  1344. private _activeSkeletons;
  1345. private _softwareSkinnedMeshes;
  1346. private _renderingManager;
  1347. /** @hidden */
  1348. _activeAnimatables: Animatable[];
  1349. private _transformMatrix;
  1350. private _sceneUbo;
  1351. private _alternateSceneUbo;
  1352. private _pickWithRayInverseMatrix;
  1353. private _viewMatrix;
  1354. private _projectionMatrix;
  1355. private _alternateViewMatrix;
  1356. private _alternateProjectionMatrix;
  1357. private _alternateTransformMatrix;
  1358. private _useAlternateCameraConfiguration;
  1359. private _alternateRendering;
  1360. private _wheelEventName;
  1361. /** @hidden */
  1362. _forcedViewPosition: Nullable<Vector3>;
  1363. /** @hidden */
  1364. readonly _isAlternateRenderingEnabled: boolean;
  1365. private _frustumPlanes;
  1366. /**
  1367. * Gets the list of frustum planes (built from the active camera)
  1368. */
  1369. readonly frustumPlanes: Plane[];
  1370. /**
  1371. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1372. * This is useful if there are more lights that the maximum simulteanous authorized
  1373. */
  1374. requireLightSorting: boolean;
  1375. /** @hidden */
  1376. readonly useMaterialMeshMap: boolean;
  1377. /** @hidden */
  1378. readonly useClonedMeshhMap: boolean;
  1379. private _pointerOverMesh;
  1380. private _pickedDownMesh;
  1381. private _pickedUpMesh;
  1382. private _externalData;
  1383. private _uid;
  1384. /**
  1385. * @hidden
  1386. * Backing store of defined scene components.
  1387. */
  1388. _components: ISceneComponent[];
  1389. /**
  1390. * @hidden
  1391. * Backing store of defined scene components.
  1392. */
  1393. _serializableComponents: ISceneSerializableComponent[];
  1394. /**
  1395. * List of components to register on the next registration step.
  1396. */
  1397. private _transientComponents;
  1398. /**
  1399. * Registers the transient components if needed.
  1400. */
  1401. private _registerTransientComponents;
  1402. /**
  1403. * @hidden
  1404. * Add a component to the scene.
  1405. * Note that the ccomponent could be registered on th next frame if this is called after
  1406. * the register component stage.
  1407. * @param component Defines the component to add to the scene
  1408. */
  1409. _addComponent(component: ISceneComponent): void;
  1410. /**
  1411. * @hidden
  1412. * Gets a component from the scene.
  1413. * @param name defines the name of the component to retrieve
  1414. * @returns the component or null if not present
  1415. */
  1416. _getComponent(name: string): Nullable<ISceneComponent>;
  1417. /**
  1418. * @hidden
  1419. * Defines the actions happening before camera updates.
  1420. */
  1421. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1422. /**
  1423. * @hidden
  1424. * Defines the actions happening before clear the canvas.
  1425. */
  1426. _beforeClearStage: Stage<SimpleStageAction>;
  1427. /**
  1428. * @hidden
  1429. * Defines the actions when collecting render targets for the frame.
  1430. */
  1431. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1432. /**
  1433. * @hidden
  1434. * Defines the actions happening for one camera in the frame.
  1435. */
  1436. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1437. /**
  1438. * @hidden
  1439. * Defines the actions happening during the per mesh ready checks.
  1440. */
  1441. _isReadyForMeshStage: Stage<MeshStageAction>;
  1442. /**
  1443. * @hidden
  1444. * Defines the actions happening before evaluate active mesh checks.
  1445. */
  1446. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1447. /**
  1448. * @hidden
  1449. * Defines the actions happening during the evaluate sub mesh checks.
  1450. */
  1451. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1452. /**
  1453. * @hidden
  1454. * Defines the actions happening during the active mesh stage.
  1455. */
  1456. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1457. /**
  1458. * @hidden
  1459. * Defines the actions happening during the per camera render target step.
  1460. */
  1461. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1462. /**
  1463. * @hidden
  1464. * Defines the actions happening just before the active camera is drawing.
  1465. */
  1466. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1467. /**
  1468. * @hidden
  1469. * Defines the actions happening just before a render target is drawing.
  1470. */
  1471. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1472. /**
  1473. * @hidden
  1474. * Defines the actions happening just before a rendering group is drawing.
  1475. */
  1476. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1477. /**
  1478. * @hidden
  1479. * Defines the actions happening just before a mesh is drawing.
  1480. */
  1481. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1482. /**
  1483. * @hidden
  1484. * Defines the actions happening just after a mesh has been drawn.
  1485. */
  1486. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1487. /**
  1488. * @hidden
  1489. * Defines the actions happening just after a rendering group has been drawn.
  1490. */
  1491. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1492. /**
  1493. * @hidden
  1494. * Defines the actions happening just after the active camera has been drawn.
  1495. */
  1496. _afterCameraDrawStage: Stage<CameraStageAction>;
  1497. /**
  1498. * @hidden
  1499. * Defines the actions happening just after a render target has been drawn.
  1500. */
  1501. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1502. /**
  1503. * @hidden
  1504. * Defines the actions happening just after rendering all cameras and computing intersections.
  1505. */
  1506. _afterRenderStage: Stage<SimpleStageAction>;
  1507. /**
  1508. * @hidden
  1509. * Defines the actions happening when a pointer move event happens.
  1510. */
  1511. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1512. /**
  1513. * @hidden
  1514. * Defines the actions happening when a pointer down event happens.
  1515. */
  1516. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1517. /**
  1518. * @hidden
  1519. * Defines the actions happening when a pointer up event happens.
  1520. */
  1521. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1522. /**
  1523. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  1524. */
  1525. private geometriesById;
  1526. /**
  1527. * Creates a new Scene
  1528. * @param engine defines the engine to use to render this scene
  1529. */
  1530. constructor(engine: Engine, options?: SceneOptions);
  1531. private _defaultMeshCandidates;
  1532. /**
  1533. * @hidden
  1534. */
  1535. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1536. private _defaultSubMeshCandidates;
  1537. /**
  1538. * @hidden
  1539. */
  1540. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1541. /**
  1542. * Sets the default candidate providers for the scene.
  1543. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1544. * and getCollidingSubMeshCandidates to their default function
  1545. */
  1546. setDefaultCandidateProviders(): void;
  1547. /**
  1548. * Gets a boolean indicating if collisions are processed on a web worker
  1549. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1550. */
  1551. workerCollisions: boolean;
  1552. /**
  1553. * Gets the mesh that is currently under the pointer
  1554. */
  1555. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1556. /**
  1557. * Gets the current on-screen X position of the pointer
  1558. */
  1559. readonly pointerX: number;
  1560. /**
  1561. * Gets the current on-screen Y position of the pointer
  1562. */
  1563. readonly pointerY: number;
  1564. /**
  1565. * Gets the cached material (ie. the latest rendered one)
  1566. * @returns the cached material
  1567. */
  1568. getCachedMaterial(): Nullable<Material>;
  1569. /**
  1570. * Gets the cached effect (ie. the latest rendered one)
  1571. * @returns the cached effect
  1572. */
  1573. getCachedEffect(): Nullable<Effect>;
  1574. /**
  1575. * Gets the cached visibility state (ie. the latest rendered one)
  1576. * @returns the cached visibility state
  1577. */
  1578. getCachedVisibility(): Nullable<number>;
  1579. /**
  1580. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1581. * @param material defines the current material
  1582. * @param effect defines the current effect
  1583. * @param visibility defines the current visibility state
  1584. * @returns true if one parameter is not cached
  1585. */
  1586. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1587. /**
  1588. * Gets the engine associated with the scene
  1589. * @returns an Engine
  1590. */
  1591. getEngine(): Engine;
  1592. /**
  1593. * Gets the total number of vertices rendered per frame
  1594. * @returns the total number of vertices rendered per frame
  1595. */
  1596. getTotalVertices(): number;
  1597. /**
  1598. * Gets the performance counter for total vertices
  1599. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1600. */
  1601. readonly totalVerticesPerfCounter: PerfCounter;
  1602. /**
  1603. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1604. * @returns the total number of active indices rendered per frame
  1605. */
  1606. getActiveIndices(): number;
  1607. /**
  1608. * Gets the performance counter for active indices
  1609. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1610. */
  1611. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1612. /**
  1613. * Gets the total number of active particles rendered per frame
  1614. * @returns the total number of active particles rendered per frame
  1615. */
  1616. getActiveParticles(): number;
  1617. /**
  1618. * Gets the performance counter for active particles
  1619. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1620. */
  1621. readonly activeParticlesPerfCounter: PerfCounter;
  1622. /**
  1623. * Gets the total number of active bones rendered per frame
  1624. * @returns the total number of active bones rendered per frame
  1625. */
  1626. getActiveBones(): number;
  1627. /**
  1628. * Gets the performance counter for active bones
  1629. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1630. */
  1631. readonly activeBonesPerfCounter: PerfCounter;
  1632. /**
  1633. * Gets the array of active meshes
  1634. * @returns an array of AbstractMesh
  1635. */
  1636. getActiveMeshes(): SmartArray<AbstractMesh>;
  1637. /**
  1638. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1639. * @returns a number
  1640. */
  1641. getAnimationRatio(): number;
  1642. /**
  1643. * Gets an unique Id for the current render phase
  1644. * @returns a number
  1645. */
  1646. getRenderId(): number;
  1647. /**
  1648. * Gets an unique Id for the current frame
  1649. * @returns a number
  1650. */
  1651. getFrameId(): number;
  1652. /** Call this function if you want to manually increment the render Id*/
  1653. incrementRenderId(): void;
  1654. private _updatePointerPosition;
  1655. private _createUbo;
  1656. private _createAlternateUbo;
  1657. private _setRayOnPointerInfo;
  1658. /**
  1659. * Use this method to simulate a pointer move on a mesh
  1660. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1661. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1662. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1663. * @returns the current scene
  1664. */
  1665. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1666. private _processPointerMove;
  1667. private _checkPrePointerObservable;
  1668. /**
  1669. * Use this method to simulate a pointer down on a mesh
  1670. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1671. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1672. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1673. * @returns the current scene
  1674. */
  1675. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1676. private _processPointerDown;
  1677. /**
  1678. * Use this method to simulate a pointer up on a mesh
  1679. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1680. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1681. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1682. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  1683. * @returns the current scene
  1684. */
  1685. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  1686. private _processPointerUp;
  1687. /**
  1688. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1689. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1690. * @returns true if the pointer was captured
  1691. */
  1692. isPointerCaptured(pointerId?: number): boolean;
  1693. /** @hidden */
  1694. _isPointerSwiping(): boolean;
  1695. /**
  1696. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1697. * @param attachUp defines if you want to attach events to pointerup
  1698. * @param attachDown defines if you want to attach events to pointerdown
  1699. * @param attachMove defines if you want to attach events to pointermove
  1700. */
  1701. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1702. /** Detaches all event handlers*/
  1703. detachControl(): void;
  1704. /**
  1705. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1706. * Delay loaded resources are not taking in account
  1707. * @return true if all required resources are ready
  1708. */
  1709. isReady(): boolean;
  1710. /** Resets all cached information relative to material (including effect and visibility) */
  1711. resetCachedMaterial(): void;
  1712. /**
  1713. * Registers a function to be called before every frame render
  1714. * @param func defines the function to register
  1715. */
  1716. registerBeforeRender(func: () => void): void;
  1717. /**
  1718. * Unregisters a function called before every frame render
  1719. * @param func defines the function to unregister
  1720. */
  1721. unregisterBeforeRender(func: () => void): void;
  1722. /**
  1723. * Registers a function to be called after every frame render
  1724. * @param func defines the function to register
  1725. */
  1726. registerAfterRender(func: () => void): void;
  1727. /**
  1728. * Unregisters a function called after every frame render
  1729. * @param func defines the function to unregister
  1730. */
  1731. unregisterAfterRender(func: () => void): void;
  1732. private _executeOnceBeforeRender;
  1733. /**
  1734. * The provided function will run before render once and will be disposed afterwards.
  1735. * A timeout delay can be provided so that the function will be executed in N ms.
  1736. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1737. * @param func The function to be executed.
  1738. * @param timeout optional delay in ms
  1739. */
  1740. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1741. /** @hidden */
  1742. _addPendingData(data: any): void;
  1743. /** @hidden */
  1744. _removePendingData(data: any): void;
  1745. /**
  1746. * Returns the number of items waiting to be loaded
  1747. * @returns the number of items waiting to be loaded
  1748. */
  1749. getWaitingItemsCount(): number;
  1750. /**
  1751. * Returns a boolean indicating if the scene is still loading data
  1752. */
  1753. readonly isLoading: boolean;
  1754. /**
  1755. * Registers a function to be executed when the scene is ready
  1756. * @param {Function} func - the function to be executed
  1757. */
  1758. executeWhenReady(func: () => void): void;
  1759. /**
  1760. * Returns a promise that resolves when the scene is ready
  1761. * @returns A promise that resolves when the scene is ready
  1762. */
  1763. whenReadyAsync(): Promise<void>;
  1764. /** @hidden */
  1765. _checkIsReady(): void;
  1766. /**
  1767. * Will start the animation sequence of a given target
  1768. * @param target defines the target
  1769. * @param from defines from which frame should animation start
  1770. * @param to defines until which frame should animation run.
  1771. * @param weight defines the weight to apply to the animation (1.0 by default)
  1772. * @param loop defines if the animation loops
  1773. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1774. * @param onAnimationEnd defines the function to be executed when the animation ends
  1775. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1776. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1777. * @returns the animatable object created for this animation
  1778. */
  1779. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1780. /**
  1781. * Will start the animation sequence of a given target
  1782. * @param target defines the target
  1783. * @param from defines from which frame should animation start
  1784. * @param to defines until which frame should animation run.
  1785. * @param loop defines if the animation loops
  1786. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1787. * @param onAnimationEnd defines the function to be executed when the animation ends
  1788. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1789. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1790. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1791. * @returns the animatable object created for this animation
  1792. */
  1793. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1794. /**
  1795. * Will start the animation sequence of a given target and its hierarchy
  1796. * @param target defines the target
  1797. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  1798. * @param from defines from which frame should animation start
  1799. * @param to defines until which frame should animation run.
  1800. * @param loop defines if the animation loops
  1801. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1802. * @param onAnimationEnd defines the function to be executed when the animation ends
  1803. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1804. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1805. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1806. * @returns the list of created animatables
  1807. */
  1808. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable[];
  1809. /**
  1810. * Begin a new animation on a given node
  1811. * @param target defines the target where the animation will take place
  1812. * @param animations defines the list of animations to start
  1813. * @param from defines the initial value
  1814. * @param to defines the final value
  1815. * @param loop defines if you want animation to loop (off by default)
  1816. * @param speedRatio defines the speed ratio to apply to all animations
  1817. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1818. * @returns the list of created animatables
  1819. */
  1820. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1821. /**
  1822. * Begin a new animation on a given node and its hierarchy
  1823. * @param target defines the root node where the animation will take place
  1824. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  1825. * @param animations defines the list of animations to start
  1826. * @param from defines the initial value
  1827. * @param to defines the final value
  1828. * @param loop defines if you want animation to loop (off by default)
  1829. * @param speedRatio defines the speed ratio to apply to all animations
  1830. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1831. * @returns the list of animatables created for all nodes
  1832. */
  1833. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1834. /**
  1835. * Gets the animatable associated with a specific target
  1836. * @param target defines the target of the animatable
  1837. * @returns the required animatable if found
  1838. */
  1839. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1840. /**
  1841. * Gets all animatables associated with a given target
  1842. * @param target defines the target to look animatables for
  1843. * @returns an array of Animatables
  1844. */
  1845. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1846. /**
  1847. * Gets all animatable attached to the scene
  1848. */
  1849. readonly animatables: Animatable[];
  1850. /**
  1851. * Will stop the animation of the given target
  1852. * @param target - the target
  1853. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1854. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  1855. */
  1856. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1857. /**
  1858. * Stops and removes all animations that have been applied to the scene
  1859. */
  1860. stopAllAnimations(): void;
  1861. private _animate;
  1862. /** @hidden */
  1863. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1864. private _processLateAnimationBindingsForMatrices;
  1865. private _processLateAnimationBindingsForQuaternions;
  1866. private _processLateAnimationBindings;
  1867. /** @hidden */
  1868. _switchToAlternateCameraConfiguration(active: boolean): void;
  1869. /**
  1870. * Gets the current view matrix
  1871. * @returns a Matrix
  1872. */
  1873. getViewMatrix(): Matrix;
  1874. /**
  1875. * Gets the current projection matrix
  1876. * @returns a Matrix
  1877. */
  1878. getProjectionMatrix(): Matrix;
  1879. /**
  1880. * Gets the current transform matrix
  1881. * @returns a Matrix made of View * Projection
  1882. */
  1883. getTransformMatrix(): Matrix;
  1884. /**
  1885. * Sets the current transform matrix
  1886. * @param view defines the View matrix to use
  1887. * @param projection defines the Projection matrix to use
  1888. */
  1889. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1890. /** @hidden */
  1891. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1892. /**
  1893. * Gets the uniform buffer used to store scene data
  1894. * @returns a UniformBuffer
  1895. */
  1896. getSceneUniformBuffer(): UniformBuffer;
  1897. /**
  1898. * Gets an unique (relatively to the current scene) Id
  1899. * @returns an unique number for the scene
  1900. */
  1901. getUniqueId(): number;
  1902. /**
  1903. * Add a mesh to the list of scene's meshes
  1904. * @param newMesh defines the mesh to add
  1905. * @param recursive if all child meshes should also be added to the scene
  1906. */
  1907. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1908. /**
  1909. * Remove a mesh for the list of scene's meshes
  1910. * @param toRemove defines the mesh to remove
  1911. * @param recursive if all child meshes should also be removed from the scene
  1912. * @returns the index where the mesh was in the mesh list
  1913. */
  1914. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1915. /**
  1916. * Add a transform node to the list of scene's transform nodes
  1917. * @param newTransformNode defines the transform node to add
  1918. */
  1919. addTransformNode(newTransformNode: TransformNode): void;
  1920. /**
  1921. * Remove a transform node for the list of scene's transform nodes
  1922. * @param toRemove defines the transform node to remove
  1923. * @returns the index where the transform node was in the transform node list
  1924. */
  1925. removeTransformNode(toRemove: TransformNode): number;
  1926. /**
  1927. * Remove a skeleton for the list of scene's skeletons
  1928. * @param toRemove defines the skeleton to remove
  1929. * @returns the index where the skeleton was in the skeleton list
  1930. */
  1931. removeSkeleton(toRemove: Skeleton): number;
  1932. /**
  1933. * Remove a morph target for the list of scene's morph targets
  1934. * @param toRemove defines the morph target to remove
  1935. * @returns the index where the morph target was in the morph target list
  1936. */
  1937. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1938. /**
  1939. * Remove a light for the list of scene's lights
  1940. * @param toRemove defines the light to remove
  1941. * @returns the index where the light was in the light list
  1942. */
  1943. removeLight(toRemove: Light): number;
  1944. /**
  1945. * Remove a camera for the list of scene's cameras
  1946. * @param toRemove defines the camera to remove
  1947. * @returns the index where the camera was in the camera list
  1948. */
  1949. removeCamera(toRemove: Camera): number;
  1950. /**
  1951. * Remove a particle system for the list of scene's particle systems
  1952. * @param toRemove defines the particle system to remove
  1953. * @returns the index where the particle system was in the particle system list
  1954. */
  1955. removeParticleSystem(toRemove: IParticleSystem): number;
  1956. /**
  1957. * Remove a animation for the list of scene's animations
  1958. * @param toRemove defines the animation to remove
  1959. * @returns the index where the animation was in the animation list
  1960. */
  1961. removeAnimation(toRemove: Animation): number;
  1962. /**
  1963. * Removes the given animation group from this scene.
  1964. * @param toRemove The animation group to remove
  1965. * @returns The index of the removed animation group
  1966. */
  1967. removeAnimationGroup(toRemove: AnimationGroup): number;
  1968. /**
  1969. * Removes the given multi-material from this scene.
  1970. * @param toRemove The multi-material to remove
  1971. * @returns The index of the removed multi-material
  1972. */
  1973. removeMultiMaterial(toRemove: MultiMaterial): number;
  1974. /**
  1975. * Removes the given material from this scene.
  1976. * @param toRemove The material to remove
  1977. * @returns The index of the removed material
  1978. */
  1979. removeMaterial(toRemove: Material): number;
  1980. /**
  1981. * Removes the given action manager from this scene.
  1982. * @param toRemove The action manager to remove
  1983. * @returns The index of the removed action manager
  1984. */
  1985. removeActionManager(toRemove: ActionManager): number;
  1986. /**
  1987. * Removes the given texture from this scene.
  1988. * @param toRemove The texture to remove
  1989. * @returns The index of the removed texture
  1990. */
  1991. removeTexture(toRemove: BaseTexture): number;
  1992. /**
  1993. * Adds the given light to this scene
  1994. * @param newLight The light to add
  1995. */
  1996. addLight(newLight: Light): void;
  1997. /**
  1998. * Sorts the list list based on light priorities
  1999. */
  2000. sortLightsByPriority(): void;
  2001. /**
  2002. * Adds the given camera to this scene
  2003. * @param newCamera The camera to add
  2004. */
  2005. addCamera(newCamera: Camera): void;
  2006. /**
  2007. * Adds the given skeleton to this scene
  2008. * @param newSkeleton The skeleton to add
  2009. */
  2010. addSkeleton(newSkeleton: Skeleton): void;
  2011. /**
  2012. * Adds the given particle system to this scene
  2013. * @param newParticleSystem The particle system to add
  2014. */
  2015. addParticleSystem(newParticleSystem: IParticleSystem): void;
  2016. /**
  2017. * Adds the given animation to this scene
  2018. * @param newAnimation The animation to add
  2019. */
  2020. addAnimation(newAnimation: Animation): void;
  2021. /**
  2022. * Adds the given animation group to this scene.
  2023. * @param newAnimationGroup The animation group to add
  2024. */
  2025. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  2026. /**
  2027. * Adds the given multi-material to this scene
  2028. * @param newMultiMaterial The multi-material to add
  2029. */
  2030. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  2031. /**
  2032. * Adds the given material to this scene
  2033. * @param newMaterial The material to add
  2034. */
  2035. addMaterial(newMaterial: Material): void;
  2036. /**
  2037. * Adds the given morph target to this scene
  2038. * @param newMorphTargetManager The morph target to add
  2039. */
  2040. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  2041. /**
  2042. * Adds the given geometry to this scene
  2043. * @param newGeometry The geometry to add
  2044. */
  2045. addGeometry(newGeometry: Geometry): void;
  2046. /**
  2047. * Adds the given action manager to this scene
  2048. * @param newActionManager The action manager to add
  2049. */
  2050. addActionManager(newActionManager: ActionManager): void;
  2051. /**
  2052. * Adds the given texture to this scene.
  2053. * @param newTexture The texture to add
  2054. */
  2055. addTexture(newTexture: BaseTexture): void;
  2056. /**
  2057. * Switch active camera
  2058. * @param newCamera defines the new active camera
  2059. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  2060. */
  2061. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  2062. /**
  2063. * sets the active camera of the scene using its ID
  2064. * @param id defines the camera's ID
  2065. * @return the new active camera or null if none found.
  2066. */
  2067. setActiveCameraByID(id: string): Nullable<Camera>;
  2068. /**
  2069. * sets the active camera of the scene using its name
  2070. * @param name defines the camera's name
  2071. * @returns the new active camera or null if none found.
  2072. */
  2073. setActiveCameraByName(name: string): Nullable<Camera>;
  2074. /**
  2075. * get an animation group using its name
  2076. * @param name defines the material's name
  2077. * @return the animation group or null if none found.
  2078. */
  2079. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2080. /**
  2081. * get a material using its id
  2082. * @param id defines the material's ID
  2083. * @return the material or null if none found.
  2084. */
  2085. getMaterialByID(id: string): Nullable<Material>;
  2086. /**
  2087. * Gets a material using its name
  2088. * @param name defines the material's name
  2089. * @return the material or null if none found.
  2090. */
  2091. getMaterialByName(name: string): Nullable<Material>;
  2092. /**
  2093. * Gets a camera using its id
  2094. * @param id defines the id to look for
  2095. * @returns the camera or null if not found
  2096. */
  2097. getCameraByID(id: string): Nullable<Camera>;
  2098. /**
  2099. * Gets a camera using its unique id
  2100. * @param uniqueId defines the unique id to look for
  2101. * @returns the camera or null if not found
  2102. */
  2103. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2104. /**
  2105. * Gets a camera using its name
  2106. * @param name defines the camera's name
  2107. * @return the camera or null if none found.
  2108. */
  2109. getCameraByName(name: string): Nullable<Camera>;
  2110. /**
  2111. * Gets a bone using its id
  2112. * @param id defines the bone's id
  2113. * @return the bone or null if not found
  2114. */
  2115. getBoneByID(id: string): Nullable<Bone>;
  2116. /**
  2117. * Gets a bone using its id
  2118. * @param name defines the bone's name
  2119. * @return the bone or null if not found
  2120. */
  2121. getBoneByName(name: string): Nullable<Bone>;
  2122. /**
  2123. * Gets a light node using its name
  2124. * @param name defines the the light's name
  2125. * @return the light or null if none found.
  2126. */
  2127. getLightByName(name: string): Nullable<Light>;
  2128. /**
  2129. * Gets a light node using its id
  2130. * @param id defines the light's id
  2131. * @return the light or null if none found.
  2132. */
  2133. getLightByID(id: string): Nullable<Light>;
  2134. /**
  2135. * Gets a light node using its scene-generated unique ID
  2136. * @param uniqueId defines the light's unique id
  2137. * @return the light or null if none found.
  2138. */
  2139. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2140. /**
  2141. * Gets a particle system by id
  2142. * @param id defines the particle system id
  2143. * @return the corresponding system or null if none found
  2144. */
  2145. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2146. /**
  2147. * Gets a geometry using its ID
  2148. * @param id defines the geometry's id
  2149. * @return the geometry or null if none found.
  2150. */
  2151. getGeometryByID(id: string): Nullable<Geometry>;
  2152. private _getGeometryByUniqueID;
  2153. /**
  2154. * Add a new geometry to this scene
  2155. * @param geometry defines the geometry to be added to the scene.
  2156. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2157. * @return a boolean defining if the geometry was added or not
  2158. */
  2159. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2160. /**
  2161. * Removes an existing geometry
  2162. * @param geometry defines the geometry to be removed from the scene
  2163. * @return a boolean defining if the geometry was removed or not
  2164. */
  2165. removeGeometry(geometry: Geometry): boolean;
  2166. /**
  2167. * Gets the list of geometries attached to the scene
  2168. * @returns an array of Geometry
  2169. */
  2170. getGeometries(): Geometry[];
  2171. /**
  2172. * Gets the first added mesh found of a given ID
  2173. * @param id defines the id to search for
  2174. * @return the mesh found or null if not found at all
  2175. */
  2176. getMeshByID(id: string): Nullable<AbstractMesh>;
  2177. /**
  2178. * Gets a list of meshes using their id
  2179. * @param id defines the id to search for
  2180. * @returns a list of meshes
  2181. */
  2182. getMeshesByID(id: string): Array<AbstractMesh>;
  2183. /**
  2184. * Gets the first added transform node found of a given ID
  2185. * @param id defines the id to search for
  2186. * @return the found transform node or null if not found at all.
  2187. */
  2188. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2189. /**
  2190. * Gets a list of transform nodes using their id
  2191. * @param id defines the id to search for
  2192. * @returns a list of transform nodes
  2193. */
  2194. getTransformNodesByID(id: string): Array<TransformNode>;
  2195. /**
  2196. * Gets a mesh with its auto-generated unique id
  2197. * @param uniqueId defines the unique id to search for
  2198. * @return the found mesh or null if not found at all.
  2199. */
  2200. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2201. /**
  2202. * Gets a the last added mesh using a given id
  2203. * @param id defines the id to search for
  2204. * @return the found mesh or null if not found at all.
  2205. */
  2206. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2207. /**
  2208. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2209. * @param id defines the id to search for
  2210. * @return the found node or null if not found at all
  2211. */
  2212. getLastEntryByID(id: string): Nullable<Node>;
  2213. /**
  2214. * Gets a node (Mesh, Camera, Light) using a given id
  2215. * @param id defines the id to search for
  2216. * @return the found node or null if not found at all
  2217. */
  2218. getNodeByID(id: string): Nullable<Node>;
  2219. /**
  2220. * Gets a node (Mesh, Camera, Light) using a given name
  2221. * @param name defines the name to search for
  2222. * @return the found node or null if not found at all.
  2223. */
  2224. getNodeByName(name: string): Nullable<Node>;
  2225. /**
  2226. * Gets a mesh using a given name
  2227. * @param name defines the name to search for
  2228. * @return the found mesh or null if not found at all.
  2229. */
  2230. getMeshByName(name: string): Nullable<AbstractMesh>;
  2231. /**
  2232. * Gets a transform node using a given name
  2233. * @param name defines the name to search for
  2234. * @return the found transform node or null if not found at all.
  2235. */
  2236. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2237. /**
  2238. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2239. * @param id defines the id to search for
  2240. * @return the found skeleton or null if not found at all.
  2241. */
  2242. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2243. /**
  2244. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2245. * @param id defines the id to search for
  2246. * @return the found skeleton or null if not found at all.
  2247. */
  2248. getSkeletonById(id: string): Nullable<Skeleton>;
  2249. /**
  2250. * Gets a skeleton using a given name
  2251. * @param name defines the name to search for
  2252. * @return the found skeleton or null if not found at all.
  2253. */
  2254. getSkeletonByName(name: string): Nullable<Skeleton>;
  2255. /**
  2256. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2257. * @param id defines the id to search for
  2258. * @return the found morph target manager or null if not found at all.
  2259. */
  2260. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2261. /**
  2262. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  2263. * @param id defines the id to search for
  2264. * @return the found morph target or null if not found at all.
  2265. */
  2266. getMorphTargetById(id: string): Nullable<MorphTarget>;
  2267. /**
  2268. * Gets a boolean indicating if the given mesh is active
  2269. * @param mesh defines the mesh to look for
  2270. * @returns true if the mesh is in the active list
  2271. */
  2272. isActiveMesh(mesh: AbstractMesh): boolean;
  2273. /**
  2274. * Return a unique id as a string which can serve as an identifier for the scene
  2275. */
  2276. readonly uid: string;
  2277. /**
  2278. * Add an externaly attached data from its key.
  2279. * This method call will fail and return false, if such key already exists.
  2280. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2281. * @param key the unique key that identifies the data
  2282. * @param data the data object to associate to the key for this Engine instance
  2283. * @return true if no such key were already present and the data was added successfully, false otherwise
  2284. */
  2285. addExternalData<T>(key: string, data: T): boolean;
  2286. /**
  2287. * Get an externaly attached data from its key
  2288. * @param key the unique key that identifies the data
  2289. * @return the associated data, if present (can be null), or undefined if not present
  2290. */
  2291. getExternalData<T>(key: string): Nullable<T>;
  2292. /**
  2293. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2294. * @param key the unique key that identifies the data
  2295. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2296. * @return the associated data, can be null if the factory returned null.
  2297. */
  2298. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2299. /**
  2300. * Remove an externaly attached data from the Engine instance
  2301. * @param key the unique key that identifies the data
  2302. * @return true if the data was successfully removed, false if it doesn't exist
  2303. */
  2304. removeExternalData(key: string): boolean;
  2305. private _evaluateSubMesh;
  2306. /**
  2307. * Clear the processed materials smart array preventing retention point in material dispose.
  2308. */
  2309. freeProcessedMaterials(): void;
  2310. private _preventFreeActiveMeshesAndRenderingGroups;
  2311. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  2312. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  2313. * when disposing several meshes in a row or a hierarchy of meshes.
  2314. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  2315. */
  2316. blockfreeActiveMeshesAndRenderingGroups: boolean;
  2317. /**
  2318. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2319. */
  2320. freeActiveMeshes(): void;
  2321. /**
  2322. * Clear the info related to rendering groups preventing retention points during dispose.
  2323. */
  2324. freeRenderingGroups(): void;
  2325. /** @hidden */
  2326. _isInIntermediateRendering(): boolean;
  2327. /**
  2328. * Lambda returning the list of potentially active meshes.
  2329. */
  2330. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2331. /**
  2332. * Lambda returning the list of potentially active sub meshes.
  2333. */
  2334. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2335. /**
  2336. * Lambda returning the list of potentially intersecting sub meshes.
  2337. */
  2338. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2339. /**
  2340. * Lambda returning the list of potentially colliding sub meshes.
  2341. */
  2342. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2343. private _activeMeshesFrozen;
  2344. /**
  2345. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2346. * @returns the current scene
  2347. */
  2348. freezeActiveMeshes(): Scene;
  2349. /**
  2350. * Use this function to restart evaluating active meshes on every frame
  2351. * @returns the current scene
  2352. */
  2353. unfreezeActiveMeshes(): Scene;
  2354. private _evaluateActiveMeshes;
  2355. private _activeMesh;
  2356. /**
  2357. * Update the transform matrix to update from the current active camera
  2358. * @param force defines a boolean used to force the update even if cache is up to date
  2359. */
  2360. updateTransformMatrix(force?: boolean): void;
  2361. /**
  2362. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  2363. * @param alternateCamera defines the camera to use
  2364. */
  2365. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2366. /** @hidden */
  2367. _allowPostProcessClearColor: boolean;
  2368. private _renderForCamera;
  2369. private _processSubCameras;
  2370. private _checkIntersections;
  2371. /** @hidden */
  2372. _advancePhysicsEngineStep(step: number): void;
  2373. /**
  2374. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2375. */
  2376. getDeterministicFrameTime: () => number;
  2377. /**
  2378. * Render the scene
  2379. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2380. */
  2381. render(updateCameras?: boolean): void;
  2382. /**
  2383. * Freeze all materials
  2384. * A frozen material will not be updatable but should be faster to render
  2385. */
  2386. freezeMaterials(): void;
  2387. /**
  2388. * Unfreeze all materials
  2389. * A frozen material will not be updatable but should be faster to render
  2390. */
  2391. unfreezeMaterials(): void;
  2392. /**
  2393. * Releases all held ressources
  2394. */
  2395. dispose(): void;
  2396. /**
  2397. * Gets if the scene is already disposed
  2398. */
  2399. readonly isDisposed: boolean;
  2400. /**
  2401. * Call this function to reduce memory footprint of the scene.
  2402. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2403. */
  2404. clearCachedVertexData(): void;
  2405. /**
  2406. * This function will remove the local cached buffer data from texture.
  2407. * It will save memory but will prevent the texture from being rebuilt
  2408. */
  2409. cleanCachedTextureBuffer(): void;
  2410. /**
  2411. * Get the world extend vectors with an optional filter
  2412. *
  2413. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2414. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2415. */
  2416. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2417. min: Vector3;
  2418. max: Vector3;
  2419. };
  2420. /**
  2421. * Creates a ray that can be used to pick in the scene
  2422. * @param x defines the x coordinate of the origin (on-screen)
  2423. * @param y defines the y coordinate of the origin (on-screen)
  2424. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2425. * @param camera defines the camera to use for the picking
  2426. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2427. * @returns a Ray
  2428. */
  2429. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2430. /**
  2431. * Creates a ray that can be used to pick in the scene
  2432. * @param x defines the x coordinate of the origin (on-screen)
  2433. * @param y defines the y coordinate of the origin (on-screen)
  2434. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2435. * @param result defines the ray where to store the picking ray
  2436. * @param camera defines the camera to use for the picking
  2437. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2438. * @returns the current scene
  2439. */
  2440. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2441. /**
  2442. * Creates a ray that can be used to pick in the scene
  2443. * @param x defines the x coordinate of the origin (on-screen)
  2444. * @param y defines the y coordinate of the origin (on-screen)
  2445. * @param camera defines the camera to use for the picking
  2446. * @returns a Ray
  2447. */
  2448. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2449. /**
  2450. * Creates a ray that can be used to pick in the scene
  2451. * @param x defines the x coordinate of the origin (on-screen)
  2452. * @param y defines the y coordinate of the origin (on-screen)
  2453. * @param result defines the ray where to store the picking ray
  2454. * @param camera defines the camera to use for the picking
  2455. * @returns the current scene
  2456. */
  2457. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2458. private _internalPick;
  2459. private _internalMultiPick;
  2460. private _tempPickingRay;
  2461. /** Launch a ray to try to pick a mesh in the scene
  2462. * @param x position on screen
  2463. * @param y position on screen
  2464. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2465. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2466. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2467. * @returns a PickingInfo
  2468. */
  2469. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2470. private _cachedRayForTransform;
  2471. /** Use the given ray to pick a mesh in the scene
  2472. * @param ray The ray to use to pick meshes
  2473. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  2474. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2475. * @returns a PickingInfo
  2476. */
  2477. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2478. /**
  2479. * Launch a ray to try to pick a mesh in the scene
  2480. * @param x X position on screen
  2481. * @param y Y position on screen
  2482. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2483. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2484. * @returns an array of PickingInfo
  2485. */
  2486. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2487. /**
  2488. * Launch a ray to try to pick a mesh in the scene
  2489. * @param ray Ray to use
  2490. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2491. * @returns an array of PickingInfo
  2492. */
  2493. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2494. /**
  2495. * Force the value of meshUnderPointer
  2496. * @param mesh defines the mesh to use
  2497. */
  2498. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2499. /**
  2500. * Gets the mesh under the pointer
  2501. * @returns a Mesh or null if no mesh is under the pointer
  2502. */
  2503. getPointerOverMesh(): Nullable<AbstractMesh>;
  2504. /** @hidden */
  2505. _rebuildGeometries(): void;
  2506. /** @hidden */
  2507. _rebuildTextures(): void;
  2508. private _getByTags;
  2509. /**
  2510. * Get a list of meshes by tags
  2511. * @param tagsQuery defines the tags query to use
  2512. * @param forEach defines a predicate used to filter results
  2513. * @returns an array of Mesh
  2514. */
  2515. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2516. /**
  2517. * Get a list of cameras by tags
  2518. * @param tagsQuery defines the tags query to use
  2519. * @param forEach defines a predicate used to filter results
  2520. * @returns an array of Camera
  2521. */
  2522. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2523. /**
  2524. * Get a list of lights by tags
  2525. * @param tagsQuery defines the tags query to use
  2526. * @param forEach defines a predicate used to filter results
  2527. * @returns an array of Light
  2528. */
  2529. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2530. /**
  2531. * Get a list of materials by tags
  2532. * @param tagsQuery defines the tags query to use
  2533. * @param forEach defines a predicate used to filter results
  2534. * @returns an array of Material
  2535. */
  2536. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2537. /**
  2538. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2539. * This allowed control for front to back rendering or reversly depending of the special needs.
  2540. *
  2541. * @param renderingGroupId The rendering group id corresponding to its index
  2542. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2543. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2544. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2545. */
  2546. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  2547. /**
  2548. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2549. *
  2550. * @param renderingGroupId The rendering group id corresponding to its index
  2551. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2552. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2553. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2554. */
  2555. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2556. /**
  2557. * Gets the current auto clear configuration for one rendering group of the rendering
  2558. * manager.
  2559. * @param index the rendering group index to get the information for
  2560. * @returns The auto clear setup for the requested rendering group
  2561. */
  2562. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2563. private _blockMaterialDirtyMechanism;
  2564. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2565. blockMaterialDirtyMechanism: boolean;
  2566. /**
  2567. * Will flag all materials as dirty to trigger new shader compilation
  2568. * @param flag defines the flag used to specify which material part must be marked as dirty
  2569. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2570. */
  2571. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2572. /** @hidden */
  2573. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  2574. /** @hidden */
  2575. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2576. }
  2577. }
  2578. declare module BABYLON {
  2579. /**
  2580. * Groups all the scene component constants in one place to ease maintenance.
  2581. * @hidden
  2582. */
  2583. class SceneComponentConstants {
  2584. static readonly NAME_EFFECTLAYER: string;
  2585. static readonly NAME_LAYER: string;
  2586. static readonly NAME_LENSFLARESYSTEM: string;
  2587. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2588. static readonly NAME_PARTICLESYSTEM: string;
  2589. static readonly NAME_GAMEPAD: string;
  2590. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2591. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2592. static readonly NAME_DEPTHRENDERER: string;
  2593. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2594. static readonly NAME_SPRITE: string;
  2595. static readonly NAME_OUTLINERENDERER: string;
  2596. static readonly NAME_PROCEDURALTEXTURE: string;
  2597. static readonly NAME_SHADOWGENERATOR: string;
  2598. static readonly NAME_OCTREE: string;
  2599. static readonly NAME_PHYSICSENGINE: string;
  2600. static readonly NAME_AUDIO: string;
  2601. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2602. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2603. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2604. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2605. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2606. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2607. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2608. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  2609. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2610. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2611. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2612. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2613. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2614. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2615. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2616. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  2617. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2618. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2619. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2620. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2621. static readonly STEP_AFTERRENDER_AUDIO: number;
  2622. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2623. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2624. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2625. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2626. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2627. static readonly STEP_POINTERMOVE_SPRITE: number;
  2628. static readonly STEP_POINTERDOWN_SPRITE: number;
  2629. static readonly STEP_POINTERUP_SPRITE: number;
  2630. }
  2631. /**
  2632. * This represents a scene component.
  2633. *
  2634. * This is used to decouple the dependency the scene is having on the different workloads like
  2635. * layers, post processes...
  2636. */
  2637. interface ISceneComponent {
  2638. /**
  2639. * The name of the component. Each component must have a unique name.
  2640. */
  2641. name: string;
  2642. /**
  2643. * The scene the component belongs to.
  2644. */
  2645. scene: Scene;
  2646. /**
  2647. * Register the component to one instance of a scene.
  2648. */
  2649. register(): void;
  2650. /**
  2651. * Rebuilds the elements related to this component in case of
  2652. * context lost for instance.
  2653. */
  2654. rebuild(): void;
  2655. /**
  2656. * Disposes the component and the associated ressources.
  2657. */
  2658. dispose(): void;
  2659. }
  2660. /**
  2661. * This represents a SERIALIZABLE scene component.
  2662. *
  2663. * This extends Scene Component to add Serialization methods on top.
  2664. */
  2665. interface ISceneSerializableComponent extends ISceneComponent {
  2666. /**
  2667. * Adds all the element from the container to the scene
  2668. * @param container the container holding the elements
  2669. */
  2670. addFromContainer(container: AbstractScene): void;
  2671. /**
  2672. * Removes all the elements in the container from the scene
  2673. * @param container contains the elements to remove
  2674. */
  2675. removeFromContainer(container: AbstractScene): void;
  2676. /**
  2677. * Serializes the component data to the specified json object
  2678. * @param serializationObject The object to serialize to
  2679. */
  2680. serialize(serializationObject: any): void;
  2681. }
  2682. /**
  2683. * Strong typing of a Mesh related stage step action
  2684. */
  2685. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2686. /**
  2687. * Strong typing of a Evaluate Sub Mesh related stage step action
  2688. */
  2689. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2690. /**
  2691. * Strong typing of a Active Mesh related stage step action
  2692. */
  2693. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2694. /**
  2695. * Strong typing of a Camera related stage step action
  2696. */
  2697. type CameraStageAction = (camera: Camera) => void;
  2698. /**
  2699. * Strong typing of a Render Target related stage step action
  2700. */
  2701. type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  2702. /**
  2703. * Strong typing of a RenderingGroup related stage step action
  2704. */
  2705. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2706. /**
  2707. * Strong typing of a Mesh Render related stage step action
  2708. */
  2709. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2710. /**
  2711. * Strong typing of a simple stage step action
  2712. */
  2713. type SimpleStageAction = () => void;
  2714. /**
  2715. * Strong typing of a render target action.
  2716. */
  2717. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2718. /**
  2719. * Strong typing of a pointer move action.
  2720. */
  2721. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2722. /**
  2723. * Strong typing of a pointer up/down action.
  2724. */
  2725. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2726. /**
  2727. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2728. * @hidden
  2729. */
  2730. class Stage<T extends Function> extends Array<{
  2731. index: number;
  2732. component: ISceneComponent;
  2733. action: T;
  2734. }> {
  2735. /**
  2736. * Hide ctor from the rest of the world.
  2737. * @param items The items to add.
  2738. */
  2739. private constructor();
  2740. /**
  2741. * Creates a new Stage.
  2742. * @returns A new instance of a Stage
  2743. */
  2744. static Create<T extends Function>(): Stage<T>;
  2745. /**
  2746. * Registers a step in an ordered way in the targeted stage.
  2747. * @param index Defines the position to register the step in
  2748. * @param component Defines the component attached to the step
  2749. * @param action Defines the action to launch during the step
  2750. */
  2751. registerStep(index: number, component: ISceneComponent, action: T): void;
  2752. /**
  2753. * Clears all the steps from the stage.
  2754. */
  2755. clear(): void;
  2756. }
  2757. }
  2758. declare module BABYLON {
  2759. /** Alias type for value that can be null */
  2760. type Nullable<T> = T | null;
  2761. /**
  2762. * Alias type for number that are floats
  2763. * @ignorenaming
  2764. */
  2765. type float = number;
  2766. /**
  2767. * Alias type for number that are doubles.
  2768. * @ignorenaming
  2769. */
  2770. type double = number;
  2771. /**
  2772. * Alias type for number that are integer
  2773. * @ignorenaming
  2774. */
  2775. type int = number;
  2776. /** Alias type for number array or Float32Array */
  2777. type FloatArray = number[] | Float32Array;
  2778. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2779. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2780. /**
  2781. * Alias for types that can be used by a Buffer or VertexBuffer.
  2782. */
  2783. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2784. /**
  2785. * Alias type for primitive types
  2786. * @ignorenaming
  2787. */
  2788. type Primitive = undefined | null | boolean | string | number | Function;
  2789. /**
  2790. * Type modifier to make all the properties of an object Readonly
  2791. */
  2792. type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  2793. /**
  2794. * Type modifier to make all the properties of an object Readonly recursively
  2795. */
  2796. type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  2797. /** @hidden */
  2798. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  2799. }
  2800. /** @hidden */
  2801. /** @hidden */
  2802. type DeepImmutableObject<T> = {
  2803. readonly [K in keyof T]: DeepImmutable<T[K]>;
  2804. };
  2805. }
  2806. declare module BABYLON {
  2807. /**
  2808. * The action to be carried out following a trigger
  2809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2810. */
  2811. class Action {
  2812. /** the trigger, with or without parameters, for the action */
  2813. triggerOptions: any;
  2814. /**
  2815. * Trigger for the action
  2816. */
  2817. trigger: number;
  2818. /**
  2819. * Internal only - manager for action
  2820. * @hidden
  2821. */
  2822. _actionManager: ActionManager;
  2823. private _nextActiveAction;
  2824. private _child;
  2825. private _condition?;
  2826. private _triggerParameter;
  2827. /**
  2828. * An event triggered prior to action being executed.
  2829. */
  2830. onBeforeExecuteObservable: Observable<Action>;
  2831. /**
  2832. * Creates a new Action
  2833. * @param triggerOptions the trigger, with or without parameters, for the action
  2834. * @param condition an optional determinant of action
  2835. */
  2836. constructor(
  2837. /** the trigger, with or without parameters, for the action */
  2838. triggerOptions: any, condition?: Condition);
  2839. /**
  2840. * Internal only
  2841. * @hidden
  2842. */
  2843. _prepare(): void;
  2844. /**
  2845. * Gets the trigger parameters
  2846. * @returns the trigger parameters
  2847. */
  2848. getTriggerParameter(): any;
  2849. /**
  2850. * Internal only - executes current action event
  2851. * @hidden
  2852. */
  2853. _executeCurrent(evt?: ActionEvent): void;
  2854. /**
  2855. * Execute placeholder for child classes
  2856. * @param evt optional action event
  2857. */
  2858. execute(evt?: ActionEvent): void;
  2859. /**
  2860. * Skips to next active action
  2861. */
  2862. skipToNextActiveAction(): void;
  2863. /**
  2864. * Adds action to chain of actions, may be a DoNothingAction
  2865. * @param action defines the next action to execute
  2866. * @returns The action passed in
  2867. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2868. */
  2869. then(action: Action): Action;
  2870. /**
  2871. * Internal only
  2872. * @hidden
  2873. */
  2874. _getProperty(propertyPath: string): string;
  2875. /**
  2876. * Internal only
  2877. * @hidden
  2878. */
  2879. _getEffectiveTarget(target: any, propertyPath: string): any;
  2880. /**
  2881. * Serialize placeholder for child classes
  2882. * @param parent of child
  2883. * @returns the serialized object
  2884. */
  2885. serialize(parent: any): any;
  2886. /**
  2887. * Internal only called by serialize
  2888. * @hidden
  2889. */
  2890. protected _serialize(serializedAction: any, parent?: any): any;
  2891. /**
  2892. * Internal only
  2893. * @hidden
  2894. */
  2895. static _SerializeValueAsString: (value: any) => string;
  2896. /**
  2897. * Internal only
  2898. * @hidden
  2899. */
  2900. static _GetTargetProperty: (target: Scene | Node) => {
  2901. name: string;
  2902. targetType: string;
  2903. value: string;
  2904. };
  2905. }
  2906. }
  2907. declare module BABYLON {
  2908. /**
  2909. * ActionEvent is the event being sent when an action is triggered.
  2910. */
  2911. class ActionEvent {
  2912. /** The mesh or sprite that triggered the action */
  2913. source: any;
  2914. /** The X mouse cursor position at the time of the event */
  2915. pointerX: number;
  2916. /** The Y mouse cursor position at the time of the event */
  2917. pointerY: number;
  2918. /** The mesh that is currently pointed at (can be null) */
  2919. meshUnderPointer: Nullable<AbstractMesh>;
  2920. /** the original (browser) event that triggered the ActionEvent */
  2921. sourceEvent?: any;
  2922. /** additional data for the event */
  2923. additionalData?: any;
  2924. /**
  2925. * Creates a new ActionEvent
  2926. * @param source The mesh or sprite that triggered the action
  2927. * @param pointerX The X mouse cursor position at the time of the event
  2928. * @param pointerY The Y mouse cursor position at the time of the event
  2929. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2930. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2931. * @param additionalData additional data for the event
  2932. */
  2933. constructor(
  2934. /** The mesh or sprite that triggered the action */
  2935. source: any,
  2936. /** The X mouse cursor position at the time of the event */
  2937. pointerX: number,
  2938. /** The Y mouse cursor position at the time of the event */
  2939. pointerY: number,
  2940. /** The mesh that is currently pointed at (can be null) */
  2941. meshUnderPointer: Nullable<AbstractMesh>,
  2942. /** the original (browser) event that triggered the ActionEvent */
  2943. sourceEvent?: any,
  2944. /** additional data for the event */
  2945. additionalData?: any);
  2946. /**
  2947. * Helper function to auto-create an ActionEvent from a source mesh.
  2948. * @param source The source mesh that triggered the event
  2949. * @param evt The original (browser) event
  2950. * @param additionalData additional data for the event
  2951. * @returns the new ActionEvent
  2952. */
  2953. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2954. /**
  2955. * Helper function to auto-create an ActionEvent from a source sprite
  2956. * @param source The source sprite that triggered the event
  2957. * @param scene Scene associated with the sprite
  2958. * @param evt The original (browser) event
  2959. * @param additionalData additional data for the event
  2960. * @returns the new ActionEvent
  2961. */
  2962. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2963. /**
  2964. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2965. * @param scene the scene where the event occurred
  2966. * @param evt The original (browser) event
  2967. * @returns the new ActionEvent
  2968. */
  2969. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2970. /**
  2971. * Helper function to auto-create an ActionEvent from a primitive
  2972. * @param prim defines the target primitive
  2973. * @param pointerPos defines the pointer position
  2974. * @param evt The original (browser) event
  2975. * @param additionalData additional data for the event
  2976. * @returns the new ActionEvent
  2977. */
  2978. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2979. }
  2980. /**
  2981. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2982. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2984. */
  2985. class ActionManager {
  2986. /**
  2987. * Nothing
  2988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2989. */
  2990. static readonly NothingTrigger: number;
  2991. /**
  2992. * On pick
  2993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2994. */
  2995. static readonly OnPickTrigger: number;
  2996. /**
  2997. * On left pick
  2998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2999. */
  3000. static readonly OnLeftPickTrigger: number;
  3001. /**
  3002. * On right pick
  3003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3004. */
  3005. static readonly OnRightPickTrigger: number;
  3006. /**
  3007. * On center pick
  3008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3009. */
  3010. static readonly OnCenterPickTrigger: number;
  3011. /**
  3012. * On pick down
  3013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3014. */
  3015. static readonly OnPickDownTrigger: number;
  3016. /**
  3017. * On double pick
  3018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3019. */
  3020. static readonly OnDoublePickTrigger: number;
  3021. /**
  3022. * On pick up
  3023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3024. */
  3025. static readonly OnPickUpTrigger: number;
  3026. /**
  3027. * On pick out.
  3028. * This trigger will only be raised if you also declared a OnPickDown
  3029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3030. */
  3031. static readonly OnPickOutTrigger: number;
  3032. /**
  3033. * On long press
  3034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3035. */
  3036. static readonly OnLongPressTrigger: number;
  3037. /**
  3038. * On pointer over
  3039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3040. */
  3041. static readonly OnPointerOverTrigger: number;
  3042. /**
  3043. * On pointer out
  3044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3045. */
  3046. static readonly OnPointerOutTrigger: number;
  3047. /**
  3048. * On every frame
  3049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3050. */
  3051. static readonly OnEveryFrameTrigger: number;
  3052. /**
  3053. * On intersection enter
  3054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3055. */
  3056. static readonly OnIntersectionEnterTrigger: number;
  3057. /**
  3058. * On intersection exit
  3059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3060. */
  3061. static readonly OnIntersectionExitTrigger: number;
  3062. /**
  3063. * On key down
  3064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3065. */
  3066. static readonly OnKeyDownTrigger: number;
  3067. /**
  3068. * On key up
  3069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3070. */
  3071. static readonly OnKeyUpTrigger: number;
  3072. /** Gets the list of active triggers */
  3073. static Triggers: {
  3074. [key: string]: number;
  3075. };
  3076. /** Gets the list of actions */
  3077. actions: Action[];
  3078. /** Gets the cursor to use when hovering items */
  3079. hoverCursor: string;
  3080. private _scene;
  3081. /**
  3082. * Creates a new action manager
  3083. * @param scene defines the hosting scene
  3084. */
  3085. constructor(scene: Scene);
  3086. /**
  3087. * Releases all associated resources
  3088. */
  3089. dispose(): void;
  3090. /**
  3091. * Gets hosting scene
  3092. * @returns the hosting scene
  3093. */
  3094. getScene(): Scene;
  3095. /**
  3096. * Does this action manager handles actions of any of the given triggers
  3097. * @param triggers defines the triggers to be tested
  3098. * @return a boolean indicating whether one (or more) of the triggers is handled
  3099. */
  3100. hasSpecificTriggers(triggers: number[]): boolean;
  3101. /**
  3102. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3103. * speed.
  3104. * @param triggerA defines the trigger to be tested
  3105. * @param triggerB defines the trigger to be tested
  3106. * @return a boolean indicating whether one (or more) of the triggers is handled
  3107. */
  3108. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3109. /**
  3110. * Does this action manager handles actions of a given trigger
  3111. * @param trigger defines the trigger to be tested
  3112. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3113. * @return whether the trigger is handled
  3114. */
  3115. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3116. /**
  3117. * Does this action manager has pointer triggers
  3118. */
  3119. readonly hasPointerTriggers: boolean;
  3120. /**
  3121. * Does this action manager has pick triggers
  3122. */
  3123. readonly hasPickTriggers: boolean;
  3124. /**
  3125. * Does exist one action manager with at least one trigger
  3126. **/
  3127. static readonly HasTriggers: boolean;
  3128. /**
  3129. * Does exist one action manager with at least one pick trigger
  3130. **/
  3131. static readonly HasPickTriggers: boolean;
  3132. /**
  3133. * Does exist one action manager that handles actions of a given trigger
  3134. * @param trigger defines the trigger to be tested
  3135. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3136. **/
  3137. static HasSpecificTrigger(trigger: number): boolean;
  3138. /**
  3139. * Registers an action to this action manager
  3140. * @param action defines the action to be registered
  3141. * @return the action amended (prepared) after registration
  3142. */
  3143. registerAction(action: Action): Nullable<Action>;
  3144. /**
  3145. * Unregisters an action to this action manager
  3146. * @param action defines the action to be unregistered
  3147. * @return a boolean indicating whether the action has been unregistered
  3148. */
  3149. unregisterAction(action: Action): Boolean;
  3150. /**
  3151. * Process a specific trigger
  3152. * @param trigger defines the trigger to process
  3153. * @param evt defines the event details to be processed
  3154. */
  3155. processTrigger(trigger: number, evt?: ActionEvent): void;
  3156. /** @hidden */
  3157. _getEffectiveTarget(target: any, propertyPath: string): any;
  3158. /** @hidden */
  3159. _getProperty(propertyPath: string): string;
  3160. /**
  3161. * Serialize this manager to a JSON object
  3162. * @param name defines the property name to store this manager
  3163. * @returns a JSON representation of this manager
  3164. */
  3165. serialize(name: string): any;
  3166. /**
  3167. * Creates a new ActionManager from a JSON data
  3168. * @param parsedActions defines the JSON data to read from
  3169. * @param object defines the hosting mesh
  3170. * @param scene defines the hosting scene
  3171. */
  3172. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3173. /**
  3174. * Get a trigger name by index
  3175. * @param trigger defines the trigger index
  3176. * @returns a trigger name
  3177. */
  3178. static GetTriggerName(trigger: number): string;
  3179. }
  3180. }
  3181. declare module BABYLON {
  3182. /**
  3183. * A Condition applied to an Action
  3184. */
  3185. class Condition {
  3186. /**
  3187. * Internal only - manager for action
  3188. * @hidden
  3189. */
  3190. _actionManager: ActionManager;
  3191. /**
  3192. * Internal only
  3193. * @hidden
  3194. */
  3195. _evaluationId: number;
  3196. /**
  3197. * Internal only
  3198. * @hidden
  3199. */
  3200. _currentResult: boolean;
  3201. /**
  3202. * Creates a new Condition
  3203. * @param actionManager the manager of the action the condition is applied to
  3204. */
  3205. constructor(actionManager: ActionManager);
  3206. /**
  3207. * Check if the current condition is valid
  3208. * @returns a boolean
  3209. */
  3210. isValid(): boolean;
  3211. /**
  3212. * Internal only
  3213. * @hidden
  3214. */
  3215. _getProperty(propertyPath: string): string;
  3216. /**
  3217. * Internal only
  3218. * @hidden
  3219. */
  3220. _getEffectiveTarget(target: any, propertyPath: string): any;
  3221. /**
  3222. * Serialize placeholder for child classes
  3223. * @returns the serialized object
  3224. */
  3225. serialize(): any;
  3226. /**
  3227. * Internal only
  3228. * @hidden
  3229. */
  3230. protected _serialize(serializedCondition: any): any;
  3231. }
  3232. /**
  3233. * Defines specific conditional operators as extensions of Condition
  3234. */
  3235. class ValueCondition extends Condition {
  3236. /** path to specify the property of the target the conditional operator uses */
  3237. propertyPath: string;
  3238. /** the value compared by the conditional operator against the current value of the property */
  3239. value: any;
  3240. /** the conditional operator, default ValueCondition.IsEqual */
  3241. operator: number;
  3242. /**
  3243. * Internal only
  3244. * @hidden
  3245. */
  3246. private static _IsEqual;
  3247. /**
  3248. * Internal only
  3249. * @hidden
  3250. */
  3251. private static _IsDifferent;
  3252. /**
  3253. * Internal only
  3254. * @hidden
  3255. */
  3256. private static _IsGreater;
  3257. /**
  3258. * Internal only
  3259. * @hidden
  3260. */
  3261. private static _IsLesser;
  3262. /**
  3263. * returns the number for IsEqual
  3264. */
  3265. static readonly IsEqual: number;
  3266. /**
  3267. * Returns the number for IsDifferent
  3268. */
  3269. static readonly IsDifferent: number;
  3270. /**
  3271. * Returns the number for IsGreater
  3272. */
  3273. static readonly IsGreater: number;
  3274. /**
  3275. * Returns the number for IsLesser
  3276. */
  3277. static readonly IsLesser: number;
  3278. /**
  3279. * Internal only The action manager for the condition
  3280. * @hidden
  3281. */
  3282. _actionManager: ActionManager;
  3283. /**
  3284. * Internal only
  3285. * @hidden
  3286. */
  3287. private _target;
  3288. /**
  3289. * Internal only
  3290. * @hidden
  3291. */
  3292. private _effectiveTarget;
  3293. /**
  3294. * Internal only
  3295. * @hidden
  3296. */
  3297. private _property;
  3298. /**
  3299. * Creates a new ValueCondition
  3300. * @param actionManager manager for the action the condition applies to
  3301. * @param target for the action
  3302. * @param propertyPath path to specify the property of the target the conditional operator uses
  3303. * @param value the value compared by the conditional operator against the current value of the property
  3304. * @param operator the conditional operator, default ValueCondition.IsEqual
  3305. */
  3306. constructor(actionManager: ActionManager, target: any,
  3307. /** path to specify the property of the target the conditional operator uses */
  3308. propertyPath: string,
  3309. /** the value compared by the conditional operator against the current value of the property */
  3310. value: any,
  3311. /** the conditional operator, default ValueCondition.IsEqual */
  3312. operator?: number);
  3313. /**
  3314. * Compares the given value with the property value for the specified conditional operator
  3315. * @returns the result of the comparison
  3316. */
  3317. isValid(): boolean;
  3318. /**
  3319. * Serialize the ValueCondition into a JSON compatible object
  3320. * @returns serialization object
  3321. */
  3322. serialize(): any;
  3323. /**
  3324. * Gets the name of the conditional operator for the ValueCondition
  3325. * @param operator the conditional operator
  3326. * @returns the name
  3327. */
  3328. static GetOperatorName(operator: number): string;
  3329. }
  3330. /**
  3331. * Defines a predicate condition as an extension of Condition
  3332. */
  3333. class PredicateCondition extends Condition {
  3334. /** defines the predicate function used to validate the condition */
  3335. predicate: () => boolean;
  3336. /**
  3337. * Internal only - manager for action
  3338. * @hidden
  3339. */
  3340. _actionManager: ActionManager;
  3341. /**
  3342. * Creates a new PredicateCondition
  3343. * @param actionManager manager for the action the condition applies to
  3344. * @param predicate defines the predicate function used to validate the condition
  3345. */
  3346. constructor(actionManager: ActionManager,
  3347. /** defines the predicate function used to validate the condition */
  3348. predicate: () => boolean);
  3349. /**
  3350. * @returns the validity of the predicate condition
  3351. */
  3352. isValid(): boolean;
  3353. }
  3354. /**
  3355. * Defines a state condition as an extension of Condition
  3356. */
  3357. class StateCondition extends Condition {
  3358. /** Value to compare with target state */
  3359. value: string;
  3360. /**
  3361. * Internal only - manager for action
  3362. * @hidden
  3363. */
  3364. _actionManager: ActionManager;
  3365. /**
  3366. * Internal only
  3367. * @hidden
  3368. */
  3369. private _target;
  3370. /**
  3371. * Creates a new StateCondition
  3372. * @param actionManager manager for the action the condition applies to
  3373. * @param target of the condition
  3374. * @param value to compare with target state
  3375. */
  3376. constructor(actionManager: ActionManager, target: any,
  3377. /** Value to compare with target state */
  3378. value: string);
  3379. /**
  3380. * Gets a boolean indicating if the current condition is met
  3381. * @returns the validity of the state
  3382. */
  3383. isValid(): boolean;
  3384. /**
  3385. * Serialize the StateCondition into a JSON compatible object
  3386. * @returns serialization object
  3387. */
  3388. serialize(): any;
  3389. }
  3390. }
  3391. declare module BABYLON {
  3392. /**
  3393. * This defines an action responsible to toggle a boolean once triggered.
  3394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3395. */
  3396. class SwitchBooleanAction extends Action {
  3397. /**
  3398. * The path to the boolean property in the target object
  3399. */
  3400. propertyPath: string;
  3401. private _target;
  3402. private _effectiveTarget;
  3403. private _property;
  3404. /**
  3405. * Instantiate the action
  3406. * @param triggerOptions defines the trigger options
  3407. * @param target defines the object containing the boolean
  3408. * @param propertyPath defines the path to the boolean property in the target object
  3409. * @param condition defines the trigger related conditions
  3410. */
  3411. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3412. /** @hidden */
  3413. _prepare(): void;
  3414. /**
  3415. * Execute the action toggle the boolean value.
  3416. */
  3417. execute(): void;
  3418. /**
  3419. * Serializes the actions and its related information.
  3420. * @param parent defines the object to serialize in
  3421. * @returns the serialized object
  3422. */
  3423. serialize(parent: any): any;
  3424. }
  3425. /**
  3426. * This defines an action responsible to set a the state field of the target
  3427. * to a desired value once triggered.
  3428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3429. */
  3430. class SetStateAction extends Action {
  3431. /**
  3432. * The value to store in the state field.
  3433. */
  3434. value: string;
  3435. private _target;
  3436. /**
  3437. * Instantiate the action
  3438. * @param triggerOptions defines the trigger options
  3439. * @param target defines the object containing the state property
  3440. * @param value defines the value to store in the state field
  3441. * @param condition defines the trigger related conditions
  3442. */
  3443. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3444. /**
  3445. * Execute the action and store the value on the target state property.
  3446. */
  3447. execute(): void;
  3448. /**
  3449. * Serializes the actions and its related information.
  3450. * @param parent defines the object to serialize in
  3451. * @returns the serialized object
  3452. */
  3453. serialize(parent: any): any;
  3454. }
  3455. /**
  3456. * This defines an action responsible to set a property of the target
  3457. * to a desired value once triggered.
  3458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3459. */
  3460. class SetValueAction extends Action {
  3461. /**
  3462. * The path of the property to set in the target.
  3463. */
  3464. propertyPath: string;
  3465. /**
  3466. * The value to set in the property
  3467. */
  3468. value: any;
  3469. private _target;
  3470. private _effectiveTarget;
  3471. private _property;
  3472. /**
  3473. * Instantiate the action
  3474. * @param triggerOptions defines the trigger options
  3475. * @param target defines the object containing the property
  3476. * @param propertyPath defines the path of the property to set in the target
  3477. * @param value defines the value to set in the property
  3478. * @param condition defines the trigger related conditions
  3479. */
  3480. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3481. /** @hidden */
  3482. _prepare(): void;
  3483. /**
  3484. * Execute the action and set the targetted property to the desired value.
  3485. */
  3486. execute(): void;
  3487. /**
  3488. * Serializes the actions and its related information.
  3489. * @param parent defines the object to serialize in
  3490. * @returns the serialized object
  3491. */
  3492. serialize(parent: any): any;
  3493. }
  3494. /**
  3495. * This defines an action responsible to increment the target value
  3496. * to a desired value once triggered.
  3497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3498. */
  3499. class IncrementValueAction extends Action {
  3500. /**
  3501. * The path of the property to increment in the target.
  3502. */
  3503. propertyPath: string;
  3504. /**
  3505. * The value we should increment the property by.
  3506. */
  3507. value: any;
  3508. private _target;
  3509. private _effectiveTarget;
  3510. private _property;
  3511. /**
  3512. * Instantiate the action
  3513. * @param triggerOptions defines the trigger options
  3514. * @param target defines the object containing the property
  3515. * @param propertyPath defines the path of the property to increment in the target
  3516. * @param value defines the value value we should increment the property by
  3517. * @param condition defines the trigger related conditions
  3518. */
  3519. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3520. /** @hidden */
  3521. _prepare(): void;
  3522. /**
  3523. * Execute the action and increment the target of the value amount.
  3524. */
  3525. execute(): void;
  3526. /**
  3527. * Serializes the actions and its related information.
  3528. * @param parent defines the object to serialize in
  3529. * @returns the serialized object
  3530. */
  3531. serialize(parent: any): any;
  3532. }
  3533. /**
  3534. * This defines an action responsible to start an animation once triggered.
  3535. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3536. */
  3537. class PlayAnimationAction extends Action {
  3538. /**
  3539. * Where the animation should start (animation frame)
  3540. */
  3541. from: number;
  3542. /**
  3543. * Where the animation should stop (animation frame)
  3544. */
  3545. to: number;
  3546. /**
  3547. * Define if the animation should loop or stop after the first play.
  3548. */
  3549. loop?: boolean;
  3550. private _target;
  3551. /**
  3552. * Instantiate the action
  3553. * @param triggerOptions defines the trigger options
  3554. * @param target defines the target animation or animation name
  3555. * @param from defines from where the animation should start (animation frame)
  3556. * @param end defines where the animation should stop (animation frame)
  3557. * @param loop defines if the animation should loop or stop after the first play
  3558. * @param condition defines the trigger related conditions
  3559. */
  3560. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3561. /** @hidden */
  3562. _prepare(): void;
  3563. /**
  3564. * Execute the action and play the animation.
  3565. */
  3566. execute(): void;
  3567. /**
  3568. * Serializes the actions and its related information.
  3569. * @param parent defines the object to serialize in
  3570. * @returns the serialized object
  3571. */
  3572. serialize(parent: any): any;
  3573. }
  3574. /**
  3575. * This defines an action responsible to stop an animation once triggered.
  3576. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3577. */
  3578. class StopAnimationAction extends Action {
  3579. private _target;
  3580. /**
  3581. * Instantiate the action
  3582. * @param triggerOptions defines the trigger options
  3583. * @param target defines the target animation or animation name
  3584. * @param condition defines the trigger related conditions
  3585. */
  3586. constructor(triggerOptions: any, target: any, condition?: Condition);
  3587. /** @hidden */
  3588. _prepare(): void;
  3589. /**
  3590. * Execute the action and stop the animation.
  3591. */
  3592. execute(): void;
  3593. /**
  3594. * Serializes the actions and its related information.
  3595. * @param parent defines the object to serialize in
  3596. * @returns the serialized object
  3597. */
  3598. serialize(parent: any): any;
  3599. }
  3600. /**
  3601. * This defines an action responsible that does nothing once triggered.
  3602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3603. */
  3604. class DoNothingAction extends Action {
  3605. /**
  3606. * Instantiate the action
  3607. * @param triggerOptions defines the trigger options
  3608. * @param condition defines the trigger related conditions
  3609. */
  3610. constructor(triggerOptions?: any, condition?: Condition);
  3611. /**
  3612. * Execute the action and do nothing.
  3613. */
  3614. execute(): void;
  3615. /**
  3616. * Serializes the actions and its related information.
  3617. * @param parent defines the object to serialize in
  3618. * @returns the serialized object
  3619. */
  3620. serialize(parent: any): any;
  3621. }
  3622. /**
  3623. * This defines an action responsible to trigger several actions once triggered.
  3624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3625. */
  3626. class CombineAction extends Action {
  3627. /**
  3628. * The list of aggregated animations to run.
  3629. */
  3630. children: Action[];
  3631. /**
  3632. * Instantiate the action
  3633. * @param triggerOptions defines the trigger options
  3634. * @param children defines the list of aggregated animations to run
  3635. * @param condition defines the trigger related conditions
  3636. */
  3637. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3638. /** @hidden */
  3639. _prepare(): void;
  3640. /**
  3641. * Execute the action and executes all the aggregated actions.
  3642. */
  3643. execute(evt: ActionEvent): void;
  3644. /**
  3645. * Serializes the actions and its related information.
  3646. * @param parent defines the object to serialize in
  3647. * @returns the serialized object
  3648. */
  3649. serialize(parent: any): any;
  3650. }
  3651. /**
  3652. * This defines an action responsible to run code (external event) once triggered.
  3653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3654. */
  3655. class ExecuteCodeAction extends Action {
  3656. /**
  3657. * The callback function to run.
  3658. */
  3659. func: (evt: ActionEvent) => void;
  3660. /**
  3661. * Instantiate the action
  3662. * @param triggerOptions defines the trigger options
  3663. * @param func defines the callback function to run
  3664. * @param condition defines the trigger related conditions
  3665. */
  3666. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3667. /**
  3668. * Execute the action and run the attached code.
  3669. */
  3670. execute(evt: ActionEvent): void;
  3671. }
  3672. /**
  3673. * This defines an action responsible to set the parent property of the target once triggered.
  3674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3675. */
  3676. class SetParentAction extends Action {
  3677. private _parent;
  3678. private _target;
  3679. /**
  3680. * Instantiate the action
  3681. * @param triggerOptions defines the trigger options
  3682. * @param target defines the target containing the parent property
  3683. * @param parent defines from where the animation should start (animation frame)
  3684. * @param condition defines the trigger related conditions
  3685. */
  3686. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3687. /** @hidden */
  3688. _prepare(): void;
  3689. /**
  3690. * Execute the action and set the parent property.
  3691. */
  3692. execute(): void;
  3693. /**
  3694. * Serializes the actions and its related information.
  3695. * @param parent defines the object to serialize in
  3696. * @returns the serialized object
  3697. */
  3698. serialize(parent: any): any;
  3699. }
  3700. }
  3701. declare module BABYLON {
  3702. /**
  3703. * This defines an action helpful to play a defined sound on a triggered action.
  3704. */
  3705. class PlaySoundAction extends Action {
  3706. private _sound;
  3707. /**
  3708. * Instantiate the action
  3709. * @param triggerOptions defines the trigger options
  3710. * @param sound defines the sound to play
  3711. * @param condition defines the trigger related conditions
  3712. */
  3713. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3714. /** @hidden */
  3715. _prepare(): void;
  3716. /**
  3717. * Execute the action and play the sound.
  3718. */
  3719. execute(): void;
  3720. /**
  3721. * Serializes the actions and its related information.
  3722. * @param parent defines the object to serialize in
  3723. * @returns the serialized object
  3724. */
  3725. serialize(parent: any): any;
  3726. }
  3727. /**
  3728. * This defines an action helpful to stop a defined sound on a triggered action.
  3729. */
  3730. class StopSoundAction extends Action {
  3731. private _sound;
  3732. /**
  3733. * Instantiate the action
  3734. * @param triggerOptions defines the trigger options
  3735. * @param sound defines the sound to stop
  3736. * @param condition defines the trigger related conditions
  3737. */
  3738. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3739. /** @hidden */
  3740. _prepare(): void;
  3741. /**
  3742. * Execute the action and stop the sound.
  3743. */
  3744. execute(): void;
  3745. /**
  3746. * Serializes the actions and its related information.
  3747. * @param parent defines the object to serialize in
  3748. * @returns the serialized object
  3749. */
  3750. serialize(parent: any): any;
  3751. }
  3752. }
  3753. declare module BABYLON {
  3754. /**
  3755. * This defines an action responsible to change the value of a property
  3756. * by interpolating between its current value and the newly set one once triggered.
  3757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3758. */
  3759. class InterpolateValueAction extends Action {
  3760. /**
  3761. * Defines the path of the property where the value should be interpolated
  3762. */
  3763. propertyPath: string;
  3764. /**
  3765. * Defines the target value at the end of the interpolation.
  3766. */
  3767. value: any;
  3768. /**
  3769. * Defines the time it will take for the property to interpolate to the value.
  3770. */
  3771. duration: number;
  3772. /**
  3773. * Defines if the other scene animations should be stopped when the action has been triggered
  3774. */
  3775. stopOtherAnimations?: boolean;
  3776. /**
  3777. * Defines a callback raised once the interpolation animation has been done.
  3778. */
  3779. onInterpolationDone?: () => void;
  3780. /**
  3781. * Observable triggered once the interpolation animation has been done.
  3782. */
  3783. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3784. private _target;
  3785. private _effectiveTarget;
  3786. private _property;
  3787. /**
  3788. * Instantiate the action
  3789. * @param triggerOptions defines the trigger options
  3790. * @param target defines the object containing the value to interpolate
  3791. * @param propertyPath defines the path to the property in the target object
  3792. * @param value defines the target value at the end of the interpolation
  3793. * @param duration deines the time it will take for the property to interpolate to the value.
  3794. * @param condition defines the trigger related conditions
  3795. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3796. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3797. */
  3798. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3799. /** @hidden */
  3800. _prepare(): void;
  3801. /**
  3802. * Execute the action starts the value interpolation.
  3803. */
  3804. execute(): void;
  3805. /**
  3806. * Serializes the actions and its related information.
  3807. * @param parent defines the object to serialize in
  3808. * @returns the serialized object
  3809. */
  3810. serialize(parent: any): any;
  3811. }
  3812. }
  3813. declare module BABYLON {
  3814. /**
  3815. * Class used to store an actual running animation
  3816. */
  3817. class Animatable {
  3818. /** defines the target object */
  3819. target: any;
  3820. /** defines the starting frame number (default is 0) */
  3821. fromFrame: number;
  3822. /** defines the ending frame number (default is 100) */
  3823. toFrame: number;
  3824. /** defines if the animation must loop (default is false) */
  3825. loopAnimation: boolean;
  3826. /** defines a callback to call when animation ends if it is not looping */
  3827. onAnimationEnd?: (() => void) | null | undefined;
  3828. private _localDelayOffset;
  3829. private _pausedDelay;
  3830. private _runtimeAnimations;
  3831. private _paused;
  3832. private _scene;
  3833. private _speedRatio;
  3834. private _weight;
  3835. private _syncRoot;
  3836. /**
  3837. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3838. * This will only apply for non looping animation (default is true)
  3839. */
  3840. disposeOnEnd: boolean;
  3841. /**
  3842. * Gets a boolean indicating if the animation has started
  3843. */
  3844. animationStarted: boolean;
  3845. /**
  3846. * Observer raised when the animation ends
  3847. */
  3848. onAnimationEndObservable: Observable<Animatable>;
  3849. /**
  3850. * Gets the root Animatable used to synchronize and normalize animations
  3851. */
  3852. readonly syncRoot: Animatable;
  3853. /**
  3854. * Gets the current frame of the first RuntimeAnimation
  3855. * Used to synchronize Animatables
  3856. */
  3857. readonly masterFrame: number;
  3858. /**
  3859. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3860. */
  3861. weight: number;
  3862. /**
  3863. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3864. */
  3865. speedRatio: number;
  3866. /**
  3867. * Creates a new Animatable
  3868. * @param scene defines the hosting scene
  3869. * @param target defines the target object
  3870. * @param fromFrame defines the starting frame number (default is 0)
  3871. * @param toFrame defines the ending frame number (default is 100)
  3872. * @param loopAnimation defines if the animation must loop (default is false)
  3873. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3874. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3875. * @param animations defines a group of animation to add to the new Animatable
  3876. */
  3877. constructor(scene: Scene,
  3878. /** defines the target object */
  3879. target: any,
  3880. /** defines the starting frame number (default is 0) */
  3881. fromFrame?: number,
  3882. /** defines the ending frame number (default is 100) */
  3883. toFrame?: number,
  3884. /** defines if the animation must loop (default is false) */
  3885. loopAnimation?: boolean, speedRatio?: number,
  3886. /** defines a callback to call when animation ends if it is not looping */
  3887. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3888. /**
  3889. * Synchronize and normalize current Animatable with a source Animatable
  3890. * This is useful when using animation weights and when animations are not of the same length
  3891. * @param root defines the root Animatable to synchronize with
  3892. * @returns the current Animatable
  3893. */
  3894. syncWith(root: Animatable): Animatable;
  3895. /**
  3896. * Gets the list of runtime animations
  3897. * @returns an array of RuntimeAnimation
  3898. */
  3899. getAnimations(): RuntimeAnimation[];
  3900. /**
  3901. * Adds more animations to the current animatable
  3902. * @param target defines the target of the animations
  3903. * @param animations defines the new animations to add
  3904. */
  3905. appendAnimations(target: any, animations: Animation[]): void;
  3906. /**
  3907. * Gets the source animation for a specific property
  3908. * @param property defines the propertyu to look for
  3909. * @returns null or the source animation for the given property
  3910. */
  3911. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3912. /**
  3913. * Gets the runtime animation for a specific property
  3914. * @param property defines the propertyu to look for
  3915. * @returns null or the runtime animation for the given property
  3916. */
  3917. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3918. /**
  3919. * Resets the animatable to its original state
  3920. */
  3921. reset(): void;
  3922. /**
  3923. * Allows the animatable to blend with current running animations
  3924. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3925. * @param blendingSpeed defines the blending speed to use
  3926. */
  3927. enableBlending(blendingSpeed: number): void;
  3928. /**
  3929. * Disable animation blending
  3930. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3931. */
  3932. disableBlending(): void;
  3933. /**
  3934. * Jump directly to a given frame
  3935. * @param frame defines the frame to jump to
  3936. */
  3937. goToFrame(frame: number): void;
  3938. /**
  3939. * Pause the animation
  3940. */
  3941. pause(): void;
  3942. /**
  3943. * Restart the animation
  3944. */
  3945. restart(): void;
  3946. private _raiseOnAnimationEnd;
  3947. /**
  3948. * Stop and delete the current animation
  3949. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3950. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  3951. */
  3952. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3953. /**
  3954. * Wait asynchronously for the animation to end
  3955. * @returns a promise which will be fullfilled when the animation ends
  3956. */
  3957. waitAsync(): Promise<Animatable>;
  3958. /** @hidden */
  3959. _animate(delay: number): boolean;
  3960. }
  3961. }
  3962. declare module BABYLON {
  3963. /**
  3964. * Represents the range of an animation
  3965. */
  3966. class AnimationRange {
  3967. /**The name of the animation range**/
  3968. name: string;
  3969. /**The starting frame of the animation */
  3970. from: number;
  3971. /**The ending frame of the animation*/
  3972. to: number;
  3973. /**
  3974. * Initializes the range of an animation
  3975. * @param name The name of the animation range
  3976. * @param from The starting frame of the animation
  3977. * @param to The ending frame of the animation
  3978. */
  3979. constructor(
  3980. /**The name of the animation range**/
  3981. name: string,
  3982. /**The starting frame of the animation */
  3983. from: number,
  3984. /**The ending frame of the animation*/
  3985. to: number);
  3986. /**
  3987. * Makes a copy of the animation range
  3988. * @returns A copy of the animation range
  3989. */
  3990. clone(): AnimationRange;
  3991. }
  3992. /**
  3993. * Composed of a frame, and an action function
  3994. */
  3995. class AnimationEvent {
  3996. /** The frame for which the event is triggered **/
  3997. frame: number;
  3998. /** The event to perform when triggered **/
  3999. action: (currentFrame: number) => void;
  4000. /** Specifies if the event should be triggered only once**/
  4001. onlyOnce?: boolean | undefined;
  4002. /**
  4003. * Specifies if the animation event is done
  4004. */
  4005. isDone: boolean;
  4006. /**
  4007. * Initializes the animation event
  4008. * @param frame The frame for which the event is triggered
  4009. * @param action The event to perform when triggered
  4010. * @param onlyOnce Specifies if the event should be triggered only once
  4011. */
  4012. constructor(
  4013. /** The frame for which the event is triggered **/
  4014. frame: number,
  4015. /** The event to perform when triggered **/
  4016. action: (currentFrame: number) => void,
  4017. /** Specifies if the event should be triggered only once**/
  4018. onlyOnce?: boolean | undefined);
  4019. /** @hidden */
  4020. _clone(): AnimationEvent;
  4021. }
  4022. /**
  4023. * A cursor which tracks a point on a path
  4024. */
  4025. class PathCursor {
  4026. private path;
  4027. /**
  4028. * Stores path cursor callbacks for when an onchange event is triggered
  4029. */
  4030. private _onchange;
  4031. /**
  4032. * The value of the path cursor
  4033. */
  4034. value: number;
  4035. /**
  4036. * The animation array of the path cursor
  4037. */
  4038. animations: Animation[];
  4039. /**
  4040. * Initializes the path cursor
  4041. * @param path The path to track
  4042. */
  4043. constructor(path: Path2);
  4044. /**
  4045. * Gets the cursor point on the path
  4046. * @returns A point on the path cursor at the cursor location
  4047. */
  4048. getPoint(): Vector3;
  4049. /**
  4050. * Moves the cursor ahead by the step amount
  4051. * @param step The amount to move the cursor forward
  4052. * @returns This path cursor
  4053. */
  4054. moveAhead(step?: number): PathCursor;
  4055. /**
  4056. * Moves the cursor behind by the step amount
  4057. * @param step The amount to move the cursor back
  4058. * @returns This path cursor
  4059. */
  4060. moveBack(step?: number): PathCursor;
  4061. /**
  4062. * Moves the cursor by the step amount
  4063. * If the step amount is greater than one, an exception is thrown
  4064. * @param step The amount to move the cursor
  4065. * @returns This path cursor
  4066. */
  4067. move(step: number): PathCursor;
  4068. /**
  4069. * Ensures that the value is limited between zero and one
  4070. * @returns This path cursor
  4071. */
  4072. private ensureLimits;
  4073. /**
  4074. * Runs onchange callbacks on change (used by the animation engine)
  4075. * @returns This path cursor
  4076. */
  4077. private raiseOnChange;
  4078. /**
  4079. * Executes a function on change
  4080. * @param f A path cursor onchange callback
  4081. * @returns This path cursor
  4082. */
  4083. onchange(f: (cursor: PathCursor) => void): PathCursor;
  4084. }
  4085. /**
  4086. * Defines an interface which represents an animation key frame
  4087. */
  4088. interface IAnimationKey {
  4089. /**
  4090. * Frame of the key frame
  4091. */
  4092. frame: number;
  4093. /**
  4094. * Value at the specifies key frame
  4095. */
  4096. value: any;
  4097. /**
  4098. * The input tangent for the cubic hermite spline
  4099. */
  4100. inTangent?: any;
  4101. /**
  4102. * The output tangent for the cubic hermite spline
  4103. */
  4104. outTangent?: any;
  4105. /**
  4106. * The animation interpolation type
  4107. */
  4108. interpolation?: AnimationKeyInterpolation;
  4109. }
  4110. /**
  4111. * Enum for the animation key frame interpolation type
  4112. */
  4113. enum AnimationKeyInterpolation {
  4114. /**
  4115. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4116. */
  4117. STEP = 1
  4118. }
  4119. /**
  4120. * Class used to store any kind of animation
  4121. */
  4122. class Animation {
  4123. /**Name of the animation */
  4124. name: string;
  4125. /**Property to animate */
  4126. targetProperty: string;
  4127. /**The frames per second of the animation */
  4128. framePerSecond: number;
  4129. /**The data type of the animation */
  4130. dataType: number;
  4131. /**The loop mode of the animation */
  4132. loopMode?: number | undefined;
  4133. /**Specifies if blending should be enabled */
  4134. enableBlending?: boolean | undefined;
  4135. /**
  4136. * Use matrix interpolation instead of using direct key value when animating matrices
  4137. */
  4138. static AllowMatricesInterpolation: boolean;
  4139. /**
  4140. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4141. */
  4142. static AllowMatrixDecomposeForInterpolation: boolean;
  4143. /**
  4144. * Stores the key frames of the animation
  4145. */
  4146. private _keys;
  4147. /**
  4148. * Stores the easing function of the animation
  4149. */
  4150. private _easingFunction;
  4151. /**
  4152. * @hidden Internal use only
  4153. */
  4154. _runtimeAnimations: RuntimeAnimation[];
  4155. /**
  4156. * The set of event that will be linked to this animation
  4157. */
  4158. private _events;
  4159. /**
  4160. * Stores an array of target property paths
  4161. */
  4162. targetPropertyPath: string[];
  4163. /**
  4164. * Stores the blending speed of the animation
  4165. */
  4166. blendingSpeed: number;
  4167. /**
  4168. * Stores the animation ranges for the animation
  4169. */
  4170. private _ranges;
  4171. /**
  4172. * @hidden Internal use
  4173. */
  4174. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4175. /**
  4176. * Sets up an animation
  4177. * @param property The property to animate
  4178. * @param animationType The animation type to apply
  4179. * @param framePerSecond The frames per second of the animation
  4180. * @param easingFunction The easing function used in the animation
  4181. * @returns The created animation
  4182. */
  4183. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4184. /**
  4185. * Create and start an animation on a node
  4186. * @param name defines the name of the global animation that will be run on all nodes
  4187. * @param node defines the root node where the animation will take place
  4188. * @param targetProperty defines property to animate
  4189. * @param framePerSecond defines the number of frame per second yo use
  4190. * @param totalFrame defines the number of frames in total
  4191. * @param from defines the initial value
  4192. * @param to defines the final value
  4193. * @param loopMode defines which loop mode you want to use (off by default)
  4194. * @param easingFunction defines the easing function to use (linear by default)
  4195. * @param onAnimationEnd defines the callback to call when animation end
  4196. * @returns the animatable created for this animation
  4197. */
  4198. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4199. /**
  4200. * Create and start an animation on a node and its descendants
  4201. * @param name defines the name of the global animation that will be run on all nodes
  4202. * @param node defines the root node where the animation will take place
  4203. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  4204. * @param targetProperty defines property to animate
  4205. * @param framePerSecond defines the number of frame per second to use
  4206. * @param totalFrame defines the number of frames in total
  4207. * @param from defines the initial value
  4208. * @param to defines the final value
  4209. * @param loopMode defines which loop mode you want to use (off by default)
  4210. * @param easingFunction defines the easing function to use (linear by default)
  4211. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4212. * @returns the list of animatables created for all nodes
  4213. * @example https://www.babylonjs-playground.com/#MH0VLI
  4214. */
  4215. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  4216. /**
  4217. * Creates a new animation, merges it with the existing animations and starts it
  4218. * @param name Name of the animation
  4219. * @param node Node which contains the scene that begins the animations
  4220. * @param targetProperty Specifies which property to animate
  4221. * @param framePerSecond The frames per second of the animation
  4222. * @param totalFrame The total number of frames
  4223. * @param from The frame at the beginning of the animation
  4224. * @param to The frame at the end of the animation
  4225. * @param loopMode Specifies the loop mode of the animation
  4226. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4227. * @param onAnimationEnd Callback to run once the animation is complete
  4228. * @returns Nullable animation
  4229. */
  4230. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4231. /**
  4232. * Transition property of an host to the target Value
  4233. * @param property The property to transition
  4234. * @param targetValue The target Value of the property
  4235. * @param host The object where the property to animate belongs
  4236. * @param scene Scene used to run the animation
  4237. * @param frameRate Framerate (in frame/s) to use
  4238. * @param transition The transition type we want to use
  4239. * @param duration The duration of the animation, in milliseconds
  4240. * @param onAnimationEnd Callback trigger at the end of the animation
  4241. * @returns Nullable animation
  4242. */
  4243. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4244. /**
  4245. * Return the array of runtime animations currently using this animation
  4246. */
  4247. readonly runtimeAnimations: RuntimeAnimation[];
  4248. /**
  4249. * Specifies if any of the runtime animations are currently running
  4250. */
  4251. readonly hasRunningRuntimeAnimations: boolean;
  4252. /**
  4253. * Initializes the animation
  4254. * @param name Name of the animation
  4255. * @param targetProperty Property to animate
  4256. * @param framePerSecond The frames per second of the animation
  4257. * @param dataType The data type of the animation
  4258. * @param loopMode The loop mode of the animation
  4259. * @param enableBlendings Specifies if blending should be enabled
  4260. */
  4261. constructor(
  4262. /**Name of the animation */
  4263. name: string,
  4264. /**Property to animate */
  4265. targetProperty: string,
  4266. /**The frames per second of the animation */
  4267. framePerSecond: number,
  4268. /**The data type of the animation */
  4269. dataType: number,
  4270. /**The loop mode of the animation */
  4271. loopMode?: number | undefined,
  4272. /**Specifies if blending should be enabled */
  4273. enableBlending?: boolean | undefined);
  4274. /**
  4275. * Converts the animation to a string
  4276. * @param fullDetails support for multiple levels of logging within scene loading
  4277. * @returns String form of the animation
  4278. */
  4279. toString(fullDetails?: boolean): string;
  4280. /**
  4281. * Add an event to this animation
  4282. * @param event Event to add
  4283. */
  4284. addEvent(event: AnimationEvent): void;
  4285. /**
  4286. * Remove all events found at the given frame
  4287. * @param frame The frame to remove events from
  4288. */
  4289. removeEvents(frame: number): void;
  4290. /**
  4291. * Retrieves all the events from the animation
  4292. * @returns Events from the animation
  4293. */
  4294. getEvents(): AnimationEvent[];
  4295. /**
  4296. * Creates an animation range
  4297. * @param name Name of the animation range
  4298. * @param from Starting frame of the animation range
  4299. * @param to Ending frame of the animation
  4300. */
  4301. createRange(name: string, from: number, to: number): void;
  4302. /**
  4303. * Deletes an animation range by name
  4304. * @param name Name of the animation range to delete
  4305. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4306. */
  4307. deleteRange(name: string, deleteFrames?: boolean): void;
  4308. /**
  4309. * Gets the animation range by name, or null if not defined
  4310. * @param name Name of the animation range
  4311. * @returns Nullable animation range
  4312. */
  4313. getRange(name: string): Nullable<AnimationRange>;
  4314. /**
  4315. * Gets the key frames from the animation
  4316. * @returns The key frames of the animation
  4317. */
  4318. getKeys(): Array<IAnimationKey>;
  4319. /**
  4320. * Gets the highest frame rate of the animation
  4321. * @returns Highest frame rate of the animation
  4322. */
  4323. getHighestFrame(): number;
  4324. /**
  4325. * Gets the easing function of the animation
  4326. * @returns Easing function of the animation
  4327. */
  4328. getEasingFunction(): IEasingFunction;
  4329. /**
  4330. * Sets the easing function of the animation
  4331. * @param easingFunction A custom mathematical formula for animation
  4332. */
  4333. setEasingFunction(easingFunction: EasingFunction): void;
  4334. /**
  4335. * Interpolates a scalar linearly
  4336. * @param startValue Start value of the animation curve
  4337. * @param endValue End value of the animation curve
  4338. * @param gradient Scalar amount to interpolate
  4339. * @returns Interpolated scalar value
  4340. */
  4341. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4342. /**
  4343. * Interpolates a scalar cubically
  4344. * @param startValue Start value of the animation curve
  4345. * @param outTangent End tangent of the animation
  4346. * @param endValue End value of the animation curve
  4347. * @param inTangent Start tangent of the animation curve
  4348. * @param gradient Scalar amount to interpolate
  4349. * @returns Interpolated scalar value
  4350. */
  4351. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4352. /**
  4353. * Interpolates a quaternion using a spherical linear interpolation
  4354. * @param startValue Start value of the animation curve
  4355. * @param endValue End value of the animation curve
  4356. * @param gradient Scalar amount to interpolate
  4357. * @returns Interpolated quaternion value
  4358. */
  4359. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4360. /**
  4361. * Interpolates a quaternion cubically
  4362. * @param startValue Start value of the animation curve
  4363. * @param outTangent End tangent of the animation curve
  4364. * @param endValue End value of the animation curve
  4365. * @param inTangent Start tangent of the animation curve
  4366. * @param gradient Scalar amount to interpolate
  4367. * @returns Interpolated quaternion value
  4368. */
  4369. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4370. /**
  4371. * Interpolates a Vector3 linearl
  4372. * @param startValue Start value of the animation curve
  4373. * @param endValue End value of the animation curve
  4374. * @param gradient Scalar amount to interpolate
  4375. * @returns Interpolated scalar value
  4376. */
  4377. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4378. /**
  4379. * Interpolates a Vector3 cubically
  4380. * @param startValue Start value of the animation curve
  4381. * @param outTangent End tangent of the animation
  4382. * @param endValue End value of the animation curve
  4383. * @param inTangent Start tangent of the animation curve
  4384. * @param gradient Scalar amount to interpolate
  4385. * @returns InterpolatedVector3 value
  4386. */
  4387. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4388. /**
  4389. * Interpolates a Vector2 linearly
  4390. * @param startValue Start value of the animation curve
  4391. * @param endValue End value of the animation curve
  4392. * @param gradient Scalar amount to interpolate
  4393. * @returns Interpolated Vector2 value
  4394. */
  4395. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4396. /**
  4397. * Interpolates a Vector2 cubically
  4398. * @param startValue Start value of the animation curve
  4399. * @param outTangent End tangent of the animation
  4400. * @param endValue End value of the animation curve
  4401. * @param inTangent Start tangent of the animation curve
  4402. * @param gradient Scalar amount to interpolate
  4403. * @returns Interpolated Vector2 value
  4404. */
  4405. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4406. /**
  4407. * Interpolates a size linearly
  4408. * @param startValue Start value of the animation curve
  4409. * @param endValue End value of the animation curve
  4410. * @param gradient Scalar amount to interpolate
  4411. * @returns Interpolated Size value
  4412. */
  4413. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4414. /**
  4415. * Interpolates a Color3 linearly
  4416. * @param startValue Start value of the animation curve
  4417. * @param endValue End value of the animation curve
  4418. * @param gradient Scalar amount to interpolate
  4419. * @returns Interpolated Color3 value
  4420. */
  4421. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4422. /**
  4423. * @hidden Internal use only
  4424. */
  4425. _getKeyValue(value: any): any;
  4426. /**
  4427. * @hidden Internal use only
  4428. */
  4429. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4430. /**
  4431. * Defines the function to use to interpolate matrices
  4432. * @param startValue defines the start matrix
  4433. * @param endValue defines the end matrix
  4434. * @param gradient defines the gradient between both matrices
  4435. * @param result defines an optional target matrix where to store the interpolation
  4436. * @returns the interpolated matrix
  4437. */
  4438. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4439. /**
  4440. * Makes a copy of the animation
  4441. * @returns Cloned animation
  4442. */
  4443. clone(): Animation;
  4444. /**
  4445. * Sets the key frames of the animation
  4446. * @param values The animation key frames to set
  4447. */
  4448. setKeys(values: Array<IAnimationKey>): void;
  4449. /**
  4450. * Serializes the animation to an object
  4451. * @returns Serialized object
  4452. */
  4453. serialize(): any;
  4454. /**
  4455. * Float animation type
  4456. */
  4457. private static _ANIMATIONTYPE_FLOAT;
  4458. /**
  4459. * Vector3 animation type
  4460. */
  4461. private static _ANIMATIONTYPE_VECTOR3;
  4462. /**
  4463. * Quaternion animation type
  4464. */
  4465. private static _ANIMATIONTYPE_QUATERNION;
  4466. /**
  4467. * Matrix animation type
  4468. */
  4469. private static _ANIMATIONTYPE_MATRIX;
  4470. /**
  4471. * Color3 animation type
  4472. */
  4473. private static _ANIMATIONTYPE_COLOR3;
  4474. /**
  4475. * Vector2 animation type
  4476. */
  4477. private static _ANIMATIONTYPE_VECTOR2;
  4478. /**
  4479. * Size animation type
  4480. */
  4481. private static _ANIMATIONTYPE_SIZE;
  4482. /**
  4483. * Relative Loop Mode
  4484. */
  4485. private static _ANIMATIONLOOPMODE_RELATIVE;
  4486. /**
  4487. * Cycle Loop Mode
  4488. */
  4489. private static _ANIMATIONLOOPMODE_CYCLE;
  4490. /**
  4491. * Constant Loop Mode
  4492. */
  4493. private static _ANIMATIONLOOPMODE_CONSTANT;
  4494. /**
  4495. * Get the float animation type
  4496. */
  4497. static readonly ANIMATIONTYPE_FLOAT: number;
  4498. /**
  4499. * Get the Vector3 animation type
  4500. */
  4501. static readonly ANIMATIONTYPE_VECTOR3: number;
  4502. /**
  4503. * Get the Vector2 animation type
  4504. */
  4505. static readonly ANIMATIONTYPE_VECTOR2: number;
  4506. /**
  4507. * Get the Size animation type
  4508. */
  4509. static readonly ANIMATIONTYPE_SIZE: number;
  4510. /**
  4511. * Get the Quaternion animation type
  4512. */
  4513. static readonly ANIMATIONTYPE_QUATERNION: number;
  4514. /**
  4515. * Get the Matrix animation type
  4516. */
  4517. static readonly ANIMATIONTYPE_MATRIX: number;
  4518. /**
  4519. * Get the Color3 animation type
  4520. */
  4521. static readonly ANIMATIONTYPE_COLOR3: number;
  4522. /**
  4523. * Get the Relative Loop Mode
  4524. */
  4525. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4526. /**
  4527. * Get the Cycle Loop Mode
  4528. */
  4529. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4530. /**
  4531. * Get the Constant Loop Mode
  4532. */
  4533. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4534. /** @hidden */
  4535. static _UniversalLerp(left: any, right: any, amount: number): any;
  4536. /**
  4537. * Parses an animation object and creates an animation
  4538. * @param parsedAnimation Parsed animation object
  4539. * @returns Animation object
  4540. */
  4541. static Parse(parsedAnimation: any): Animation;
  4542. /**
  4543. * Appends the serialized animations from the source animations
  4544. * @param source Source containing the animations
  4545. * @param destination Target to store the animations
  4546. */
  4547. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4548. }
  4549. }
  4550. declare module BABYLON {
  4551. /**
  4552. * This class defines the direct association between an animation and a target
  4553. */
  4554. class TargetedAnimation {
  4555. /**
  4556. * Animation to perform
  4557. */
  4558. animation: Animation;
  4559. /**
  4560. * Target to animate
  4561. */
  4562. target: any;
  4563. }
  4564. /**
  4565. * Use this class to create coordinated animations on multiple targets
  4566. */
  4567. class AnimationGroup implements IDisposable {
  4568. /** The name of the animation group */
  4569. name: string;
  4570. private _scene;
  4571. private _targetedAnimations;
  4572. private _animatables;
  4573. private _from;
  4574. private _to;
  4575. private _isStarted;
  4576. private _isPaused;
  4577. private _speedRatio;
  4578. /**
  4579. * Gets or sets the unique id of the node
  4580. */
  4581. uniqueId: number;
  4582. /**
  4583. * This observable will notify when one animation have ended.
  4584. */
  4585. onAnimationEndObservable: Observable<TargetedAnimation>;
  4586. /**
  4587. * This observable will notify when all animations have ended.
  4588. */
  4589. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4590. /**
  4591. * This observable will notify when all animations have paused.
  4592. */
  4593. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4594. /**
  4595. * This observable will notify when all animations are playing.
  4596. */
  4597. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  4598. /**
  4599. * Gets the first frame
  4600. */
  4601. readonly from: number;
  4602. /**
  4603. * Gets the last frame
  4604. */
  4605. readonly to: number;
  4606. /**
  4607. * Define if the animations are started
  4608. */
  4609. readonly isStarted: boolean;
  4610. /**
  4611. * Gets a value indicating that the current group is playing
  4612. */
  4613. readonly isPlaying: boolean;
  4614. /**
  4615. * Gets or sets the speed ratio to use for all animations
  4616. */
  4617. /**
  4618. * Gets or sets the speed ratio to use for all animations
  4619. */
  4620. speedRatio: number;
  4621. /**
  4622. * Gets the targeted animations for this animation group
  4623. */
  4624. readonly targetedAnimations: Array<TargetedAnimation>;
  4625. /**
  4626. * returning the list of animatables controlled by this animation group.
  4627. */
  4628. readonly animatables: Array<Animatable>;
  4629. /**
  4630. * Instantiates a new Animation Group.
  4631. * This helps managing several animations at once.
  4632. * @see http://doc.babylonjs.com/how_to/group
  4633. * @param name Defines the name of the group
  4634. * @param scene Defines the scene the group belongs to
  4635. */
  4636. constructor(
  4637. /** The name of the animation group */
  4638. name: string, scene?: Nullable<Scene>);
  4639. /**
  4640. * Add an animation (with its target) in the group
  4641. * @param animation defines the animation we want to add
  4642. * @param target defines the target of the animation
  4643. * @returns the TargetedAnimation object
  4644. */
  4645. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4646. /**
  4647. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4648. * It can add constant keys at begin or end
  4649. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4650. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4651. * @returns the animation group
  4652. */
  4653. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4654. /**
  4655. * Start all animations on given targets
  4656. * @param loop defines if animations must loop
  4657. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4658. * @param from defines the from key (optional)
  4659. * @param to defines the to key (optional)
  4660. * @returns the current animation group
  4661. */
  4662. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4663. /**
  4664. * Pause all animations
  4665. * @returns the animation group
  4666. */
  4667. pause(): AnimationGroup;
  4668. /**
  4669. * Play all animations to initial state
  4670. * This function will start() the animations if they were not started or will restart() them if they were paused
  4671. * @param loop defines if animations must loop
  4672. * @returns the animation group
  4673. */
  4674. play(loop?: boolean): AnimationGroup;
  4675. /**
  4676. * Reset all animations to initial state
  4677. * @returns the animation group
  4678. */
  4679. reset(): AnimationGroup;
  4680. /**
  4681. * Restart animations from key 0
  4682. * @returns the animation group
  4683. */
  4684. restart(): AnimationGroup;
  4685. /**
  4686. * Stop all animations
  4687. * @returns the animation group
  4688. */
  4689. stop(): AnimationGroup;
  4690. /**
  4691. * Set animation weight for all animatables
  4692. * @param weight defines the weight to use
  4693. * @return the animationGroup
  4694. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4695. */
  4696. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4697. /**
  4698. * Synchronize and normalize all animatables with a source animatable
  4699. * @param root defines the root animatable to synchronize with
  4700. * @return the animationGroup
  4701. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4702. */
  4703. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4704. /**
  4705. * Goes to a specific frame in this animation group
  4706. * @param frame the frame number to go to
  4707. * @return the animationGroup
  4708. */
  4709. goToFrame(frame: number): AnimationGroup;
  4710. /**
  4711. * Dispose all associated resources
  4712. */
  4713. dispose(): void;
  4714. private _checkAnimationGroupEnded;
  4715. /**
  4716. * Returns a new AnimationGroup object parsed from the source provided.
  4717. * @param parsedAnimationGroup defines the source
  4718. * @param scene defines the scene that will receive the animationGroup
  4719. * @returns a new AnimationGroup
  4720. */
  4721. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4722. /**
  4723. * Returns the string "AnimationGroup"
  4724. * @returns "AnimationGroup"
  4725. */
  4726. getClassName(): string;
  4727. /**
  4728. * Creates a detailled string about the object
  4729. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4730. * @returns a string representing the object
  4731. */
  4732. toString(fullDetails?: boolean): string;
  4733. }
  4734. }
  4735. declare module BABYLON {
  4736. /**
  4737. * Class used to override all child animations of a given target
  4738. */
  4739. class AnimationPropertiesOverride {
  4740. /**
  4741. * Gets or sets a value indicating if animation blending must be used
  4742. */
  4743. enableBlending: boolean;
  4744. /**
  4745. * Gets or sets the blending speed to use when enableBlending is true
  4746. */
  4747. blendingSpeed: number;
  4748. /**
  4749. * Gets or sets the default loop mode to use
  4750. */
  4751. loopMode: number;
  4752. }
  4753. }
  4754. declare module BABYLON {
  4755. /**
  4756. * This represents the main contract an easing function should follow.
  4757. * Easing functions are used throughout the animation system.
  4758. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4759. */
  4760. interface IEasingFunction {
  4761. /**
  4762. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4763. * of the easing function.
  4764. * The link below provides some of the most common examples of easing functions.
  4765. * @see https://easings.net/
  4766. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4767. * @returns the corresponding value on the curve defined by the easing function
  4768. */
  4769. ease(gradient: number): number;
  4770. }
  4771. /**
  4772. * Base class used for every default easing function.
  4773. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4774. */
  4775. class EasingFunction implements IEasingFunction {
  4776. /**
  4777. * Interpolation follows the mathematical formula associated with the easing function.
  4778. */
  4779. static readonly EASINGMODE_EASEIN: number;
  4780. /**
  4781. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4782. */
  4783. static readonly EASINGMODE_EASEOUT: number;
  4784. /**
  4785. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4786. */
  4787. static readonly EASINGMODE_EASEINOUT: number;
  4788. private _easingMode;
  4789. /**
  4790. * Sets the easing mode of the current function.
  4791. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4792. */
  4793. setEasingMode(easingMode: number): void;
  4794. /**
  4795. * Gets the current easing mode.
  4796. * @returns the easing mode
  4797. */
  4798. getEasingMode(): number;
  4799. /**
  4800. * @hidden
  4801. */
  4802. easeInCore(gradient: number): number;
  4803. /**
  4804. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4805. * of the easing function.
  4806. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4807. * @returns the corresponding value on the curve defined by the easing function
  4808. */
  4809. ease(gradient: number): number;
  4810. }
  4811. /**
  4812. * Easing function with a circle shape (see link below).
  4813. * @see https://easings.net/#easeInCirc
  4814. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4815. */
  4816. class CircleEase extends EasingFunction implements IEasingFunction {
  4817. /** @hidden */
  4818. easeInCore(gradient: number): number;
  4819. }
  4820. /**
  4821. * Easing function with a ease back shape (see link below).
  4822. * @see https://easings.net/#easeInBack
  4823. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4824. */
  4825. class BackEase extends EasingFunction implements IEasingFunction {
  4826. /** Defines the amplitude of the function */
  4827. amplitude: number;
  4828. /**
  4829. * Instantiates a back ease easing
  4830. * @see https://easings.net/#easeInBack
  4831. * @param amplitude Defines the amplitude of the function
  4832. */
  4833. constructor(
  4834. /** Defines the amplitude of the function */
  4835. amplitude?: number);
  4836. /** @hidden */
  4837. easeInCore(gradient: number): number;
  4838. }
  4839. /**
  4840. * Easing function with a bouncing shape (see link below).
  4841. * @see https://easings.net/#easeInBounce
  4842. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4843. */
  4844. class BounceEase extends EasingFunction implements IEasingFunction {
  4845. /** Defines the number of bounces */
  4846. bounces: number;
  4847. /** Defines the amplitude of the bounce */
  4848. bounciness: number;
  4849. /**
  4850. * Instantiates a bounce easing
  4851. * @see https://easings.net/#easeInBounce
  4852. * @param bounces Defines the number of bounces
  4853. * @param bounciness Defines the amplitude of the bounce
  4854. */
  4855. constructor(
  4856. /** Defines the number of bounces */
  4857. bounces?: number,
  4858. /** Defines the amplitude of the bounce */
  4859. bounciness?: number);
  4860. /** @hidden */
  4861. easeInCore(gradient: number): number;
  4862. }
  4863. /**
  4864. * Easing function with a power of 3 shape (see link below).
  4865. * @see https://easings.net/#easeInCubic
  4866. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4867. */
  4868. class CubicEase extends EasingFunction implements IEasingFunction {
  4869. /** @hidden */
  4870. easeInCore(gradient: number): number;
  4871. }
  4872. /**
  4873. * Easing function with an elastic shape (see link below).
  4874. * @see https://easings.net/#easeInElastic
  4875. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4876. */
  4877. class ElasticEase extends EasingFunction implements IEasingFunction {
  4878. /** Defines the number of oscillations*/
  4879. oscillations: number;
  4880. /** Defines the amplitude of the oscillations*/
  4881. springiness: number;
  4882. /**
  4883. * Instantiates an elastic easing function
  4884. * @see https://easings.net/#easeInElastic
  4885. * @param oscillations Defines the number of oscillations
  4886. * @param springiness Defines the amplitude of the oscillations
  4887. */
  4888. constructor(
  4889. /** Defines the number of oscillations*/
  4890. oscillations?: number,
  4891. /** Defines the amplitude of the oscillations*/
  4892. springiness?: number);
  4893. /** @hidden */
  4894. easeInCore(gradient: number): number;
  4895. }
  4896. /**
  4897. * Easing function with an exponential shape (see link below).
  4898. * @see https://easings.net/#easeInExpo
  4899. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4900. */
  4901. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4902. /** Defines the exponent of the function */
  4903. exponent: number;
  4904. /**
  4905. * Instantiates an exponential easing function
  4906. * @see https://easings.net/#easeInExpo
  4907. * @param exponent Defines the exponent of the function
  4908. */
  4909. constructor(
  4910. /** Defines the exponent of the function */
  4911. exponent?: number);
  4912. /** @hidden */
  4913. easeInCore(gradient: number): number;
  4914. }
  4915. /**
  4916. * Easing function with a power shape (see link below).
  4917. * @see https://easings.net/#easeInQuad
  4918. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4919. */
  4920. class PowerEase extends EasingFunction implements IEasingFunction {
  4921. /** Defines the power of the function */
  4922. power: number;
  4923. /**
  4924. * Instantiates an power base easing function
  4925. * @see https://easings.net/#easeInQuad
  4926. * @param power Defines the power of the function
  4927. */
  4928. constructor(
  4929. /** Defines the power of the function */
  4930. power?: number);
  4931. /** @hidden */
  4932. easeInCore(gradient: number): number;
  4933. }
  4934. /**
  4935. * Easing function with a power of 2 shape (see link below).
  4936. * @see https://easings.net/#easeInQuad
  4937. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4938. */
  4939. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4940. /** @hidden */
  4941. easeInCore(gradient: number): number;
  4942. }
  4943. /**
  4944. * Easing function with a power of 4 shape (see link below).
  4945. * @see https://easings.net/#easeInQuart
  4946. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4947. */
  4948. class QuarticEase extends EasingFunction implements IEasingFunction {
  4949. /** @hidden */
  4950. easeInCore(gradient: number): number;
  4951. }
  4952. /**
  4953. * Easing function with a power of 5 shape (see link below).
  4954. * @see https://easings.net/#easeInQuint
  4955. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4956. */
  4957. class QuinticEase extends EasingFunction implements IEasingFunction {
  4958. /** @hidden */
  4959. easeInCore(gradient: number): number;
  4960. }
  4961. /**
  4962. * Easing function with a sin shape (see link below).
  4963. * @see https://easings.net/#easeInSine
  4964. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4965. */
  4966. class SineEase extends EasingFunction implements IEasingFunction {
  4967. /** @hidden */
  4968. easeInCore(gradient: number): number;
  4969. }
  4970. /**
  4971. * Easing function with a bezier shape (see link below).
  4972. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4973. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4974. */
  4975. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4976. /** Defines the x component of the start tangent in the bezier curve */
  4977. x1: number;
  4978. /** Defines the y component of the start tangent in the bezier curve */
  4979. y1: number;
  4980. /** Defines the x component of the end tangent in the bezier curve */
  4981. x2: number;
  4982. /** Defines the y component of the end tangent in the bezier curve */
  4983. y2: number;
  4984. /**
  4985. * Instantiates a bezier function
  4986. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4987. * @param x1 Defines the x component of the start tangent in the bezier curve
  4988. * @param y1 Defines the y component of the start tangent in the bezier curve
  4989. * @param x2 Defines the x component of the end tangent in the bezier curve
  4990. * @param y2 Defines the y component of the end tangent in the bezier curve
  4991. */
  4992. constructor(
  4993. /** Defines the x component of the start tangent in the bezier curve */
  4994. x1?: number,
  4995. /** Defines the y component of the start tangent in the bezier curve */
  4996. y1?: number,
  4997. /** Defines the x component of the end tangent in the bezier curve */
  4998. x2?: number,
  4999. /** Defines the y component of the end tangent in the bezier curve */
  5000. y2?: number);
  5001. /** @hidden */
  5002. easeInCore(gradient: number): number;
  5003. }
  5004. }
  5005. declare module BABYLON {
  5006. /**
  5007. * Defines a runtime animation
  5008. */
  5009. class RuntimeAnimation {
  5010. private _events;
  5011. /**
  5012. * The current frame of the runtime animation
  5013. */
  5014. private _currentFrame;
  5015. /**
  5016. * The animation used by the runtime animation
  5017. */
  5018. private _animation;
  5019. /**
  5020. * The target of the runtime animation
  5021. */
  5022. private _target;
  5023. /**
  5024. * The initiating animatable
  5025. */
  5026. private _host;
  5027. /**
  5028. * The original value of the runtime animation
  5029. */
  5030. private _originalValue;
  5031. /**
  5032. * The original blend value of the runtime animation
  5033. */
  5034. private _originalBlendValue;
  5035. /**
  5036. * The offsets cache of the runtime animation
  5037. */
  5038. private _offsetsCache;
  5039. /**
  5040. * The high limits cache of the runtime animation
  5041. */
  5042. private _highLimitsCache;
  5043. /**
  5044. * Specifies if the runtime animation has been stopped
  5045. */
  5046. private _stopped;
  5047. /**
  5048. * The blending factor of the runtime animation
  5049. */
  5050. private _blendingFactor;
  5051. /**
  5052. * The BabylonJS scene
  5053. */
  5054. private _scene;
  5055. /**
  5056. * The current value of the runtime animation
  5057. */
  5058. private _currentValue;
  5059. /** @hidden */
  5060. _workValue: any;
  5061. /**
  5062. * The active target of the runtime animation
  5063. */
  5064. private _activeTarget;
  5065. /**
  5066. * The target path of the runtime animation
  5067. */
  5068. private _targetPath;
  5069. /**
  5070. * The weight of the runtime animation
  5071. */
  5072. private _weight;
  5073. /**
  5074. * The ratio offset of the runtime animation
  5075. */
  5076. private _ratioOffset;
  5077. /**
  5078. * The previous delay of the runtime animation
  5079. */
  5080. private _previousDelay;
  5081. /**
  5082. * The previous ratio of the runtime animation
  5083. */
  5084. private _previousRatio;
  5085. /**
  5086. * Gets the current frame of the runtime animation
  5087. */
  5088. readonly currentFrame: number;
  5089. /**
  5090. * Gets the weight of the runtime animation
  5091. */
  5092. readonly weight: number;
  5093. /**
  5094. * Gets the current value of the runtime animation
  5095. */
  5096. readonly currentValue: any;
  5097. /**
  5098. * Gets the target path of the runtime animation
  5099. */
  5100. readonly targetPath: string;
  5101. /**
  5102. * Gets the actual target of the runtime animation
  5103. */
  5104. readonly target: any;
  5105. /**
  5106. * Create a new RuntimeAnimation object
  5107. * @param target defines the target of the animation
  5108. * @param animation defines the source animation object
  5109. * @param scene defines the hosting scene
  5110. * @param host defines the initiating Animatable
  5111. */
  5112. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5113. /**
  5114. * Gets the animation from the runtime animation
  5115. */
  5116. readonly animation: Animation;
  5117. /**
  5118. * Resets the runtime animation to the beginning
  5119. * @param restoreOriginal defines whether to restore the target property to the original value
  5120. */
  5121. reset(restoreOriginal?: boolean): void;
  5122. /**
  5123. * Specifies if the runtime animation is stopped
  5124. * @returns Boolean specifying if the runtime animation is stopped
  5125. */
  5126. isStopped(): boolean;
  5127. /**
  5128. * Disposes of the runtime animation
  5129. */
  5130. dispose(): void;
  5131. /**
  5132. * Interpolates the animation from the current frame
  5133. * @param currentFrame The frame to interpolate the animation to
  5134. * @param repeatCount The number of times that the animation should loop
  5135. * @param loopMode The type of looping mode to use
  5136. * @param offsetValue Animation offset value
  5137. * @param highLimitValue The high limit value
  5138. * @returns The interpolated value
  5139. */
  5140. private _interpolate;
  5141. /**
  5142. * Apply the interpolated value to the target
  5143. * @param currentValue defines the value computed by the animation
  5144. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5145. */
  5146. setValue(currentValue: any, weight?: number): void;
  5147. private _setValue;
  5148. /**
  5149. * Gets the loop pmode of the runtime animation
  5150. * @returns Loop Mode
  5151. */
  5152. private _getCorrectLoopMode;
  5153. /**
  5154. * Move the current animation to a given frame
  5155. * @param frame defines the frame to move to
  5156. */
  5157. goToFrame(frame: number): void;
  5158. /**
  5159. * @hidden Internal use only
  5160. */
  5161. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5162. /**
  5163. * Execute the current animation
  5164. * @param delay defines the delay to add to the current frame
  5165. * @param from defines the lower bound of the animation range
  5166. * @param to defines the upper bound of the animation range
  5167. * @param loop defines if the current animation must loop
  5168. * @param speedRatio defines the current speed ratio
  5169. * @param weight defines the weight of the animation (default is -1 so no weight)
  5170. * @returns a boolean indicating if the animation is running
  5171. */
  5172. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  5173. }
  5174. }
  5175. declare module BABYLON {
  5176. /**
  5177. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5178. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5179. */
  5180. class Analyser {
  5181. /**
  5182. * Gets or sets the smoothing
  5183. * @ignorenaming
  5184. */
  5185. SMOOTHING: number;
  5186. /**
  5187. * Gets or sets the FFT table size
  5188. * @ignorenaming
  5189. */
  5190. FFT_SIZE: number;
  5191. /**
  5192. * Gets or sets the bar graph amplitude
  5193. * @ignorenaming
  5194. */
  5195. BARGRAPHAMPLITUDE: number;
  5196. /**
  5197. * Gets or sets the position of the debug canvas
  5198. * @ignorenaming
  5199. */
  5200. DEBUGCANVASPOS: {
  5201. x: number;
  5202. y: number;
  5203. };
  5204. /**
  5205. * Gets or sets the debug canvas size
  5206. * @ignorenaming
  5207. */
  5208. DEBUGCANVASSIZE: {
  5209. width: number;
  5210. height: number;
  5211. };
  5212. private _byteFreqs;
  5213. private _byteTime;
  5214. private _floatFreqs;
  5215. private _webAudioAnalyser;
  5216. private _debugCanvas;
  5217. private _debugCanvasContext;
  5218. private _scene;
  5219. private _registerFunc;
  5220. private _audioEngine;
  5221. /**
  5222. * Creates a new analyser
  5223. * @param scene defines hosting scene
  5224. */
  5225. constructor(scene: Scene);
  5226. /**
  5227. * Get the number of data values you will have to play with for the visualization
  5228. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5229. * @returns a number
  5230. */
  5231. getFrequencyBinCount(): number;
  5232. /**
  5233. * Gets the current frequency data as a byte array
  5234. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5235. * @returns a Uint8Array
  5236. */
  5237. getByteFrequencyData(): Uint8Array;
  5238. /**
  5239. * Gets the current waveform as a byte array
  5240. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5241. * @returns a Uint8Array
  5242. */
  5243. getByteTimeDomainData(): Uint8Array;
  5244. /**
  5245. * Gets the current frequency data as a float array
  5246. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5247. * @returns a Float32Array
  5248. */
  5249. getFloatFrequencyData(): Float32Array;
  5250. /**
  5251. * Renders the debug canvas
  5252. */
  5253. drawDebugCanvas(): void;
  5254. /**
  5255. * Stops rendering the debug canvas and removes it
  5256. */
  5257. stopDebugCanvas(): void;
  5258. /**
  5259. * Connects two audio nodes
  5260. * @param inputAudioNode defines first node to connect
  5261. * @param outputAudioNode defines second node to connect
  5262. */
  5263. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5264. /**
  5265. * Releases all associated resources
  5266. */
  5267. dispose(): void;
  5268. }
  5269. }
  5270. declare module BABYLON {
  5271. /**
  5272. * This represents an audio engine and it is responsible
  5273. * to play, synchronize and analyse sounds throughout the application.
  5274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5275. */
  5276. interface IAudioEngine extends IDisposable {
  5277. /**
  5278. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5279. */
  5280. readonly canUseWebAudio: boolean;
  5281. /**
  5282. * Gets the current AudioContext if available.
  5283. */
  5284. readonly audioContext: Nullable<AudioContext>;
  5285. /**
  5286. * The master gain node defines the global audio volume of your audio engine.
  5287. */
  5288. readonly masterGain: GainNode;
  5289. /**
  5290. * Gets whether or not mp3 are supported by your browser.
  5291. */
  5292. readonly isMP3supported: boolean;
  5293. /**
  5294. * Gets whether or not ogg are supported by your browser.
  5295. */
  5296. readonly isOGGsupported: boolean;
  5297. /**
  5298. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5299. * @ignoreNaming
  5300. */
  5301. WarnedWebAudioUnsupported: boolean;
  5302. /**
  5303. * Defines if the audio engine relies on a custom unlocked button.
  5304. * In this case, the embedded button will not be displayed.
  5305. */
  5306. useCustomUnlockedButton: boolean;
  5307. /**
  5308. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5309. */
  5310. readonly unlocked: boolean;
  5311. /**
  5312. * Event raised when audio has been unlocked on the browser.
  5313. */
  5314. onAudioUnlockedObservable: Observable<AudioEngine>;
  5315. /**
  5316. * Event raised when audio has been locked on the browser.
  5317. */
  5318. onAudioLockedObservable: Observable<AudioEngine>;
  5319. /**
  5320. * Flags the audio engine in Locked state.
  5321. * This happens due to new browser policies preventing audio to autoplay.
  5322. */
  5323. lock(): void;
  5324. /**
  5325. * Unlocks the audio engine once a user action has been done on the dom.
  5326. * This is helpful to resume play once browser policies have been satisfied.
  5327. */
  5328. unlock(): void;
  5329. }
  5330. /**
  5331. * This represents the default audio engine used in babylon.
  5332. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5333. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5334. */
  5335. class AudioEngine implements IAudioEngine {
  5336. private _audioContext;
  5337. private _audioContextInitialized;
  5338. private _muteButton;
  5339. private _hostElement;
  5340. /**
  5341. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5342. */
  5343. canUseWebAudio: boolean;
  5344. /**
  5345. * The master gain node defines the global audio volume of your audio engine.
  5346. */
  5347. masterGain: GainNode;
  5348. /**
  5349. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5350. * @ignoreNaming
  5351. */
  5352. WarnedWebAudioUnsupported: boolean;
  5353. /**
  5354. * Gets whether or not mp3 are supported by your browser.
  5355. */
  5356. isMP3supported: boolean;
  5357. /**
  5358. * Gets whether or not ogg are supported by your browser.
  5359. */
  5360. isOGGsupported: boolean;
  5361. /**
  5362. * Gets whether audio has been unlocked on the device.
  5363. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5364. * a user interaction has happened.
  5365. */
  5366. unlocked: boolean;
  5367. /**
  5368. * Defines if the audio engine relies on a custom unlocked button.
  5369. * In this case, the embedded button will not be displayed.
  5370. */
  5371. useCustomUnlockedButton: boolean;
  5372. /**
  5373. * Event raised when audio has been unlocked on the browser.
  5374. */
  5375. onAudioUnlockedObservable: Observable<AudioEngine>;
  5376. /**
  5377. * Event raised when audio has been locked on the browser.
  5378. */
  5379. onAudioLockedObservable: Observable<AudioEngine>;
  5380. /**
  5381. * Gets the current AudioContext if available.
  5382. */
  5383. readonly audioContext: Nullable<AudioContext>;
  5384. private _connectedAnalyser;
  5385. /**
  5386. * Instantiates a new audio engine.
  5387. *
  5388. * There should be only one per page as some browsers restrict the number
  5389. * of audio contexts you can create.
  5390. * @param hostElement defines the host element where to display the mute icon if necessary
  5391. */
  5392. constructor(hostElement?: Nullable<HTMLElement>);
  5393. /**
  5394. * Flags the audio engine in Locked state.
  5395. * This happens due to new browser policies preventing audio to autoplay.
  5396. */
  5397. lock(): void;
  5398. /**
  5399. * Unlocks the audio engine once a user action has been done on the dom.
  5400. * This is helpful to resume play once browser policies have been satisfied.
  5401. */
  5402. unlock(): void;
  5403. private _resumeAudioContext;
  5404. private _initializeAudioContext;
  5405. private _tryToRun;
  5406. private _triggerRunningState;
  5407. private _triggerSuspendedState;
  5408. private _displayMuteButton;
  5409. private _moveButtonToTopLeft;
  5410. private _onResize;
  5411. private _hideMuteButton;
  5412. /**
  5413. * Destroy and release the resources associated with the audio ccontext.
  5414. */
  5415. dispose(): void;
  5416. /**
  5417. * Gets the global volume sets on the master gain.
  5418. * @returns the global volume if set or -1 otherwise
  5419. */
  5420. getGlobalVolume(): number;
  5421. /**
  5422. * Sets the global volume of your experience (sets on the master gain).
  5423. * @param newVolume Defines the new global volume of the application
  5424. */
  5425. setGlobalVolume(newVolume: number): void;
  5426. /**
  5427. * Connect the audio engine to an audio analyser allowing some amazing
  5428. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5430. * @param analyser The analyser to connect to the engine
  5431. */
  5432. connectToAnalyser(analyser: Analyser): void;
  5433. }
  5434. }
  5435. declare module BABYLON {
  5436. interface AbstractScene {
  5437. /**
  5438. * The list of sounds used in the scene.
  5439. */
  5440. sounds: Nullable<Array<Sound>>;
  5441. }
  5442. interface Scene {
  5443. /**
  5444. * @hidden
  5445. * Backing field
  5446. */
  5447. _mainSoundTrack: SoundTrack;
  5448. /**
  5449. * The main sound track played by the scene.
  5450. * It cotains your primary collection of sounds.
  5451. */
  5452. mainSoundTrack: SoundTrack;
  5453. /**
  5454. * The list of sound tracks added to the scene
  5455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5456. */
  5457. soundTracks: Nullable<Array<SoundTrack>>;
  5458. /**
  5459. * Gets a sound using a given name
  5460. * @param name defines the name to search for
  5461. * @return the found sound or null if not found at all.
  5462. */
  5463. getSoundByName(name: string): Nullable<Sound>;
  5464. /**
  5465. * Gets or sets if audio support is enabled
  5466. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5467. */
  5468. audioEnabled: boolean;
  5469. /**
  5470. * Gets or sets if audio will be output to headphones
  5471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5472. */
  5473. headphone: boolean;
  5474. }
  5475. /**
  5476. * Defines the sound scene component responsible to manage any sounds
  5477. * in a given scene.
  5478. */
  5479. class AudioSceneComponent implements ISceneSerializableComponent {
  5480. /**
  5481. * The component name helpfull to identify the component in the list of scene components.
  5482. */
  5483. readonly name: string;
  5484. /**
  5485. * The scene the component belongs to.
  5486. */
  5487. scene: Scene;
  5488. private _audioEnabled;
  5489. /**
  5490. * Gets whether audio is enabled or not.
  5491. * Please use related enable/disable method to switch state.
  5492. */
  5493. readonly audioEnabled: boolean;
  5494. private _headphone;
  5495. /**
  5496. * Gets whether audio is outputing to headphone or not.
  5497. * Please use the according Switch methods to change output.
  5498. */
  5499. readonly headphone: boolean;
  5500. /**
  5501. * Creates a new instance of the component for the given scene
  5502. * @param scene Defines the scene to register the component in
  5503. */
  5504. constructor(scene: Scene);
  5505. /**
  5506. * Registers the component in a given scene
  5507. */
  5508. register(): void;
  5509. /**
  5510. * Rebuilds the elements related to this component in case of
  5511. * context lost for instance.
  5512. */
  5513. rebuild(): void;
  5514. /**
  5515. * Serializes the component data to the specified json object
  5516. * @param serializationObject The object to serialize to
  5517. */
  5518. serialize(serializationObject: any): void;
  5519. /**
  5520. * Adds all the element from the container to the scene
  5521. * @param container the container holding the elements
  5522. */
  5523. addFromContainer(container: AbstractScene): void;
  5524. /**
  5525. * Removes all the elements in the container from the scene
  5526. * @param container contains the elements to remove
  5527. */
  5528. removeFromContainer(container: AbstractScene): void;
  5529. /**
  5530. * Disposes the component and the associated ressources.
  5531. */
  5532. dispose(): void;
  5533. /**
  5534. * Disables audio in the associated scene.
  5535. */
  5536. disableAudio(): void;
  5537. /**
  5538. * Enables audio in the associated scene.
  5539. */
  5540. enableAudio(): void;
  5541. /**
  5542. * Switch audio to headphone output.
  5543. */
  5544. switchAudioModeForHeadphones(): void;
  5545. /**
  5546. * Switch audio to normal speakers.
  5547. */
  5548. switchAudioModeForNormalSpeakers(): void;
  5549. private _afterRender;
  5550. }
  5551. }
  5552. declare module BABYLON {
  5553. /**
  5554. * Defines a sound that can be played in the application.
  5555. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5557. */
  5558. class Sound {
  5559. /**
  5560. * The name of the sound in the scene.
  5561. */
  5562. name: string;
  5563. /**
  5564. * Does the sound autoplay once loaded.
  5565. */
  5566. autoplay: boolean;
  5567. /**
  5568. * Does the sound loop after it finishes playing once.
  5569. */
  5570. loop: boolean;
  5571. /**
  5572. * Does the sound use a custom attenuation curve to simulate the falloff
  5573. * happening when the source gets further away from the camera.
  5574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5575. */
  5576. useCustomAttenuation: boolean;
  5577. /**
  5578. * The sound track id this sound belongs to.
  5579. */
  5580. soundTrackId: number;
  5581. /**
  5582. * Is this sound currently played.
  5583. */
  5584. isPlaying: boolean;
  5585. /**
  5586. * Is this sound currently paused.
  5587. */
  5588. isPaused: boolean;
  5589. /**
  5590. * Does this sound enables spatial sound.
  5591. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5592. */
  5593. spatialSound: boolean;
  5594. /**
  5595. * Define the reference distance the sound should be heard perfectly.
  5596. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5597. */
  5598. refDistance: number;
  5599. /**
  5600. * Define the roll off factor of spatial sounds.
  5601. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5602. */
  5603. rolloffFactor: number;
  5604. /**
  5605. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5607. */
  5608. maxDistance: number;
  5609. /**
  5610. * Define the distance attenuation model the sound will follow.
  5611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5612. */
  5613. distanceModel: string;
  5614. /**
  5615. * @hidden
  5616. * Back Compat
  5617. **/
  5618. onended: () => any;
  5619. /**
  5620. * Observable event when the current playing sound finishes.
  5621. */
  5622. onEndedObservable: Observable<Sound>;
  5623. private _panningModel;
  5624. private _playbackRate;
  5625. private _streaming;
  5626. private _startTime;
  5627. private _startOffset;
  5628. private _position;
  5629. /** @hidden */
  5630. _positionInEmitterSpace: boolean;
  5631. private _localDirection;
  5632. private _volume;
  5633. private _isReadyToPlay;
  5634. private _isDirectional;
  5635. private _readyToPlayCallback;
  5636. private _audioBuffer;
  5637. private _soundSource;
  5638. private _streamingSource;
  5639. private _soundPanner;
  5640. private _soundGain;
  5641. private _inputAudioNode;
  5642. private _outputAudioNode;
  5643. private _coneInnerAngle;
  5644. private _coneOuterAngle;
  5645. private _coneOuterGain;
  5646. private _scene;
  5647. private _connectedTransformNode;
  5648. private _customAttenuationFunction;
  5649. private _registerFunc;
  5650. private _isOutputConnected;
  5651. private _htmlAudioElement;
  5652. private _urlType;
  5653. /**
  5654. * Create a sound and attach it to a scene
  5655. * @param name Name of your sound
  5656. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5657. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5658. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5659. */
  5660. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5661. /**
  5662. * Release the sound and its associated resources
  5663. */
  5664. dispose(): void;
  5665. /**
  5666. * Gets if the sounds is ready to be played or not.
  5667. * @returns true if ready, otherwise false
  5668. */
  5669. isReady(): boolean;
  5670. private _soundLoaded;
  5671. /**
  5672. * Sets the data of the sound from an audiobuffer
  5673. * @param audioBuffer The audioBuffer containing the data
  5674. */
  5675. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5676. /**
  5677. * Updates the current sounds options such as maxdistance, loop...
  5678. * @param options A JSON object containing values named as the object properties
  5679. */
  5680. updateOptions(options: any): void;
  5681. private _createSpatialParameters;
  5682. private _updateSpatialParameters;
  5683. /**
  5684. * Switch the panning model to HRTF:
  5685. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5687. */
  5688. switchPanningModelToHRTF(): void;
  5689. /**
  5690. * Switch the panning model to Equal Power:
  5691. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5692. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5693. */
  5694. switchPanningModelToEqualPower(): void;
  5695. private _switchPanningModel;
  5696. /**
  5697. * Connect this sound to a sound track audio node like gain...
  5698. * @param soundTrackAudioNode the sound track audio node to connect to
  5699. */
  5700. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5701. /**
  5702. * Transform this sound into a directional source
  5703. * @param coneInnerAngle Size of the inner cone in degree
  5704. * @param coneOuterAngle Size of the outer cone in degree
  5705. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5706. */
  5707. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5708. /**
  5709. * Gets or sets the inner angle for the directional cone.
  5710. */
  5711. /**
  5712. * Gets or sets the inner angle for the directional cone.
  5713. */
  5714. directionalConeInnerAngle: number;
  5715. /**
  5716. * Gets or sets the outer angle for the directional cone.
  5717. */
  5718. /**
  5719. * Gets or sets the outer angle for the directional cone.
  5720. */
  5721. directionalConeOuterAngle: number;
  5722. /**
  5723. * Sets the position of the emitter if spatial sound is enabled
  5724. * @param newPosition Defines the new posisiton
  5725. */
  5726. setPosition(newPosition: Vector3): void;
  5727. /**
  5728. * Sets the local direction of the emitter if spatial sound is enabled
  5729. * @param newLocalDirection Defines the new local direction
  5730. */
  5731. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5732. private _updateDirection;
  5733. /** @hidden */
  5734. updateDistanceFromListener(): void;
  5735. /**
  5736. * Sets a new custom attenuation function for the sound.
  5737. * @param callback Defines the function used for the attenuation
  5738. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5739. */
  5740. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5741. /**
  5742. * Play the sound
  5743. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5744. * @param offset (optional) Start the sound setting it at a specific time
  5745. */
  5746. play(time?: number, offset?: number): void;
  5747. private _onended;
  5748. /**
  5749. * Stop the sound
  5750. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5751. */
  5752. stop(time?: number): void;
  5753. /**
  5754. * Put the sound in pause
  5755. */
  5756. pause(): void;
  5757. /**
  5758. * Sets a dedicated volume for this sounds
  5759. * @param newVolume Define the new volume of the sound
  5760. * @param time Define in how long the sound should be at this value
  5761. */
  5762. setVolume(newVolume: number, time?: number): void;
  5763. /**
  5764. * Set the sound play back rate
  5765. * @param newPlaybackRate Define the playback rate the sound should be played at
  5766. */
  5767. setPlaybackRate(newPlaybackRate: number): void;
  5768. /**
  5769. * Gets the volume of the sound.
  5770. * @returns the volume of the sound
  5771. */
  5772. getVolume(): number;
  5773. /**
  5774. * Attach the sound to a dedicated mesh
  5775. * @param transformNode The transform node to connect the sound with
  5776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5777. */
  5778. attachToMesh(transformNode: TransformNode): void;
  5779. /**
  5780. * Detach the sound from the previously attached mesh
  5781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5782. */
  5783. detachFromMesh(): void;
  5784. private _onRegisterAfterWorldMatrixUpdate;
  5785. /**
  5786. * Clone the current sound in the scene.
  5787. * @returns the new sound clone
  5788. */
  5789. clone(): Nullable<Sound>;
  5790. /**
  5791. * Gets the current underlying audio buffer containing the data
  5792. * @returns the audio buffer
  5793. */
  5794. getAudioBuffer(): Nullable<AudioBuffer>;
  5795. /**
  5796. * Serializes the Sound in a JSON representation
  5797. * @returns the JSON representation of the sound
  5798. */
  5799. serialize(): any;
  5800. /**
  5801. * Parse a JSON representation of a sound to innstantiate in a given scene
  5802. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5803. * @param scene Define the scene the new parsed sound should be created in
  5804. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5805. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5806. * @returns the newly parsed sound
  5807. */
  5808. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5809. }
  5810. }
  5811. declare module BABYLON {
  5812. /**
  5813. * Options allowed during the creation of a sound track.
  5814. */
  5815. interface ISoundTrackOptions {
  5816. /**
  5817. * The volume the sound track should take during creation
  5818. */
  5819. volume?: number;
  5820. /**
  5821. * Define if the sound track is the main sound track of the scene
  5822. */
  5823. mainTrack?: boolean;
  5824. }
  5825. /**
  5826. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5827. * It will be also used in a future release to apply effects on a specific track.
  5828. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5829. */
  5830. class SoundTrack {
  5831. /**
  5832. * The unique identifier of the sound track in the scene.
  5833. */
  5834. id: number;
  5835. /**
  5836. * The list of sounds included in the sound track.
  5837. */
  5838. soundCollection: Array<Sound>;
  5839. private _outputAudioNode;
  5840. private _scene;
  5841. private _isMainTrack;
  5842. private _connectedAnalyser;
  5843. private _options;
  5844. private _isInitialized;
  5845. /**
  5846. * Creates a new sound track.
  5847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5848. * @param scene Define the scene the sound track belongs to
  5849. * @param options
  5850. */
  5851. constructor(scene: Scene, options?: ISoundTrackOptions);
  5852. private _initializeSoundTrackAudioGraph;
  5853. /**
  5854. * Release the sound track and its associated resources
  5855. */
  5856. dispose(): void;
  5857. /**
  5858. * Adds a sound to this sound track
  5859. * @param sound define the cound to add
  5860. * @ignoreNaming
  5861. */
  5862. AddSound(sound: Sound): void;
  5863. /**
  5864. * Removes a sound to this sound track
  5865. * @param sound define the cound to remove
  5866. * @ignoreNaming
  5867. */
  5868. RemoveSound(sound: Sound): void;
  5869. /**
  5870. * Set a global volume for the full sound track.
  5871. * @param newVolume Define the new volume of the sound track
  5872. */
  5873. setVolume(newVolume: number): void;
  5874. /**
  5875. * Switch the panning model to HRTF:
  5876. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5878. */
  5879. switchPanningModelToHRTF(): void;
  5880. /**
  5881. * Switch the panning model to Equal Power:
  5882. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5884. */
  5885. switchPanningModelToEqualPower(): void;
  5886. /**
  5887. * Connect the sound track to an audio analyser allowing some amazing
  5888. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5889. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5890. * @param analyser The analyser to connect to the engine
  5891. */
  5892. connectToAnalyser(analyser: Analyser): void;
  5893. }
  5894. }
  5895. declare module BABYLON {
  5896. /**
  5897. * Wraps one or more Sound objects and selects one with random weight for playback.
  5898. */
  5899. class WeightedSound {
  5900. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5901. loop: boolean;
  5902. private _coneInnerAngle;
  5903. private _coneOuterAngle;
  5904. private _volume;
  5905. /** A Sound is currently playing. */
  5906. isPlaying: boolean;
  5907. /** A Sound is currently paused. */
  5908. isPaused: boolean;
  5909. private _sounds;
  5910. private _weights;
  5911. private _currentIndex?;
  5912. /**
  5913. * Creates a new WeightedSound from the list of sounds given.
  5914. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5915. * @param sounds Array of Sounds that will be selected from.
  5916. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5917. */
  5918. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5919. /**
  5920. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5921. */
  5922. /**
  5923. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5924. */
  5925. directionalConeInnerAngle: number;
  5926. /**
  5927. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5928. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5929. */
  5930. /**
  5931. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5932. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5933. */
  5934. directionalConeOuterAngle: number;
  5935. /**
  5936. * Playback volume.
  5937. */
  5938. /**
  5939. * Playback volume.
  5940. */
  5941. volume: number;
  5942. private _onended;
  5943. /**
  5944. * Suspend playback
  5945. */
  5946. pause(): void;
  5947. /**
  5948. * Stop playback
  5949. */
  5950. stop(): void;
  5951. /**
  5952. * Start playback.
  5953. * @param startOffset Position the clip head at a specific time in seconds.
  5954. */
  5955. play(startOffset?: number): void;
  5956. }
  5957. }
  5958. declare module BABYLON {
  5959. /**
  5960. * Interface used to define a behavior
  5961. */
  5962. interface Behavior<T> {
  5963. /** gets or sets behavior's name */
  5964. name: string;
  5965. /**
  5966. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5967. */
  5968. init(): void;
  5969. /**
  5970. * Called when the behavior is attached to a target
  5971. * @param target defines the target where the behavior is attached to
  5972. */
  5973. attach(target: T): void;
  5974. /**
  5975. * Called when the behavior is detached from its target
  5976. */
  5977. detach(): void;
  5978. }
  5979. /**
  5980. * Interface implemented by classes supporting behaviors
  5981. */
  5982. interface IBehaviorAware<T> {
  5983. /**
  5984. * Attach a behavior
  5985. * @param behavior defines the behavior to attach
  5986. * @returns the current host
  5987. */
  5988. addBehavior(behavior: Behavior<T>): T;
  5989. /**
  5990. * Remove a behavior from the current object
  5991. * @param behavior defines the behavior to detach
  5992. * @returns the current host
  5993. */
  5994. removeBehavior(behavior: Behavior<T>): T;
  5995. /**
  5996. * Gets a behavior using its name to search
  5997. * @param name defines the name to search
  5998. * @returns the behavior or null if not found
  5999. */
  6000. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6001. }
  6002. }
  6003. declare module BABYLON {
  6004. /**
  6005. * Class used to store bone information
  6006. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6007. */
  6008. class Bone extends Node {
  6009. /**
  6010. * defines the bone name
  6011. */
  6012. name: string;
  6013. private static _tmpVecs;
  6014. private static _tmpQuat;
  6015. private static _tmpMats;
  6016. /**
  6017. * Gets the list of child bones
  6018. */
  6019. children: Bone[];
  6020. /** Gets the animations associated with this bone */
  6021. animations: Animation[];
  6022. /**
  6023. * Gets or sets bone length
  6024. */
  6025. length: number;
  6026. /**
  6027. * @hidden Internal only
  6028. * Set this value to map this bone to a different index in the transform matrices
  6029. * Set this value to -1 to exclude the bone from the transform matrices
  6030. */
  6031. _index: Nullable<number>;
  6032. private _skeleton;
  6033. private _localMatrix;
  6034. private _restPose;
  6035. private _baseMatrix;
  6036. private _absoluteTransform;
  6037. private _invertedAbsoluteTransform;
  6038. private _parent;
  6039. private _scalingDeterminant;
  6040. private _worldTransform;
  6041. private _localScaling;
  6042. private _localRotation;
  6043. private _localPosition;
  6044. private _needToDecompose;
  6045. private _needToCompose;
  6046. /** @hidden */
  6047. _linkedTransformNode: Nullable<TransformNode>;
  6048. /** @hidden */
  6049. /** @hidden */
  6050. _matrix: Matrix;
  6051. /**
  6052. * Create a new bone
  6053. * @param name defines the bone name
  6054. * @param skeleton defines the parent skeleton
  6055. * @param parentBone defines the parent (can be null if the bone is the root)
  6056. * @param localMatrix defines the local matrix
  6057. * @param restPose defines the rest pose matrix
  6058. * @param baseMatrix defines the base matrix
  6059. * @param index defines index of the bone in the hiearchy
  6060. */
  6061. constructor(
  6062. /**
  6063. * defines the bone name
  6064. */
  6065. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  6066. /**
  6067. * Gets the parent skeleton
  6068. * @returns a skeleton
  6069. */
  6070. getSkeleton(): Skeleton;
  6071. /**
  6072. * Gets parent bone
  6073. * @returns a bone or null if the bone is the root of the bone hierarchy
  6074. */
  6075. getParent(): Nullable<Bone>;
  6076. /**
  6077. * Sets the parent bone
  6078. * @param parent defines the parent (can be null if the bone is the root)
  6079. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6080. */
  6081. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  6082. /**
  6083. * Gets the local matrix
  6084. * @returns a matrix
  6085. */
  6086. getLocalMatrix(): Matrix;
  6087. /**
  6088. * Gets the base matrix (initial matrix which remains unchanged)
  6089. * @returns a matrix
  6090. */
  6091. getBaseMatrix(): Matrix;
  6092. /**
  6093. * Gets the rest pose matrix
  6094. * @returns a matrix
  6095. */
  6096. getRestPose(): Matrix;
  6097. /**
  6098. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  6099. */
  6100. getWorldMatrix(): Matrix;
  6101. /**
  6102. * Sets the local matrix to rest pose matrix
  6103. */
  6104. returnToRest(): void;
  6105. /**
  6106. * Gets the inverse of the absolute transform matrix.
  6107. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  6108. * @returns a matrix
  6109. */
  6110. getInvertedAbsoluteTransform(): Matrix;
  6111. /**
  6112. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  6113. * @returns a matrix
  6114. */
  6115. getAbsoluteTransform(): Matrix;
  6116. /**
  6117. * Links with the given transform node.
  6118. * The local matrix of this bone is copied from the transform node every frame.
  6119. * @param transformNode defines the transform node to link to
  6120. */
  6121. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  6122. /** Gets or sets current position (in local space) */
  6123. position: Vector3;
  6124. /** Gets or sets current rotation (in local space) */
  6125. rotation: Vector3;
  6126. /** Gets or sets current rotation quaternion (in local space) */
  6127. rotationQuaternion: Quaternion;
  6128. /** Gets or sets current scaling (in local space) */
  6129. scaling: Vector3;
  6130. /**
  6131. * Gets the animation properties override
  6132. */
  6133. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6134. private _decompose;
  6135. private _compose;
  6136. /**
  6137. * Update the base and local matrices
  6138. * @param matrix defines the new base or local matrix
  6139. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6140. * @param updateLocalMatrix defines if the local matrix should be updated
  6141. */
  6142. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6143. /** @hidden */
  6144. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6145. /**
  6146. * Flag the bone as dirty (Forcing it to update everything)
  6147. */
  6148. markAsDirty(): void;
  6149. private _markAsDirtyAndCompose;
  6150. private _markAsDirtyAndDecompose;
  6151. /**
  6152. * Copy an animation range from another bone
  6153. * @param source defines the source bone
  6154. * @param rangeName defines the range name to copy
  6155. * @param frameOffset defines the frame offset
  6156. * @param rescaleAsRequired defines if rescaling must be applied if required
  6157. * @param skelDimensionsRatio defines the scaling ratio
  6158. * @returns true if operation was successful
  6159. */
  6160. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6161. /**
  6162. * Translate the bone in local or world space
  6163. * @param vec The amount to translate the bone
  6164. * @param space The space that the translation is in
  6165. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6166. */
  6167. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6168. /**
  6169. * Set the postion of the bone in local or world space
  6170. * @param position The position to set the bone
  6171. * @param space The space that the position is in
  6172. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6173. */
  6174. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6175. /**
  6176. * Set the absolute position of the bone (world space)
  6177. * @param position The position to set the bone
  6178. * @param mesh The mesh that this bone is attached to
  6179. */
  6180. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6181. /**
  6182. * Scale the bone on the x, y and z axes (in local space)
  6183. * @param x The amount to scale the bone on the x axis
  6184. * @param y The amount to scale the bone on the y axis
  6185. * @param z The amount to scale the bone on the z axis
  6186. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6187. */
  6188. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6189. /**
  6190. * Set the bone scaling in local space
  6191. * @param scale defines the scaling vector
  6192. */
  6193. setScale(scale: Vector3): void;
  6194. /**
  6195. * Gets the current scaling in local space
  6196. * @returns the current scaling vector
  6197. */
  6198. getScale(): Vector3;
  6199. /**
  6200. * Gets the current scaling in local space and stores it in a target vector
  6201. * @param result defines the target vector
  6202. */
  6203. getScaleToRef(result: Vector3): void;
  6204. /**
  6205. * Set the yaw, pitch, and roll of the bone in local or world space
  6206. * @param yaw The rotation of the bone on the y axis
  6207. * @param pitch The rotation of the bone on the x axis
  6208. * @param roll The rotation of the bone on the z axis
  6209. * @param space The space that the axes of rotation are in
  6210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6211. */
  6212. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6213. /**
  6214. * Add a rotation to the bone on an axis in local or world space
  6215. * @param axis The axis to rotate the bone on
  6216. * @param amount The amount to rotate the bone
  6217. * @param space The space that the axis is in
  6218. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6219. */
  6220. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6221. /**
  6222. * Set the rotation of the bone to a particular axis angle in local or world space
  6223. * @param axis The axis to rotate the bone on
  6224. * @param angle The angle that the bone should be rotated to
  6225. * @param space The space that the axis is in
  6226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6227. */
  6228. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6229. /**
  6230. * Set the euler rotation of the bone in local of world space
  6231. * @param rotation The euler rotation that the bone should be set to
  6232. * @param space The space that the rotation is in
  6233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6234. */
  6235. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6236. /**
  6237. * Set the quaternion rotation of the bone in local of world space
  6238. * @param quat The quaternion rotation that the bone should be set to
  6239. * @param space The space that the rotation is in
  6240. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6241. */
  6242. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6243. /**
  6244. * Set the rotation matrix of the bone in local of world space
  6245. * @param rotMat The rotation matrix that the bone should be set to
  6246. * @param space The space that the rotation is in
  6247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6248. */
  6249. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6250. private _rotateWithMatrix;
  6251. private _getNegativeRotationToRef;
  6252. /**
  6253. * Get the position of the bone in local or world space
  6254. * @param space The space that the returned position is in
  6255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6256. * @returns The position of the bone
  6257. */
  6258. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6259. /**
  6260. * Copy the position of the bone to a vector3 in local or world space
  6261. * @param space The space that the returned position is in
  6262. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6263. * @param result The vector3 to copy the position to
  6264. */
  6265. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6266. /**
  6267. * Get the absolute position of the bone (world space)
  6268. * @param mesh The mesh that this bone is attached to
  6269. * @returns The absolute position of the bone
  6270. */
  6271. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6272. /**
  6273. * Copy the absolute position of the bone (world space) to the result param
  6274. * @param mesh The mesh that this bone is attached to
  6275. * @param result The vector3 to copy the absolute position to
  6276. */
  6277. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6278. /**
  6279. * Compute the absolute transforms of this bone and its children
  6280. */
  6281. computeAbsoluteTransforms(): void;
  6282. /**
  6283. * Get the world direction from an axis that is in the local space of the bone
  6284. * @param localAxis The local direction that is used to compute the world direction
  6285. * @param mesh The mesh that this bone is attached to
  6286. * @returns The world direction
  6287. */
  6288. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6289. /**
  6290. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6291. * @param localAxis The local direction that is used to compute the world direction
  6292. * @param mesh The mesh that this bone is attached to
  6293. * @param result The vector3 that the world direction will be copied to
  6294. */
  6295. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6296. /**
  6297. * Get the euler rotation of the bone in local or world space
  6298. * @param space The space that the rotation should be in
  6299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6300. * @returns The euler rotation
  6301. */
  6302. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6303. /**
  6304. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6305. * @param space The space that the rotation should be in
  6306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6307. * @param result The vector3 that the rotation should be copied to
  6308. */
  6309. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6310. /**
  6311. * Get the quaternion rotation of the bone in either local or world space
  6312. * @param space The space that the rotation should be in
  6313. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6314. * @returns The quaternion rotation
  6315. */
  6316. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6317. /**
  6318. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6319. * @param space The space that the rotation should be in
  6320. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6321. * @param result The quaternion that the rotation should be copied to
  6322. */
  6323. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6324. /**
  6325. * Get the rotation matrix of the bone in local or world space
  6326. * @param space The space that the rotation should be in
  6327. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6328. * @returns The rotation matrix
  6329. */
  6330. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6331. /**
  6332. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6333. * @param space The space that the rotation should be in
  6334. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6335. * @param result The quaternion that the rotation should be copied to
  6336. */
  6337. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6338. /**
  6339. * Get the world position of a point that is in the local space of the bone
  6340. * @param position The local position
  6341. * @param mesh The mesh that this bone is attached to
  6342. * @returns The world position
  6343. */
  6344. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6345. /**
  6346. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6347. * @param position The local position
  6348. * @param mesh The mesh that this bone is attached to
  6349. * @param result The vector3 that the world position should be copied to
  6350. */
  6351. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6352. /**
  6353. * Get the local position of a point that is in world space
  6354. * @param position The world position
  6355. * @param mesh The mesh that this bone is attached to
  6356. * @returns The local position
  6357. */
  6358. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6359. /**
  6360. * Get the local position of a point that is in world space and copy it to the result param
  6361. * @param position The world position
  6362. * @param mesh The mesh that this bone is attached to
  6363. * @param result The vector3 that the local position should be copied to
  6364. */
  6365. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6366. }
  6367. }
  6368. declare module BABYLON {
  6369. /**
  6370. * Class used to apply inverse kinematics to bones
  6371. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6372. */
  6373. class BoneIKController {
  6374. private static _tmpVecs;
  6375. private static _tmpQuat;
  6376. private static _tmpMats;
  6377. /**
  6378. * Gets or sets the target mesh
  6379. */
  6380. targetMesh: AbstractMesh;
  6381. /** Gets or sets the mesh used as pole */
  6382. poleTargetMesh: AbstractMesh;
  6383. /**
  6384. * Gets or sets the bone used as pole
  6385. */
  6386. poleTargetBone: Nullable<Bone>;
  6387. /**
  6388. * Gets or sets the target position
  6389. */
  6390. targetPosition: Vector3;
  6391. /**
  6392. * Gets or sets the pole target position
  6393. */
  6394. poleTargetPosition: Vector3;
  6395. /**
  6396. * Gets or sets the pole target local offset
  6397. */
  6398. poleTargetLocalOffset: Vector3;
  6399. /**
  6400. * Gets or sets the pole angle
  6401. */
  6402. poleAngle: number;
  6403. /**
  6404. * Gets or sets the mesh associated with the controller
  6405. */
  6406. mesh: AbstractMesh;
  6407. /**
  6408. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  6409. */
  6410. slerpAmount: number;
  6411. private _bone1Quat;
  6412. private _bone1Mat;
  6413. private _bone2Ang;
  6414. private _bone1;
  6415. private _bone2;
  6416. private _bone1Length;
  6417. private _bone2Length;
  6418. private _maxAngle;
  6419. private _maxReach;
  6420. private _rightHandedSystem;
  6421. private _bendAxis;
  6422. private _slerping;
  6423. private _adjustRoll;
  6424. /**
  6425. * Gets or sets maximum allowed angle
  6426. */
  6427. maxAngle: number;
  6428. /**
  6429. * Creates a new BoneIKController
  6430. * @param mesh defines the mesh to control
  6431. * @param bone defines the bone to control
  6432. * @param options defines options to set up the controller
  6433. */
  6434. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6435. targetMesh?: AbstractMesh;
  6436. poleTargetMesh?: AbstractMesh;
  6437. poleTargetBone?: Bone;
  6438. poleTargetLocalOffset?: Vector3;
  6439. poleAngle?: number;
  6440. bendAxis?: Vector3;
  6441. maxAngle?: number;
  6442. slerpAmount?: number;
  6443. });
  6444. private _setMaxAngle;
  6445. /**
  6446. * Force the controller to update the bones
  6447. */
  6448. update(): void;
  6449. }
  6450. }
  6451. declare module BABYLON {
  6452. /**
  6453. * Class used to make a bone look toward a point in space
  6454. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6455. */
  6456. class BoneLookController {
  6457. private static _tmpVecs;
  6458. private static _tmpQuat;
  6459. private static _tmpMats;
  6460. /**
  6461. * The target Vector3 that the bone will look at
  6462. */
  6463. target: Vector3;
  6464. /**
  6465. * The mesh that the bone is attached to
  6466. */
  6467. mesh: AbstractMesh;
  6468. /**
  6469. * The bone that will be looking to the target
  6470. */
  6471. bone: Bone;
  6472. /**
  6473. * The up axis of the coordinate system that is used when the bone is rotated
  6474. */
  6475. upAxis: Vector3;
  6476. /**
  6477. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6478. */
  6479. upAxisSpace: Space;
  6480. /**
  6481. * Used to make an adjustment to the yaw of the bone
  6482. */
  6483. adjustYaw: number;
  6484. /**
  6485. * Used to make an adjustment to the pitch of the bone
  6486. */
  6487. adjustPitch: number;
  6488. /**
  6489. * Used to make an adjustment to the roll of the bone
  6490. */
  6491. adjustRoll: number;
  6492. /**
  6493. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  6494. */
  6495. slerpAmount: number;
  6496. private _minYaw;
  6497. private _maxYaw;
  6498. private _minPitch;
  6499. private _maxPitch;
  6500. private _minYawSin;
  6501. private _minYawCos;
  6502. private _maxYawSin;
  6503. private _maxYawCos;
  6504. private _midYawConstraint;
  6505. private _minPitchTan;
  6506. private _maxPitchTan;
  6507. private _boneQuat;
  6508. private _slerping;
  6509. private _transformYawPitch;
  6510. private _transformYawPitchInv;
  6511. private _firstFrameSkipped;
  6512. private _yawRange;
  6513. private _fowardAxis;
  6514. /**
  6515. * Gets or sets the minimum yaw angle that the bone can look to
  6516. */
  6517. minYaw: number;
  6518. /**
  6519. * Gets or sets the maximum yaw angle that the bone can look to
  6520. */
  6521. maxYaw: number;
  6522. /**
  6523. * Gets or sets the minimum pitch angle that the bone can look to
  6524. */
  6525. minPitch: number;
  6526. /**
  6527. * Gets or sets the maximum pitch angle that the bone can look to
  6528. */
  6529. maxPitch: number;
  6530. /**
  6531. * Create a BoneLookController
  6532. * @param mesh the mesh that the bone belongs to
  6533. * @param bone the bone that will be looking to the target
  6534. * @param target the target Vector3 to look at
  6535. * @param settings optional settings:
  6536. * * maxYaw: the maximum angle the bone will yaw to
  6537. * * minYaw: the minimum angle the bone will yaw to
  6538. * * maxPitch: the maximum angle the bone will pitch to
  6539. * * minPitch: the minimum angle the bone will yaw to
  6540. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6541. * * upAxis: the up axis of the coordinate system
  6542. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6543. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6544. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6545. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6546. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6547. * * adjustRoll: used to make an adjustment to the roll of the bone
  6548. **/
  6549. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6550. maxYaw?: number;
  6551. minYaw?: number;
  6552. maxPitch?: number;
  6553. minPitch?: number;
  6554. slerpAmount?: number;
  6555. upAxis?: Vector3;
  6556. upAxisSpace?: Space;
  6557. yawAxis?: Vector3;
  6558. pitchAxis?: Vector3;
  6559. adjustYaw?: number;
  6560. adjustPitch?: number;
  6561. adjustRoll?: number;
  6562. });
  6563. /**
  6564. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6565. */
  6566. update(): void;
  6567. private _getAngleDiff;
  6568. private _getAngleBetween;
  6569. private _isAngleBetween;
  6570. }
  6571. }
  6572. declare module BABYLON {
  6573. /**
  6574. * Class used to handle skinning animations
  6575. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6576. */
  6577. class Skeleton implements IAnimatable {
  6578. /** defines the skeleton name */
  6579. name: string;
  6580. /** defines the skeleton Id */
  6581. id: string;
  6582. /**
  6583. * Defines the list of child bones
  6584. */
  6585. bones: Bone[];
  6586. /**
  6587. * Defines an estimate of the dimension of the skeleton at rest
  6588. */
  6589. dimensionsAtRest: Vector3;
  6590. /**
  6591. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6592. */
  6593. needInitialSkinMatrix: boolean;
  6594. /**
  6595. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  6596. */
  6597. overrideMesh: Nullable<AbstractMesh>;
  6598. /**
  6599. * Gets the list of animations attached to this skeleton
  6600. */
  6601. animations: Array<Animation>;
  6602. private _scene;
  6603. private _isDirty;
  6604. private _transformMatrices;
  6605. private _transformMatrixTexture;
  6606. private _meshesWithPoseMatrix;
  6607. private _animatables;
  6608. private _identity;
  6609. private _synchronizedWithMesh;
  6610. private _ranges;
  6611. private _lastAbsoluteTransformsUpdateId;
  6612. private _canUseTextureForBones;
  6613. /** @hidden */
  6614. _numBonesWithLinkedTransformNode: number;
  6615. /**
  6616. * Specifies if the skeleton should be serialized
  6617. */
  6618. doNotSerialize: boolean;
  6619. /**
  6620. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  6621. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  6622. */
  6623. useTextureToStoreBoneMatrices: boolean;
  6624. private _animationPropertiesOverride;
  6625. /**
  6626. * Gets or sets the animation properties override
  6627. */
  6628. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6629. /**
  6630. * An observable triggered before computing the skeleton's matrices
  6631. */
  6632. onBeforeComputeObservable: Observable<Skeleton>;
  6633. /**
  6634. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  6635. */
  6636. readonly isUsingTextureForMatrices: boolean;
  6637. /**
  6638. * Creates a new skeleton
  6639. * @param name defines the skeleton name
  6640. * @param id defines the skeleton Id
  6641. * @param scene defines the hosting scene
  6642. */
  6643. constructor(
  6644. /** defines the skeleton name */
  6645. name: string,
  6646. /** defines the skeleton Id */
  6647. id: string, scene: Scene);
  6648. /**
  6649. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6650. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6651. * @returns a Float32Array containing matrices data
  6652. */
  6653. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6654. /**
  6655. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  6656. * @returns a raw texture containing the data
  6657. */
  6658. getTransformMatrixTexture(): Nullable<RawTexture>;
  6659. /**
  6660. * Gets the current hosting scene
  6661. * @returns a scene object
  6662. */
  6663. getScene(): Scene;
  6664. /**
  6665. * Gets a string representing the current skeleton data
  6666. * @param fullDetails defines a boolean indicating if we want a verbose version
  6667. * @returns a string representing the current skeleton data
  6668. */
  6669. toString(fullDetails?: boolean): string;
  6670. /**
  6671. * Get bone's index searching by name
  6672. * @param name defines bone's name to search for
  6673. * @return the indice of the bone. Returns -1 if not found
  6674. */
  6675. getBoneIndexByName(name: string): number;
  6676. /**
  6677. * Creater a new animation range
  6678. * @param name defines the name of the range
  6679. * @param from defines the start key
  6680. * @param to defines the end key
  6681. */
  6682. createAnimationRange(name: string, from: number, to: number): void;
  6683. /**
  6684. * Delete a specific animation range
  6685. * @param name defines the name of the range
  6686. * @param deleteFrames defines if frames must be removed as well
  6687. */
  6688. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6689. /**
  6690. * Gets a specific animation range
  6691. * @param name defines the name of the range to look for
  6692. * @returns the requested animation range or null if not found
  6693. */
  6694. getAnimationRange(name: string): Nullable<AnimationRange>;
  6695. /**
  6696. * Gets the list of all animation ranges defined on this skeleton
  6697. * @returns an array
  6698. */
  6699. getAnimationRanges(): Nullable<AnimationRange>[];
  6700. /**
  6701. * Copy animation range from a source skeleton.
  6702. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6703. * @param source defines the source skeleton
  6704. * @param name defines the name of the range to copy
  6705. * @param rescaleAsRequired defines if rescaling must be applied if required
  6706. * @returns true if operation was successful
  6707. */
  6708. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6709. /**
  6710. * Forces the skeleton to go to rest pose
  6711. */
  6712. returnToRest(): void;
  6713. private _getHighestAnimationFrame;
  6714. /**
  6715. * Begin a specific animation range
  6716. * @param name defines the name of the range to start
  6717. * @param loop defines if looping must be turned on (false by default)
  6718. * @param speedRatio defines the speed ratio to apply (1 by default)
  6719. * @param onAnimationEnd defines a callback which will be called when animation will end
  6720. * @returns a new animatable
  6721. */
  6722. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6723. /** @hidden */
  6724. _markAsDirty(): void;
  6725. /** @hidden */
  6726. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6727. /** @hidden */
  6728. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6729. private _computeTransformMatrices;
  6730. /**
  6731. * Build all resources required to render a skeleton
  6732. */
  6733. prepare(): void;
  6734. /**
  6735. * Gets the list of animatables currently running for this skeleton
  6736. * @returns an array of animatables
  6737. */
  6738. getAnimatables(): IAnimatable[];
  6739. /**
  6740. * Clone the current skeleton
  6741. * @param name defines the name of the new skeleton
  6742. * @param id defines the id of the enw skeleton
  6743. * @returns the new skeleton
  6744. */
  6745. clone(name: string, id: string): Skeleton;
  6746. /**
  6747. * Enable animation blending for this skeleton
  6748. * @param blendingSpeed defines the blending speed to apply
  6749. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6750. */
  6751. enableBlending(blendingSpeed?: number): void;
  6752. /**
  6753. * Releases all resources associated with the current skeleton
  6754. */
  6755. dispose(): void;
  6756. /**
  6757. * Serialize the skeleton in a JSON object
  6758. * @returns a JSON object
  6759. */
  6760. serialize(): any;
  6761. /**
  6762. * Creates a new skeleton from serialized data
  6763. * @param parsedSkeleton defines the serialized data
  6764. * @param scene defines the hosting scene
  6765. * @returns a new skeleton
  6766. */
  6767. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6768. /**
  6769. * Compute all node absolute transforms
  6770. * @param forceUpdate defines if computation must be done even if cache is up to date
  6771. */
  6772. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6773. /**
  6774. * Gets the root pose matrix
  6775. * @returns a matrix
  6776. */
  6777. getPoseMatrix(): Nullable<Matrix>;
  6778. /**
  6779. * Sorts bones per internal index
  6780. */
  6781. sortBones(): void;
  6782. private _sortBones;
  6783. }
  6784. }
  6785. declare module BABYLON {
  6786. /** @hidden */
  6787. class Collider {
  6788. /** Define if a collision was found */
  6789. collisionFound: boolean;
  6790. /**
  6791. * Define last intersection point in local space
  6792. */
  6793. intersectionPoint: Vector3;
  6794. /**
  6795. * Define last collided mesh
  6796. */
  6797. collidedMesh: Nullable<AbstractMesh>;
  6798. private _collisionPoint;
  6799. private _planeIntersectionPoint;
  6800. private _tempVector;
  6801. private _tempVector2;
  6802. private _tempVector3;
  6803. private _tempVector4;
  6804. private _edge;
  6805. private _baseToVertex;
  6806. private _destinationPoint;
  6807. private _slidePlaneNormal;
  6808. private _displacementVector;
  6809. /** @hidden */
  6810. _radius: Vector3;
  6811. /** @hidden */
  6812. _retry: number;
  6813. private _velocity;
  6814. private _basePoint;
  6815. private _epsilon;
  6816. /** @hidden */
  6817. _velocityWorldLength: number;
  6818. /** @hidden */
  6819. _basePointWorld: Vector3;
  6820. private _velocityWorld;
  6821. private _normalizedVelocity;
  6822. /** @hidden */
  6823. _initialVelocity: Vector3;
  6824. /** @hidden */
  6825. _initialPosition: Vector3;
  6826. private _nearestDistance;
  6827. private _collisionMask;
  6828. collisionMask: number;
  6829. /**
  6830. * Gets the plane normal used to compute the sliding response (in local space)
  6831. */
  6832. readonly slidePlaneNormal: Vector3;
  6833. /** @hidden */
  6834. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6835. /** @hidden */
  6836. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6837. /** @hidden */
  6838. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6839. /** @hidden */
  6840. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6841. /** @hidden */
  6842. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6843. /** @hidden */
  6844. _getResponse(pos: Vector3, vel: Vector3): void;
  6845. }
  6846. }
  6847. declare module BABYLON {
  6848. /** @hidden */
  6849. var CollisionWorker: string;
  6850. /** @hidden */
  6851. interface ICollisionCoordinator {
  6852. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6853. init(scene: Scene): void;
  6854. destroy(): void;
  6855. onMeshAdded(mesh: AbstractMesh): void;
  6856. onMeshUpdated(mesh: AbstractMesh): void;
  6857. onMeshRemoved(mesh: AbstractMesh): void;
  6858. onGeometryAdded(geometry: Geometry): void;
  6859. onGeometryUpdated(geometry: Geometry): void;
  6860. onGeometryDeleted(geometry: Geometry): void;
  6861. }
  6862. /** @hidden */
  6863. interface SerializedMesh {
  6864. id: string;
  6865. name: string;
  6866. uniqueId: number;
  6867. geometryId: Nullable<string>;
  6868. sphereCenter: Array<number>;
  6869. sphereRadius: number;
  6870. boxMinimum: Array<number>;
  6871. boxMaximum: Array<number>;
  6872. worldMatrixFromCache: any;
  6873. subMeshes: Array<SerializedSubMesh>;
  6874. checkCollisions: boolean;
  6875. }
  6876. /** @hidden */
  6877. interface SerializedSubMesh {
  6878. position: number;
  6879. verticesStart: number;
  6880. verticesCount: number;
  6881. indexStart: number;
  6882. indexCount: number;
  6883. hasMaterial: boolean;
  6884. sphereCenter: Array<number>;
  6885. sphereRadius: number;
  6886. boxMinimum: Array<number>;
  6887. boxMaximum: Array<number>;
  6888. }
  6889. /**
  6890. * Interface describing the value associated with a geometry.
  6891. * @hidden
  6892. */
  6893. interface SerializedGeometry {
  6894. /**
  6895. * Defines the unique ID of the geometry
  6896. */
  6897. id: string;
  6898. /**
  6899. * Defines the array containing the positions
  6900. */
  6901. positions: Float32Array;
  6902. /**
  6903. * Defines the array containing the indices
  6904. */
  6905. indices: Uint32Array;
  6906. /**
  6907. * Defines the array containing the normals
  6908. */
  6909. normals: Float32Array;
  6910. }
  6911. /** @hidden */
  6912. interface BabylonMessage {
  6913. taskType: WorkerTaskType;
  6914. payload: InitPayload | CollidePayload | UpdatePayload;
  6915. }
  6916. /** @hidden */
  6917. interface SerializedColliderToWorker {
  6918. position: Array<number>;
  6919. velocity: Array<number>;
  6920. radius: Array<number>;
  6921. }
  6922. /** Defines supported task for worker process */
  6923. enum WorkerTaskType {
  6924. /** Initialization */
  6925. INIT = 0,
  6926. /** Update of geometry */
  6927. UPDATE = 1,
  6928. /** Evaluate collision */
  6929. COLLIDE = 2
  6930. }
  6931. /** @hidden */
  6932. interface WorkerReply {
  6933. error: WorkerReplyType;
  6934. taskType: WorkerTaskType;
  6935. payload?: any;
  6936. }
  6937. /** @hidden */
  6938. interface CollisionReplyPayload {
  6939. newPosition: Array<number>;
  6940. collisionId: number;
  6941. collidedMeshUniqueId: number;
  6942. }
  6943. /** @hidden */
  6944. interface InitPayload {
  6945. }
  6946. /** @hidden */
  6947. interface CollidePayload {
  6948. collisionId: number;
  6949. collider: SerializedColliderToWorker;
  6950. maximumRetry: number;
  6951. excludedMeshUniqueId: Nullable<number>;
  6952. }
  6953. /** @hidden */
  6954. interface UpdatePayload {
  6955. updatedMeshes: {
  6956. [n: number]: SerializedMesh;
  6957. };
  6958. updatedGeometries: {
  6959. [s: string]: SerializedGeometry;
  6960. };
  6961. removedMeshes: Array<number>;
  6962. removedGeometries: Array<string>;
  6963. }
  6964. /** Defines kind of replies returned by worker */
  6965. enum WorkerReplyType {
  6966. /** Success */
  6967. SUCCESS = 0,
  6968. /** Unkown error */
  6969. UNKNOWN_ERROR = 1
  6970. }
  6971. /** @hidden */
  6972. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6973. private _scene;
  6974. private _scaledPosition;
  6975. private _scaledVelocity;
  6976. private _collisionsCallbackArray;
  6977. private _init;
  6978. private _runningUpdated;
  6979. private _worker;
  6980. private _addUpdateMeshesList;
  6981. private _addUpdateGeometriesList;
  6982. private _toRemoveMeshesArray;
  6983. private _toRemoveGeometryArray;
  6984. constructor();
  6985. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  6986. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  6987. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6988. init(scene: Scene): void;
  6989. destroy(): void;
  6990. onMeshAdded(mesh: AbstractMesh): void;
  6991. onMeshUpdated: (transformNode: TransformNode) => void;
  6992. onMeshRemoved(mesh: AbstractMesh): void;
  6993. onGeometryAdded(geometry: Geometry): void;
  6994. onGeometryUpdated: (geometry: Geometry) => void;
  6995. onGeometryDeleted(geometry: Geometry): void;
  6996. private _afterRender;
  6997. private _onMessageFromWorker;
  6998. }
  6999. /** @hidden */
  7000. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  7001. private _scene;
  7002. private _scaledPosition;
  7003. private _scaledVelocity;
  7004. private _finalPosition;
  7005. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  7006. init(scene: Scene): void;
  7007. destroy(): void;
  7008. onMeshAdded(mesh: AbstractMesh): void;
  7009. onMeshUpdated(mesh: AbstractMesh): void;
  7010. onMeshRemoved(mesh: AbstractMesh): void;
  7011. onGeometryAdded(geometry: Geometry): void;
  7012. onGeometryUpdated(geometry: Geometry): void;
  7013. onGeometryDeleted(geometry: Geometry): void;
  7014. private _collideWithWorld;
  7015. }
  7016. }
  7017. declare function importScripts(...urls: string[]): void;
  7018. declare const safePostMessage: any;
  7019. declare module BABYLON {
  7020. /** @hidden */
  7021. var WorkerIncluded: boolean;
  7022. /** @hidden */
  7023. class CollisionCache {
  7024. private _meshes;
  7025. private _geometries;
  7026. getMeshes(): {
  7027. [n: number]: SerializedMesh;
  7028. };
  7029. getGeometries(): {
  7030. [s: number]: SerializedGeometry;
  7031. };
  7032. getMesh(id: any): SerializedMesh;
  7033. addMesh(mesh: SerializedMesh): void;
  7034. removeMesh(uniqueId: number): void;
  7035. getGeometry(id: string): SerializedGeometry;
  7036. addGeometry(geometry: SerializedGeometry): void;
  7037. removeGeometry(id: string): void;
  7038. }
  7039. /** @hidden */
  7040. class CollideWorker {
  7041. collider: Collider;
  7042. private _collisionCache;
  7043. private finalPosition;
  7044. private collisionsScalingMatrix;
  7045. private collisionTranformationMatrix;
  7046. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  7047. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  7048. private checkCollision;
  7049. private processCollisionsForSubMeshes;
  7050. private collideForSubMesh;
  7051. private checkSubmeshCollision;
  7052. }
  7053. /** @hidden */
  7054. interface ICollisionDetector {
  7055. onInit(payload: InitPayload): void;
  7056. onUpdate(payload: UpdatePayload): void;
  7057. onCollision(payload: CollidePayload): void;
  7058. }
  7059. /** @hidden */
  7060. class CollisionDetectorTransferable implements ICollisionDetector {
  7061. private _collisionCache;
  7062. onInit(payload: InitPayload): void;
  7063. onUpdate(payload: UpdatePayload): void;
  7064. onCollision(payload: CollidePayload): void;
  7065. }
  7066. }
  7067. declare module BABYLON {
  7068. /**
  7069. * @hidden
  7070. */
  7071. class IntersectionInfo {
  7072. bu: Nullable<number>;
  7073. bv: Nullable<number>;
  7074. distance: number;
  7075. faceId: number;
  7076. subMeshId: number;
  7077. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7078. }
  7079. /**
  7080. * Information about the result of picking within a scene
  7081. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  7082. */
  7083. class PickingInfo {
  7084. /**
  7085. * If the pick collided with an object
  7086. */
  7087. hit: boolean;
  7088. /**
  7089. * Distance away where the pick collided
  7090. */
  7091. distance: number;
  7092. /**
  7093. * The location of pick collision
  7094. */
  7095. pickedPoint: Nullable<Vector3>;
  7096. /**
  7097. * The mesh corresponding the the pick collision
  7098. */
  7099. pickedMesh: Nullable<AbstractMesh>;
  7100. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  7101. bu: number;
  7102. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  7103. bv: number;
  7104. /** The id of the face on the mesh that was picked */
  7105. faceId: number;
  7106. /** Id of the the submesh that was picked */
  7107. subMeshId: number;
  7108. /** If a sprite was picked, this will be the sprite the pick collided with */
  7109. pickedSprite: Nullable<Sprite>;
  7110. /**
  7111. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  7112. */
  7113. originMesh: Nullable<AbstractMesh>;
  7114. /**
  7115. * The ray that was used to perform the picking.
  7116. */
  7117. ray: Nullable<Ray>;
  7118. /**
  7119. * Gets the normal correspodning to the face the pick collided with
  7120. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  7121. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  7122. * @returns The normal correspodning to the face the pick collided with
  7123. */
  7124. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  7125. /**
  7126. * Gets the texture coordinates of where the pick occured
  7127. * @returns the vector containing the coordnates of the texture
  7128. */
  7129. getTextureCoordinates(): Nullable<Vector2>;
  7130. }
  7131. }
  7132. declare module BABYLON {
  7133. /**
  7134. * Class used to store bounding box information
  7135. */
  7136. class BoundingBox implements ICullable {
  7137. /**
  7138. * Gets the 8 vectors representing the bounding box in local space
  7139. */
  7140. readonly vectors: Vector3[];
  7141. /**
  7142. * Gets the center of the bounding box in local space
  7143. */
  7144. readonly center: Vector3;
  7145. /**
  7146. * Gets the center of the bounding box in world space
  7147. */
  7148. readonly centerWorld: Vector3;
  7149. /**
  7150. * Gets the extend size in local space
  7151. */
  7152. readonly extendSize: Vector3;
  7153. /**
  7154. * Gets the extend size in world space
  7155. */
  7156. readonly extendSizeWorld: Vector3;
  7157. /**
  7158. * Gets the OBB (object bounding box) directions
  7159. */
  7160. readonly directions: Vector3[];
  7161. /**
  7162. * Gets the 8 vectors representing the bounding box in world space
  7163. */
  7164. readonly vectorsWorld: Vector3[];
  7165. /**
  7166. * Gets the minimum vector in world space
  7167. */
  7168. readonly minimumWorld: Vector3;
  7169. /**
  7170. * Gets the maximum vector in world space
  7171. */
  7172. readonly maximumWorld: Vector3;
  7173. /**
  7174. * Gets the minimum vector in local space
  7175. */
  7176. readonly minimum: Vector3;
  7177. /**
  7178. * Gets the maximum vector in local space
  7179. */
  7180. readonly maximum: Vector3;
  7181. private _worldMatrix;
  7182. private static readonly TmpVector3;
  7183. /**
  7184. * @hidden
  7185. */
  7186. _tag: number;
  7187. /**
  7188. * Creates a new bounding box
  7189. * @param min defines the minimum vector (in local space)
  7190. * @param max defines the maximum vector (in local space)
  7191. * @param worldMatrix defines the new world matrix
  7192. */
  7193. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7194. /**
  7195. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7196. * @param min defines the new minimum vector (in local space)
  7197. * @param max defines the new maximum vector (in local space)
  7198. * @param worldMatrix defines the new world matrix
  7199. */
  7200. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7201. /**
  7202. * Scale the current bounding box by applying a scale factor
  7203. * @param factor defines the scale factor to apply
  7204. * @returns the current bounding box
  7205. */
  7206. scale(factor: number): BoundingBox;
  7207. /**
  7208. * Gets the world matrix of the bounding box
  7209. * @returns a matrix
  7210. */
  7211. getWorldMatrix(): DeepImmutable<Matrix>;
  7212. /** @hidden */
  7213. _update(world: DeepImmutable<Matrix>): void;
  7214. /**
  7215. * Tests if the bounding box is intersecting the frustum planes
  7216. * @param frustumPlanes defines the frustum planes to test
  7217. * @returns true if there is an intersection
  7218. */
  7219. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7220. /**
  7221. * Tests if the bounding box is entirely inside the frustum planes
  7222. * @param frustumPlanes defines the frustum planes to test
  7223. * @returns true if there is an inclusion
  7224. */
  7225. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7226. /**
  7227. * Tests if a point is inside the bounding box
  7228. * @param point defines the point to test
  7229. * @returns true if the point is inside the bounding box
  7230. */
  7231. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7232. /**
  7233. * Tests if the bounding box intersects with a bounding sphere
  7234. * @param sphere defines the sphere to test
  7235. * @returns true if there is an intersection
  7236. */
  7237. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7238. /**
  7239. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7240. * @param min defines the min vector to use
  7241. * @param max defines the max vector to use
  7242. * @returns true if there is an intersection
  7243. */
  7244. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7245. /**
  7246. * Tests if two bounding boxes are intersections
  7247. * @param box0 defines the first box to test
  7248. * @param box1 defines the second box to test
  7249. * @returns true if there is an intersection
  7250. */
  7251. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7252. /**
  7253. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7254. * @param minPoint defines the minimum vector of the bounding box
  7255. * @param maxPoint defines the maximum vector of the bounding box
  7256. * @param sphereCenter defines the sphere center
  7257. * @param sphereRadius defines the sphere radius
  7258. * @returns true if there is an intersection
  7259. */
  7260. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7261. /**
  7262. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7263. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7264. * @param frustumPlanes defines the frustum planes to test
  7265. * @return true if there is an inclusion
  7266. */
  7267. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7268. /**
  7269. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7270. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7271. * @param frustumPlanes defines the frustum planes to test
  7272. * @return true if there is an intersection
  7273. */
  7274. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7275. }
  7276. }
  7277. declare module BABYLON {
  7278. /**
  7279. * Interface for cullable objects
  7280. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7281. */
  7282. interface ICullable {
  7283. /**
  7284. * Checks if the object or part of the object is in the frustum
  7285. * @param frustumPlanes Camera near/planes
  7286. * @returns true if the object is in frustum otherwise false
  7287. */
  7288. isInFrustum(frustumPlanes: Plane[]): boolean;
  7289. /**
  7290. * Checks if a cullable object (mesh...) is in the camera frustum
  7291. * Unlike isInFrustum this cheks the full bounding box
  7292. * @param frustumPlanes Camera near/planes
  7293. * @returns true if the object is in frustum otherwise false
  7294. */
  7295. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7296. }
  7297. /**
  7298. * Info for a bounding data of a mesh
  7299. */
  7300. class BoundingInfo implements ICullable {
  7301. /**
  7302. * Bounding box for the mesh
  7303. */
  7304. readonly boundingBox: BoundingBox;
  7305. /**
  7306. * Bounding sphere for the mesh
  7307. */
  7308. readonly boundingSphere: BoundingSphere;
  7309. private _isLocked;
  7310. private static readonly TmpVector3;
  7311. /**
  7312. * Constructs bounding info
  7313. * @param minimum min vector of the bounding box/sphere
  7314. * @param maximum max vector of the bounding box/sphere
  7315. * @param worldMatrix defines the new world matrix
  7316. */
  7317. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7318. /**
  7319. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7320. * @param min defines the new minimum vector (in local space)
  7321. * @param max defines the new maximum vector (in local space)
  7322. * @param worldMatrix defines the new world matrix
  7323. */
  7324. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7325. /**
  7326. * min vector of the bounding box/sphere
  7327. */
  7328. readonly minimum: Vector3;
  7329. /**
  7330. * max vector of the bounding box/sphere
  7331. */
  7332. readonly maximum: Vector3;
  7333. /**
  7334. * If the info is locked and won't be updated to avoid perf overhead
  7335. */
  7336. isLocked: boolean;
  7337. /**
  7338. * Updates the bounding sphere and box
  7339. * @param world world matrix to be used to update
  7340. */
  7341. update(world: DeepImmutable<Matrix>): void;
  7342. /**
  7343. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7344. * @param center New center of the bounding info
  7345. * @param extend New extend of the bounding info
  7346. * @returns the current bounding info
  7347. */
  7348. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7349. /**
  7350. * Scale the current bounding info by applying a scale factor
  7351. * @param factor defines the scale factor to apply
  7352. * @returns the current bounding info
  7353. */
  7354. scale(factor: number): BoundingInfo;
  7355. /**
  7356. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7357. * @param frustumPlanes defines the frustum to test
  7358. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  7359. * @returns true if the bounding info is in the frustum planes
  7360. */
  7361. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7362. /**
  7363. * Gets the world distance between the min and max points of the bounding box
  7364. */
  7365. readonly diagonalLength: number;
  7366. /**
  7367. * Checks if a cullable object (mesh...) is in the camera frustum
  7368. * Unlike isInFrustum this cheks the full bounding box
  7369. * @param frustumPlanes Camera near/planes
  7370. * @returns true if the object is in frustum otherwise false
  7371. */
  7372. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7373. /** @hidden */
  7374. _checkCollision(collider: Collider): boolean;
  7375. /**
  7376. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7377. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7378. * @param point the point to check intersection with
  7379. * @returns if the point intersects
  7380. */
  7381. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7382. /**
  7383. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7384. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7385. * @param boundingInfo the bounding info to check intersection with
  7386. * @param precise if the intersection should be done using OBB
  7387. * @returns if the bounding info intersects
  7388. */
  7389. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7390. }
  7391. }
  7392. declare module BABYLON {
  7393. /**
  7394. * Class used to store bounding sphere information
  7395. */
  7396. class BoundingSphere {
  7397. /**
  7398. * Gets the center of the bounding sphere in local space
  7399. */
  7400. readonly center: Vector3;
  7401. /**
  7402. * Radius of the bounding sphere in local space
  7403. */
  7404. radius: number;
  7405. /**
  7406. * Gets the center of the bounding sphere in world space
  7407. */
  7408. readonly centerWorld: Vector3;
  7409. /**
  7410. * Radius of the bounding sphere in world space
  7411. */
  7412. radiusWorld: number;
  7413. /**
  7414. * Gets the minimum vector in local space
  7415. */
  7416. readonly minimum: Vector3;
  7417. /**
  7418. * Gets the maximum vector in local space
  7419. */
  7420. readonly maximum: Vector3;
  7421. private _worldMatrix;
  7422. private static readonly TmpVector3;
  7423. /**
  7424. * Creates a new bounding sphere
  7425. * @param min defines the minimum vector (in local space)
  7426. * @param max defines the maximum vector (in local space)
  7427. * @param worldMatrix defines the new world matrix
  7428. */
  7429. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7430. /**
  7431. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7432. * @param min defines the new minimum vector (in local space)
  7433. * @param max defines the new maximum vector (in local space)
  7434. * @param worldMatrix defines the new world matrix
  7435. */
  7436. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7437. /**
  7438. * Scale the current bounding sphere by applying a scale factor
  7439. * @param factor defines the scale factor to apply
  7440. * @returns the current bounding box
  7441. */
  7442. scale(factor: number): BoundingSphere;
  7443. /**
  7444. * Gets the world matrix of the bounding box
  7445. * @returns a matrix
  7446. */
  7447. getWorldMatrix(): DeepImmutable<Matrix>;
  7448. /** @hidden */
  7449. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7450. /**
  7451. * Tests if the bounding sphere is intersecting the frustum planes
  7452. * @param frustumPlanes defines the frustum planes to test
  7453. * @returns true if there is an intersection
  7454. */
  7455. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7456. /**
  7457. * Tests if a point is inside the bounding sphere
  7458. * @param point defines the point to test
  7459. * @returns true if the point is inside the bounding sphere
  7460. */
  7461. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7462. /**
  7463. * Checks if two sphere intersct
  7464. * @param sphere0 sphere 0
  7465. * @param sphere1 sphere 1
  7466. * @returns true if the speres intersect
  7467. */
  7468. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7469. }
  7470. }
  7471. declare module BABYLON {
  7472. /**
  7473. * Class representing a ray with position and direction
  7474. */
  7475. class Ray {
  7476. /** origin point */
  7477. origin: Vector3;
  7478. /** direction */
  7479. direction: Vector3;
  7480. /** length of the ray */
  7481. length: number;
  7482. private static readonly TmpVector3;
  7483. private _tmpRay;
  7484. /**
  7485. * Creates a new ray
  7486. * @param origin origin point
  7487. * @param direction direction
  7488. * @param length length of the ray
  7489. */
  7490. constructor(
  7491. /** origin point */
  7492. origin: Vector3,
  7493. /** direction */
  7494. direction: Vector3,
  7495. /** length of the ray */
  7496. length?: number);
  7497. /**
  7498. * Checks if the ray intersects a box
  7499. * @param minimum bound of the box
  7500. * @param maximum bound of the box
  7501. * @param intersectionTreshold extra extend to be added to the box in all direction
  7502. * @returns if the box was hit
  7503. */
  7504. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  7505. /**
  7506. * Checks if the ray intersects a box
  7507. * @param box the bounding box to check
  7508. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  7509. * @returns if the box was hit
  7510. */
  7511. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  7512. /**
  7513. * If the ray hits a sphere
  7514. * @param sphere the bounding sphere to check
  7515. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  7516. * @returns true if it hits the sphere
  7517. */
  7518. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  7519. /**
  7520. * If the ray hits a triange
  7521. * @param vertex0 triangle vertex
  7522. * @param vertex1 triangle vertex
  7523. * @param vertex2 triangle vertex
  7524. * @returns intersection information if hit
  7525. */
  7526. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  7527. /**
  7528. * Checks if ray intersects a plane
  7529. * @param plane the plane to check
  7530. * @returns the distance away it was hit
  7531. */
  7532. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  7533. /**
  7534. * Checks if ray intersects a mesh
  7535. * @param mesh the mesh to check
  7536. * @param fastCheck if only the bounding box should checked
  7537. * @returns picking info of the intersecton
  7538. */
  7539. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  7540. /**
  7541. * Checks if ray intersects a mesh
  7542. * @param meshes the meshes to check
  7543. * @param fastCheck if only the bounding box should checked
  7544. * @param results array to store result in
  7545. * @returns Array of picking infos
  7546. */
  7547. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  7548. private _comparePickingInfo;
  7549. private static smallnum;
  7550. private static rayl;
  7551. /**
  7552. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  7553. * @param sega the first point of the segment to test the intersection against
  7554. * @param segb the second point of the segment to test the intersection against
  7555. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  7556. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  7557. */
  7558. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  7559. /**
  7560. * Update the ray from viewport position
  7561. * @param x position
  7562. * @param y y position
  7563. * @param viewportWidth viewport width
  7564. * @param viewportHeight viewport height
  7565. * @param world world matrix
  7566. * @param view view matrix
  7567. * @param projection projection matrix
  7568. * @returns this ray updated
  7569. */
  7570. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  7571. /**
  7572. * Creates a ray with origin and direction of 0,0,0
  7573. * @returns the new ray
  7574. */
  7575. static Zero(): Ray;
  7576. /**
  7577. * Creates a new ray from screen space and viewport
  7578. * @param x position
  7579. * @param y y position
  7580. * @param viewportWidth viewport width
  7581. * @param viewportHeight viewport height
  7582. * @param world world matrix
  7583. * @param view view matrix
  7584. * @param projection projection matrix
  7585. * @returns new ray
  7586. */
  7587. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  7588. /**
  7589. * 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
  7590. * transformed to the given world matrix.
  7591. * @param origin The origin point
  7592. * @param end The end point
  7593. * @param world a matrix to transform the ray to. Default is the identity matrix.
  7594. * @returns the new ray
  7595. */
  7596. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  7597. /**
  7598. * Transforms a ray by a matrix
  7599. * @param ray ray to transform
  7600. * @param matrix matrix to apply
  7601. * @returns the resulting new ray
  7602. */
  7603. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  7604. /**
  7605. * Transforms a ray by a matrix
  7606. * @param ray ray to transform
  7607. * @param matrix matrix to apply
  7608. * @param result ray to store result in
  7609. */
  7610. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  7611. }
  7612. }
  7613. declare module BABYLON {
  7614. /**
  7615. * This represents an orbital type of camera.
  7616. *
  7617. * 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.
  7618. * 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.
  7619. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  7620. */
  7621. class ArcRotateCamera extends TargetCamera {
  7622. /**
  7623. * Defines the rotation angle of the camera along the longitudinal axis.
  7624. */
  7625. alpha: number;
  7626. /**
  7627. * Defines the rotation angle of the camera along the latitudinal axis.
  7628. */
  7629. beta: number;
  7630. /**
  7631. * Defines the radius of the camera from it s target point.
  7632. */
  7633. radius: number;
  7634. protected _target: Vector3;
  7635. protected _targetHost: Nullable<AbstractMesh>;
  7636. /**
  7637. * Defines the target point of the camera.
  7638. * The camera looks towards it form the radius distance.
  7639. */
  7640. target: Vector3;
  7641. /**
  7642. * Current inertia value on the longitudinal axis.
  7643. * The bigger this number the longer it will take for the camera to stop.
  7644. */
  7645. inertialAlphaOffset: number;
  7646. /**
  7647. * Current inertia value on the latitudinal axis.
  7648. * The bigger this number the longer it will take for the camera to stop.
  7649. */
  7650. inertialBetaOffset: number;
  7651. /**
  7652. * Current inertia value on the radius axis.
  7653. * The bigger this number the longer it will take for the camera to stop.
  7654. */
  7655. inertialRadiusOffset: number;
  7656. /**
  7657. * Minimum allowed angle on the longitudinal axis.
  7658. * This can help limiting how the Camera is able to move in the scene.
  7659. */
  7660. lowerAlphaLimit: Nullable<number>;
  7661. /**
  7662. * Maximum allowed angle on the longitudinal axis.
  7663. * This can help limiting how the Camera is able to move in the scene.
  7664. */
  7665. upperAlphaLimit: Nullable<number>;
  7666. /**
  7667. * Minimum allowed angle on the latitudinal axis.
  7668. * This can help limiting how the Camera is able to move in the scene.
  7669. */
  7670. lowerBetaLimit: number;
  7671. /**
  7672. * Maximum allowed angle on the latitudinal axis.
  7673. * This can help limiting how the Camera is able to move in the scene.
  7674. */
  7675. upperBetaLimit: number;
  7676. /**
  7677. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  7678. * This can help limiting how the Camera is able to move in the scene.
  7679. */
  7680. lowerRadiusLimit: Nullable<number>;
  7681. /**
  7682. * Maximum allowed distance of the camera to the target (The camera can not get further).
  7683. * This can help limiting how the Camera is able to move in the scene.
  7684. */
  7685. upperRadiusLimit: Nullable<number>;
  7686. /**
  7687. * Defines the current inertia value used during panning of the camera along the X axis.
  7688. */
  7689. inertialPanningX: number;
  7690. /**
  7691. * Defines the current inertia value used during panning of the camera along the Y axis.
  7692. */
  7693. inertialPanningY: number;
  7694. /**
  7695. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  7696. * Basically if your fingers moves away from more than this distance you will be considered
  7697. * in pinch mode.
  7698. */
  7699. pinchToPanMaxDistance: number;
  7700. /**
  7701. * Defines the maximum distance the camera can pan.
  7702. * This could help keeping the cammera always in your scene.
  7703. */
  7704. panningDistanceLimit: Nullable<number>;
  7705. /**
  7706. * Defines the target of the camera before paning.
  7707. */
  7708. panningOriginTarget: Vector3;
  7709. /**
  7710. * Defines the value of the inertia used during panning.
  7711. * 0 would mean stop inertia and one would mean no decelleration at all.
  7712. */
  7713. panningInertia: number;
  7714. /**
  7715. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  7716. */
  7717. angularSensibilityX: number;
  7718. /**
  7719. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  7720. */
  7721. angularSensibilityY: number;
  7722. /**
  7723. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  7724. */
  7725. pinchPrecision: number;
  7726. /**
  7727. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  7728. * It will be used instead of pinchDeltaPrecision if different from 0.
  7729. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7730. */
  7731. pinchDeltaPercentage: number;
  7732. /**
  7733. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  7734. */
  7735. panningSensibility: number;
  7736. /**
  7737. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  7738. */
  7739. keysUp: number[];
  7740. /**
  7741. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  7742. */
  7743. keysDown: number[];
  7744. /**
  7745. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  7746. */
  7747. keysLeft: number[];
  7748. /**
  7749. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  7750. */
  7751. keysRight: number[];
  7752. /**
  7753. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  7754. */
  7755. wheelPrecision: number;
  7756. /**
  7757. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  7758. * It will be used instead of pinchDeltaPrecision if different from 0.
  7759. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7760. */
  7761. wheelDeltaPercentage: number;
  7762. /**
  7763. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  7764. */
  7765. zoomOnFactor: number;
  7766. /**
  7767. * Defines a screen offset for the camera position.
  7768. */
  7769. targetScreenOffset: Vector2;
  7770. /**
  7771. * Allows the camera to be completely reversed.
  7772. * If false the camera can not arrive upside down.
  7773. */
  7774. allowUpsideDown: boolean;
  7775. /**
  7776. * Define if double tap/click is used to restore the previously saved state of the camera.
  7777. */
  7778. useInputToRestoreState: boolean;
  7779. /** @hidden */
  7780. _viewMatrix: Matrix;
  7781. /** @hidden */
  7782. _useCtrlForPanning: boolean;
  7783. /** @hidden */
  7784. _panningMouseButton: number;
  7785. /**
  7786. * Defines the inpute associated to the camera.
  7787. */
  7788. inputs: ArcRotateCameraInputsManager;
  7789. /** @hidden */
  7790. _reset: () => void;
  7791. /**
  7792. * Defines the allowed panning axis.
  7793. */
  7794. panningAxis: Vector3;
  7795. protected _localDirection: Vector3;
  7796. protected _transformedDirection: Vector3;
  7797. private _bouncingBehavior;
  7798. /**
  7799. * Gets the bouncing behavior of the camera if it has been enabled.
  7800. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7801. */
  7802. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  7803. /**
  7804. * Defines if the bouncing behavior of the camera is enabled on the camera.
  7805. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7806. */
  7807. useBouncingBehavior: boolean;
  7808. private _framingBehavior;
  7809. /**
  7810. * Gets the framing behavior of the camera if it has been enabled.
  7811. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7812. */
  7813. readonly framingBehavior: Nullable<FramingBehavior>;
  7814. /**
  7815. * Defines if the framing behavior of the camera is enabled on the camera.
  7816. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7817. */
  7818. useFramingBehavior: boolean;
  7819. private _autoRotationBehavior;
  7820. /**
  7821. * Gets the auto rotation behavior of the camera if it has been enabled.
  7822. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7823. */
  7824. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  7825. /**
  7826. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  7827. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7828. */
  7829. useAutoRotationBehavior: boolean;
  7830. /**
  7831. * Observable triggered when the mesh target has been changed on the camera.
  7832. */
  7833. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  7834. /**
  7835. * Event raised when the camera is colliding with a mesh.
  7836. */
  7837. onCollide: (collidedMesh: AbstractMesh) => void;
  7838. /**
  7839. * Defines whether the camera should check collision with the objects oh the scene.
  7840. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  7841. */
  7842. checkCollisions: boolean;
  7843. /**
  7844. * Defines the collision radius of the camera.
  7845. * This simulates a sphere around the camera.
  7846. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7847. */
  7848. collisionRadius: Vector3;
  7849. protected _collider: Collider;
  7850. protected _previousPosition: Vector3;
  7851. protected _collisionVelocity: Vector3;
  7852. protected _newPosition: Vector3;
  7853. protected _previousAlpha: number;
  7854. protected _previousBeta: number;
  7855. protected _previousRadius: number;
  7856. protected _collisionTriggered: boolean;
  7857. protected _targetBoundingCenter: Nullable<Vector3>;
  7858. private _computationVector;
  7859. /**
  7860. * Instantiates a new ArcRotateCamera in a given scene
  7861. * @param name Defines the name of the camera
  7862. * @param alpha Defines the camera rotation along the logitudinal axis
  7863. * @param beta Defines the camera rotation along the latitudinal axis
  7864. * @param radius Defines the camera distance from its target
  7865. * @param target Defines the camera target
  7866. * @param scene Defines the scene the camera belongs to
  7867. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7868. */
  7869. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7870. /** @hidden */
  7871. _initCache(): void;
  7872. /** @hidden */
  7873. _updateCache(ignoreParentClass?: boolean): void;
  7874. protected _getTargetPosition(): Vector3;
  7875. private _storedAlpha;
  7876. private _storedBeta;
  7877. private _storedRadius;
  7878. private _storedTarget;
  7879. /**
  7880. * Stores the current state of the camera (alpha, beta, radius and target)
  7881. * @returns the camera itself
  7882. */
  7883. storeState(): Camera;
  7884. /**
  7885. * @hidden
  7886. * Restored camera state. You must call storeState() first
  7887. */
  7888. _restoreStateValues(): boolean;
  7889. /** @hidden */
  7890. _isSynchronizedViewMatrix(): boolean;
  7891. /**
  7892. * Attached controls to the current camera.
  7893. * @param element Defines the element the controls should be listened from
  7894. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7895. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  7896. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  7897. */
  7898. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  7899. /**
  7900. * Detach the current controls from the camera.
  7901. * The camera will stop reacting to inputs.
  7902. * @param element Defines the element to stop listening the inputs from
  7903. */
  7904. detachControl(element: HTMLElement): void;
  7905. /** @hidden */
  7906. _checkInputs(): void;
  7907. protected _checkLimits(): void;
  7908. /**
  7909. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  7910. */
  7911. rebuildAnglesAndRadius(): void;
  7912. /**
  7913. * Use a position to define the current camera related information like aplha, beta and radius
  7914. * @param position Defines the position to set the camera at
  7915. */
  7916. setPosition(position: Vector3): void;
  7917. /**
  7918. * Defines the target the camera should look at.
  7919. * This will automatically adapt alpha beta and radius to fit within the new target.
  7920. * @param target Defines the new target as a Vector or a mesh
  7921. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7922. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7923. */
  7924. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7925. /** @hidden */
  7926. _getViewMatrix(): Matrix;
  7927. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7928. /**
  7929. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7930. * @param meshes Defines the mesh to zoom on
  7931. * @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)
  7932. */
  7933. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7934. /**
  7935. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7936. * The target will be changed but the radius
  7937. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7938. * @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)
  7939. */
  7940. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7941. min: Vector3;
  7942. max: Vector3;
  7943. distance: number;
  7944. }, doNotUpdateMaxZ?: boolean): void;
  7945. /**
  7946. * @override
  7947. * Override Camera.createRigCamera
  7948. */
  7949. createRigCamera(name: string, cameraIndex: number): Camera;
  7950. /**
  7951. * @hidden
  7952. * @override
  7953. * Override Camera._updateRigCameras
  7954. */
  7955. _updateRigCameras(): void;
  7956. /**
  7957. * Destroy the camera and release the current resources hold by it.
  7958. */
  7959. dispose(): void;
  7960. /**
  7961. * Gets the current object class name.
  7962. * @return the class name
  7963. */
  7964. getClassName(): string;
  7965. }
  7966. }
  7967. declare module BABYLON {
  7968. /**
  7969. * Default Inputs manager for the ArcRotateCamera.
  7970. * It groups all the default supported inputs for ease of use.
  7971. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7972. */
  7973. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7974. /**
  7975. * Instantiates a new ArcRotateCameraInputsManager.
  7976. * @param camera Defines the camera the inputs belong to
  7977. */
  7978. constructor(camera: ArcRotateCamera);
  7979. /**
  7980. * Add mouse wheel input support to the input manager.
  7981. * @returns the current input manager
  7982. */
  7983. addMouseWheel(): ArcRotateCameraInputsManager;
  7984. /**
  7985. * Add pointers input support to the input manager.
  7986. * @returns the current input manager
  7987. */
  7988. addPointers(): ArcRotateCameraInputsManager;
  7989. /**
  7990. * Add keyboard input support to the input manager.
  7991. * @returns the current input manager
  7992. */
  7993. addKeyboard(): ArcRotateCameraInputsManager;
  7994. /**
  7995. * Add orientation input support to the input manager.
  7996. * @returns the current input manager
  7997. */
  7998. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7999. }
  8000. }
  8001. declare module BABYLON {
  8002. /**
  8003. * This is the base class of all the camera used in the application.
  8004. * @see http://doc.babylonjs.com/features/cameras
  8005. */
  8006. class Camera extends Node {
  8007. /**
  8008. * This is the default projection mode used by the cameras.
  8009. * It helps recreating a feeling of perspective and better appreciate depth.
  8010. * This is the best way to simulate real life cameras.
  8011. */
  8012. static readonly PERSPECTIVE_CAMERA: number;
  8013. /**
  8014. * This helps creating camera with an orthographic mode.
  8015. * 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.
  8016. */
  8017. static readonly ORTHOGRAPHIC_CAMERA: number;
  8018. /**
  8019. * This is the default FOV mode for perspective cameras.
  8020. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  8021. */
  8022. static readonly FOVMODE_VERTICAL_FIXED: number;
  8023. /**
  8024. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  8025. */
  8026. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  8027. /**
  8028. * This specifies ther is no need for a camera rig.
  8029. * Basically only one eye is rendered corresponding to the camera.
  8030. */
  8031. static readonly RIG_MODE_NONE: number;
  8032. /**
  8033. * Simulates a camera Rig with one blue eye and one red eye.
  8034. * This can be use with 3d blue and red glasses.
  8035. */
  8036. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  8037. /**
  8038. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  8039. */
  8040. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  8041. /**
  8042. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  8043. */
  8044. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  8045. /**
  8046. * Defines that both eyes of the camera will be rendered over under each other.
  8047. */
  8048. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  8049. /**
  8050. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  8051. */
  8052. static readonly RIG_MODE_VR: number;
  8053. /**
  8054. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  8055. */
  8056. static readonly RIG_MODE_WEBVR: number;
  8057. /**
  8058. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  8059. */
  8060. static readonly RIG_MODE_CUSTOM: number;
  8061. /**
  8062. * Defines if by default attaching controls should prevent the default javascript event to continue.
  8063. */
  8064. static ForceAttachControlToAlwaysPreventDefault: boolean;
  8065. /**
  8066. * @hidden
  8067. * Might be removed once multiview will be a thing
  8068. */
  8069. static UseAlternateWebVRRendering: boolean;
  8070. /**
  8071. * Define the input manager associated with the camera.
  8072. */
  8073. inputs: CameraInputsManager<Camera>;
  8074. /**
  8075. * Define the current local position of the camera in the scene
  8076. */
  8077. position: Vector3;
  8078. /**
  8079. * The vector the camera should consider as up.
  8080. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  8081. */
  8082. upVector: Vector3;
  8083. /**
  8084. * Define the current limit on the left side for an orthographic camera
  8085. * In scene unit
  8086. */
  8087. orthoLeft: Nullable<number>;
  8088. /**
  8089. * Define the current limit on the right side for an orthographic camera
  8090. * In scene unit
  8091. */
  8092. orthoRight: Nullable<number>;
  8093. /**
  8094. * Define the current limit on the bottom side for an orthographic camera
  8095. * In scene unit
  8096. */
  8097. orthoBottom: Nullable<number>;
  8098. /**
  8099. * Define the current limit on the top side for an orthographic camera
  8100. * In scene unit
  8101. */
  8102. orthoTop: Nullable<number>;
  8103. /**
  8104. * Field Of View is set in Radians. (default is 0.8)
  8105. */
  8106. fov: number;
  8107. /**
  8108. * Define the minimum distance the camera can see from.
  8109. * This is important to note that the depth buffer are not infinite and the closer it starts
  8110. * the more your scene might encounter depth fighting issue.
  8111. */
  8112. minZ: number;
  8113. /**
  8114. * Define the maximum distance the camera can see to.
  8115. * This is important to note that the depth buffer are not infinite and the further it end
  8116. * the more your scene might encounter depth fighting issue.
  8117. */
  8118. maxZ: number;
  8119. /**
  8120. * Define the default inertia of the camera.
  8121. * This helps giving a smooth feeling to the camera movement.
  8122. */
  8123. inertia: number;
  8124. /**
  8125. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  8126. */
  8127. mode: number;
  8128. /**
  8129. * Define wether the camera is intermediate.
  8130. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  8131. */
  8132. isIntermediate: boolean;
  8133. /**
  8134. * Define the viewport of the camera.
  8135. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  8136. */
  8137. viewport: Viewport;
  8138. /**
  8139. * Restricts the camera to viewing objects with the same layerMask.
  8140. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  8141. */
  8142. layerMask: number;
  8143. /**
  8144. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  8145. */
  8146. fovMode: number;
  8147. /**
  8148. * Rig mode of the camera.
  8149. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  8150. * This is normally controlled byt the camera themselves as internal use.
  8151. */
  8152. cameraRigMode: number;
  8153. /**
  8154. * Defines the distance between both "eyes" in case of a RIG
  8155. */
  8156. interaxialDistance: number;
  8157. /**
  8158. * Defines if stereoscopic rendering is done side by side or over under.
  8159. */
  8160. isStereoscopicSideBySide: boolean;
  8161. /**
  8162. * 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
  8163. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  8164. * else in the scene.
  8165. */
  8166. customRenderTargets: RenderTargetTexture[];
  8167. /**
  8168. * When set, the camera will render to this render target instead of the default canvas
  8169. */
  8170. outputRenderTarget: Nullable<RenderTargetTexture>;
  8171. /**
  8172. * Observable triggered when the camera view matrix has changed.
  8173. */
  8174. onViewMatrixChangedObservable: Observable<Camera>;
  8175. /**
  8176. * Observable triggered when the camera Projection matrix has changed.
  8177. */
  8178. onProjectionMatrixChangedObservable: Observable<Camera>;
  8179. /**
  8180. * Observable triggered when the inputs have been processed.
  8181. */
  8182. onAfterCheckInputsObservable: Observable<Camera>;
  8183. /**
  8184. * Observable triggered when reset has been called and applied to the camera.
  8185. */
  8186. onRestoreStateObservable: Observable<Camera>;
  8187. /** @hidden */
  8188. _cameraRigParams: any;
  8189. /** @hidden */
  8190. _rigCameras: Camera[];
  8191. /** @hidden */
  8192. _rigPostProcess: Nullable<PostProcess>;
  8193. protected _webvrViewMatrix: Matrix;
  8194. /** @hidden */
  8195. _skipRendering: boolean;
  8196. /** @hidden */
  8197. _alternateCamera: Camera;
  8198. /** @hidden */
  8199. _projectionMatrix: Matrix;
  8200. /** @hidden */
  8201. _postProcesses: Nullable<PostProcess>[];
  8202. /** @hidden */
  8203. _activeMeshes: SmartArray<AbstractMesh>;
  8204. protected _globalPosition: Vector3;
  8205. /** hidden */
  8206. _computedViewMatrix: Matrix;
  8207. private _doNotComputeProjectionMatrix;
  8208. private _transformMatrix;
  8209. private _frustumPlanes;
  8210. private _refreshFrustumPlanes;
  8211. private _storedFov;
  8212. private _stateStored;
  8213. /**
  8214. * Instantiates a new camera object.
  8215. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  8216. * @see http://doc.babylonjs.com/features/cameras
  8217. * @param name Defines the name of the camera in the scene
  8218. * @param position Defines the position of the camera
  8219. * @param scene Defines the scene the camera belongs too
  8220. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  8221. */
  8222. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8223. /**
  8224. * Store current camera state (fov, position, etc..)
  8225. * @returns the camera
  8226. */
  8227. storeState(): Camera;
  8228. /**
  8229. * Restores the camera state values if it has been stored. You must call storeState() first
  8230. */
  8231. protected _restoreStateValues(): boolean;
  8232. /**
  8233. * Restored camera state. You must call storeState() first.
  8234. * @returns true if restored and false otherwise
  8235. */
  8236. restoreState(): boolean;
  8237. /**
  8238. * Gets the class name of the camera.
  8239. * @returns the class name
  8240. */
  8241. getClassName(): string;
  8242. /**
  8243. * Gets a string representation of the camera useful for debug purpose.
  8244. * @param fullDetails Defines that a more verboe level of logging is required
  8245. * @returns the string representation
  8246. */
  8247. toString(fullDetails?: boolean): string;
  8248. /**
  8249. * Gets the current world space position of the camera.
  8250. */
  8251. readonly globalPosition: Vector3;
  8252. /**
  8253. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  8254. * @returns the active meshe list
  8255. */
  8256. getActiveMeshes(): SmartArray<AbstractMesh>;
  8257. /**
  8258. * Check wether a mesh is part of the current active mesh list of the camera
  8259. * @param mesh Defines the mesh to check
  8260. * @returns true if active, false otherwise
  8261. */
  8262. isActiveMesh(mesh: Mesh): boolean;
  8263. /**
  8264. * Is this camera ready to be used/rendered
  8265. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  8266. * @return true if the camera is ready
  8267. */
  8268. isReady(completeCheck?: boolean): boolean;
  8269. /** @hidden */
  8270. _initCache(): void;
  8271. /** @hidden */
  8272. _updateCache(ignoreParentClass?: boolean): void;
  8273. /** @hidden */
  8274. _isSynchronized(): boolean;
  8275. /** @hidden */
  8276. _isSynchronizedViewMatrix(): boolean;
  8277. /** @hidden */
  8278. _isSynchronizedProjectionMatrix(): boolean;
  8279. /**
  8280. * Attach the input controls to a specific dom element to get the input from.
  8281. * @param element Defines the element the controls should be listened from
  8282. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8283. */
  8284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8285. /**
  8286. * Detach the current controls from the specified dom element.
  8287. * @param element Defines the element to stop listening the inputs from
  8288. */
  8289. detachControl(element: HTMLElement): void;
  8290. /**
  8291. * Update the camera state according to the different inputs gathered during the frame.
  8292. */
  8293. update(): void;
  8294. /** @hidden */
  8295. _checkInputs(): void;
  8296. /** @hidden */
  8297. readonly rigCameras: Camera[];
  8298. /**
  8299. * Gets the post process used by the rig cameras
  8300. */
  8301. readonly rigPostProcess: Nullable<PostProcess>;
  8302. /**
  8303. * Internal, gets the first post proces.
  8304. * @returns the first post process to be run on this camera.
  8305. */
  8306. _getFirstPostProcess(): Nullable<PostProcess>;
  8307. private _cascadePostProcessesToRigCams;
  8308. /**
  8309. * Attach a post process to the camera.
  8310. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8311. * @param postProcess The post process to attach to the camera
  8312. * @param insertAt The position of the post process in case several of them are in use in the scene
  8313. * @returns the position the post process has been inserted at
  8314. */
  8315. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  8316. /**
  8317. * Detach a post process to the camera.
  8318. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8319. * @param postProcess The post process to detach from the camera
  8320. */
  8321. detachPostProcess(postProcess: PostProcess): void;
  8322. /**
  8323. * Gets the current world matrix of the camera
  8324. */
  8325. getWorldMatrix(): Matrix;
  8326. /** @hidden */
  8327. protected _getViewMatrix(): Matrix;
  8328. /**
  8329. * Gets the current view matrix of the camera.
  8330. * @param force forces the camera to recompute the matrix without looking at the cached state
  8331. * @returns the view matrix
  8332. */
  8333. getViewMatrix(force?: boolean): Matrix;
  8334. /**
  8335. * Freeze the projection matrix.
  8336. * It will prevent the cache check of the camera projection compute and can speed up perf
  8337. * if no parameter of the camera are meant to change
  8338. * @param projection Defines manually a projection if necessary
  8339. */
  8340. freezeProjectionMatrix(projection?: Matrix): void;
  8341. /**
  8342. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  8343. */
  8344. unfreezeProjectionMatrix(): void;
  8345. /**
  8346. * Gets the current projection matrix of the camera.
  8347. * @param force forces the camera to recompute the matrix without looking at the cached state
  8348. * @returns the projection matrix
  8349. */
  8350. getProjectionMatrix(force?: boolean): Matrix;
  8351. /**
  8352. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  8353. * @returns a Matrix
  8354. */
  8355. getTransformationMatrix(): Matrix;
  8356. private _updateFrustumPlanes;
  8357. /**
  8358. * Checks if a cullable object (mesh...) is in the camera frustum
  8359. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  8360. * @param target The object to check
  8361. * @returns true if the object is in frustum otherwise false
  8362. */
  8363. isInFrustum(target: ICullable): boolean;
  8364. /**
  8365. * Checks if a cullable object (mesh...) is in the camera frustum
  8366. * Unlike isInFrustum this cheks the full bounding box
  8367. * @param target The object to check
  8368. * @returns true if the object is in frustum otherwise false
  8369. */
  8370. isCompletelyInFrustum(target: ICullable): boolean;
  8371. /**
  8372. * Gets a ray in the forward direction from the camera.
  8373. * @param length Defines the length of the ray to create
  8374. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  8375. * @param origin Defines the start point of the ray which defaults to the camera position
  8376. * @returns the forward ray
  8377. */
  8378. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  8379. /**
  8380. * Releases resources associated with this node.
  8381. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8382. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8383. */
  8384. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8385. /**
  8386. * Gets the left camera of a rig setup in case of Rigged Camera
  8387. */
  8388. readonly leftCamera: Nullable<FreeCamera>;
  8389. /**
  8390. * Gets the right camera of a rig setup in case of Rigged Camera
  8391. */
  8392. readonly rightCamera: Nullable<FreeCamera>;
  8393. /**
  8394. * Gets the left camera target of a rig setup in case of Rigged Camera
  8395. * @returns the target position
  8396. */
  8397. getLeftTarget(): Nullable<Vector3>;
  8398. /**
  8399. * Gets the right camera target of a rig setup in case of Rigged Camera
  8400. * @returns the target position
  8401. */
  8402. getRightTarget(): Nullable<Vector3>;
  8403. /**
  8404. * @hidden
  8405. */
  8406. setCameraRigMode(mode: number, rigParams: any): void;
  8407. private _getVRProjectionMatrix;
  8408. protected _updateCameraRotationMatrix(): void;
  8409. protected _updateWebVRCameraRotationMatrix(): void;
  8410. /**
  8411. * This function MUST be overwritten by the different WebVR cameras available.
  8412. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8413. */
  8414. protected _getWebVRProjectionMatrix(): Matrix;
  8415. /**
  8416. * This function MUST be overwritten by the different WebVR cameras available.
  8417. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8418. */
  8419. protected _getWebVRViewMatrix(): Matrix;
  8420. /** @hidden */
  8421. setCameraRigParameter(name: string, value: any): void;
  8422. /**
  8423. * needs to be overridden by children so sub has required properties to be copied
  8424. * @hidden
  8425. */
  8426. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8427. /**
  8428. * May need to be overridden by children
  8429. * @hidden
  8430. */
  8431. _updateRigCameras(): void;
  8432. /** @hidden */
  8433. _setupInputs(): void;
  8434. /**
  8435. * Serialiaze the camera setup to a json represention
  8436. * @returns the JSON representation
  8437. */
  8438. serialize(): any;
  8439. /**
  8440. * Clones the current camera.
  8441. * @param name The cloned camera name
  8442. * @returns the cloned camera
  8443. */
  8444. clone(name: string): Camera;
  8445. /**
  8446. * Gets the direction of the camera relative to a given local axis.
  8447. * @param localAxis Defines the reference axis to provide a relative direction.
  8448. * @return the direction
  8449. */
  8450. getDirection(localAxis: Vector3): Vector3;
  8451. /**
  8452. * Gets the direction of the camera relative to a given local axis into a passed vector.
  8453. * @param localAxis Defines the reference axis to provide a relative direction.
  8454. * @param result Defines the vector to store the result in
  8455. */
  8456. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  8457. /**
  8458. * Gets a camera constructor for a given camera type
  8459. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  8460. * @param name The name of the camera the result will be able to instantiate
  8461. * @param scene The scene the result will construct the camera in
  8462. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  8463. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  8464. * @returns a factory method to construc the camera
  8465. */
  8466. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  8467. /**
  8468. * Compute the world matrix of the camera.
  8469. * @returns the camera workd matrix
  8470. */
  8471. computeWorldMatrix(): Matrix;
  8472. /**
  8473. * Parse a JSON and creates the camera from the parsed information
  8474. * @param parsedCamera The JSON to parse
  8475. * @param scene The scene to instantiate the camera in
  8476. * @returns the newly constructed camera
  8477. */
  8478. static Parse(parsedCamera: any, scene: Scene): Camera;
  8479. }
  8480. }
  8481. declare module BABYLON {
  8482. /**
  8483. * @ignore
  8484. * This is a list of all the different input types that are available in the application.
  8485. * Fo instance: ArcRotateCameraGamepadInput...
  8486. */
  8487. var CameraInputTypes: {};
  8488. /**
  8489. * This is the contract to implement in order to create a new input class.
  8490. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8491. */
  8492. interface ICameraInput<TCamera extends Camera> {
  8493. /**
  8494. * Defines the camera the input is attached to.
  8495. */
  8496. camera: Nullable<TCamera>;
  8497. /**
  8498. * Gets the class name of the current intput.
  8499. * @returns the class name
  8500. */
  8501. getClassName(): string;
  8502. /**
  8503. * Get the friendly name associated with the input class.
  8504. * @returns the input friendly name
  8505. */
  8506. getSimpleName(): string;
  8507. /**
  8508. * Attach the input controls to a specific dom element to get the input from.
  8509. * @param element Defines the element the controls should be listened from
  8510. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8511. */
  8512. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8513. /**
  8514. * Detach the current controls from the specified dom element.
  8515. * @param element Defines the element to stop listening the inputs from
  8516. */
  8517. detachControl(element: Nullable<HTMLElement>): void;
  8518. /**
  8519. * Update the current camera state depending on the inputs that have been used this frame.
  8520. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8521. */
  8522. checkInputs?: () => void;
  8523. }
  8524. /**
  8525. * Represents a map of input types to input instance or input index to input instance.
  8526. */
  8527. interface CameraInputsMap<TCamera extends Camera> {
  8528. /**
  8529. * Accessor to the input by input type.
  8530. */
  8531. [name: string]: ICameraInput<TCamera>;
  8532. /**
  8533. * Accessor to the input by input index.
  8534. */
  8535. [idx: number]: ICameraInput<TCamera>;
  8536. }
  8537. /**
  8538. * This represents the input manager used within a camera.
  8539. * It helps dealing with all the different kind of input attached to a camera.
  8540. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8541. */
  8542. class CameraInputsManager<TCamera extends Camera> {
  8543. /**
  8544. * Defines the list of inputs attahed to the camera.
  8545. */
  8546. attached: CameraInputsMap<TCamera>;
  8547. /**
  8548. * Defines the dom element the camera is collecting inputs from.
  8549. * This is null if the controls have not been attached.
  8550. */
  8551. attachedElement: Nullable<HTMLElement>;
  8552. /**
  8553. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8554. */
  8555. noPreventDefault: boolean;
  8556. /**
  8557. * Defined the camera the input manager belongs to.
  8558. */
  8559. camera: TCamera;
  8560. /**
  8561. * Update the current camera state depending on the inputs that have been used this frame.
  8562. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8563. */
  8564. checkInputs: () => void;
  8565. /**
  8566. * Instantiate a new Camera Input Manager.
  8567. * @param camera Defines the camera the input manager blongs to
  8568. */
  8569. constructor(camera: TCamera);
  8570. /**
  8571. * Add an input method to a camera
  8572. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8573. * @param input camera input method
  8574. */
  8575. add(input: ICameraInput<TCamera>): void;
  8576. /**
  8577. * Remove a specific input method from a camera
  8578. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8579. * @param inputToRemove camera input method
  8580. */
  8581. remove(inputToRemove: ICameraInput<TCamera>): void;
  8582. /**
  8583. * Remove a specific input type from a camera
  8584. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8585. * @param inputType the type of the input to remove
  8586. */
  8587. removeByType(inputType: string): void;
  8588. private _addCheckInputs;
  8589. /**
  8590. * Attach the input controls to the currently attached dom element to listen the events from.
  8591. * @param input Defines the input to attach
  8592. */
  8593. attachInput(input: ICameraInput<TCamera>): void;
  8594. /**
  8595. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8596. * @param element Defines the dom element to collect the events from
  8597. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8598. */
  8599. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8600. /**
  8601. * Detach the current manager inputs controls from a specific dom element.
  8602. * @param element Defines the dom element to collect the events from
  8603. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8604. */
  8605. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8606. /**
  8607. * Rebuild the dynamic inputCheck function from the current list of
  8608. * defined inputs in the manager.
  8609. */
  8610. rebuildInputCheck(): void;
  8611. /**
  8612. * Remove all attached input methods from a camera
  8613. */
  8614. clear(): void;
  8615. /**
  8616. * Serialize the current input manager attached to a camera.
  8617. * This ensures than once parsed,
  8618. * the input associated to the camera will be identical to the current ones
  8619. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8620. */
  8621. serialize(serializedCamera: any): void;
  8622. /**
  8623. * Parses an input manager serialized JSON to restore the previous list of inputs
  8624. * and states associated to a camera.
  8625. * @param parsedCamera Defines the JSON to parse
  8626. */
  8627. parse(parsedCamera: any): void;
  8628. }
  8629. }
  8630. declare module BABYLON {
  8631. /**
  8632. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  8633. * being tilted forward or back and left or right.
  8634. */
  8635. class DeviceOrientationCamera extends FreeCamera {
  8636. private _initialQuaternion;
  8637. private _quaternionCache;
  8638. /**
  8639. * Creates a new device orientation camera
  8640. * @param name The name of the camera
  8641. * @param position The start position camera
  8642. * @param scene The scene the camera belongs to
  8643. */
  8644. constructor(name: string, position: Vector3, scene: Scene);
  8645. /**
  8646. * Gets the current instance class name ("DeviceOrientationCamera").
  8647. * This helps avoiding instanceof at run time.
  8648. * @returns the class name
  8649. */
  8650. getClassName(): string;
  8651. /**
  8652. * @hidden
  8653. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  8654. */
  8655. _checkInputs(): void;
  8656. /**
  8657. * Reset the camera to its default orientation on the specified axis only.
  8658. * @param axis The axis to reset
  8659. */
  8660. resetToCurrentRotation(axis?: Axis): void;
  8661. }
  8662. }
  8663. declare module BABYLON {
  8664. /**
  8665. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8666. * such as in a 3D Space Shooter or a Flight Simulator.
  8667. */
  8668. class FlyCamera extends TargetCamera {
  8669. /**
  8670. * Define the collision ellipsoid of the camera.
  8671. * This is helpful for simulating a camera body, like a player's body.
  8672. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8673. */
  8674. ellipsoid: Vector3;
  8675. /**
  8676. * Define an offset for the position of the ellipsoid around the camera.
  8677. * This can be helpful if the camera is attached away from the player's body center,
  8678. * such as at its head.
  8679. */
  8680. ellipsoidOffset: Vector3;
  8681. /**
  8682. * Enable or disable collisions of the camera with the rest of the scene objects.
  8683. */
  8684. checkCollisions: boolean;
  8685. /**
  8686. * Enable or disable gravity on the camera.
  8687. */
  8688. applyGravity: boolean;
  8689. /**
  8690. * Define the current direction the camera is moving to.
  8691. */
  8692. cameraDirection: Vector3;
  8693. /**
  8694. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  8695. * This overrides and empties cameraRotation.
  8696. */
  8697. rotationQuaternion: BABYLON.Quaternion;
  8698. /**
  8699. * Track Roll to maintain the wanted Rolling when looking around.
  8700. */
  8701. _trackRoll: number;
  8702. /**
  8703. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  8704. */
  8705. rollCorrect: number;
  8706. /**
  8707. * Mimic a banked turn, Rolling the camera when Yawing.
  8708. * It's recommended to use rollCorrect = 10 for faster banking correction.
  8709. */
  8710. bankedTurn: boolean;
  8711. /**
  8712. * Limit in radians for how much Roll banking will add. (Default: 90°)
  8713. */
  8714. bankedTurnLimit: number;
  8715. /**
  8716. * Value of 0 disables the banked Roll.
  8717. * Value of 1 is equal to the Yaw angle in radians.
  8718. */
  8719. bankedTurnMultiplier: number;
  8720. /**
  8721. * The inputs manager loads all the input sources, such as keyboard and mouse.
  8722. */
  8723. inputs: FlyCameraInputsManager;
  8724. /**
  8725. * Gets the input sensibility for mouse input.
  8726. * Higher values reduce sensitivity.
  8727. */
  8728. /**
  8729. * Sets the input sensibility for a mouse input.
  8730. * Higher values reduce sensitivity.
  8731. */
  8732. angularSensibility: number;
  8733. /**
  8734. * Get the keys for camera movement forward.
  8735. */
  8736. /**
  8737. * Set the keys for camera movement forward.
  8738. */
  8739. keysForward: number[];
  8740. /**
  8741. * Get the keys for camera movement backward.
  8742. */
  8743. keysBackward: number[];
  8744. /**
  8745. * Get the keys for camera movement up.
  8746. */
  8747. /**
  8748. * Set the keys for camera movement up.
  8749. */
  8750. keysUp: number[];
  8751. /**
  8752. * Get the keys for camera movement down.
  8753. */
  8754. /**
  8755. * Set the keys for camera movement down.
  8756. */
  8757. keysDown: number[];
  8758. /**
  8759. * Get the keys for camera movement left.
  8760. */
  8761. /**
  8762. * Set the keys for camera movement left.
  8763. */
  8764. keysLeft: number[];
  8765. /**
  8766. * Set the keys for camera movement right.
  8767. */
  8768. /**
  8769. * Set the keys for camera movement right.
  8770. */
  8771. keysRight: number[];
  8772. /**
  8773. * Event raised when the camera collides with a mesh in the scene.
  8774. */
  8775. onCollide: (collidedMesh: AbstractMesh) => void;
  8776. private _collider;
  8777. private _needMoveForGravity;
  8778. private _oldPosition;
  8779. private _diffPosition;
  8780. private _newPosition;
  8781. /** @hidden */
  8782. _localDirection: Vector3;
  8783. /** @hidden */
  8784. _transformedDirection: Vector3;
  8785. /**
  8786. * Instantiates a FlyCamera.
  8787. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8788. * such as in a 3D Space Shooter or a Flight Simulator.
  8789. * @param name Define the name of the camera in the scene.
  8790. * @param position Define the starting position of the camera in the scene.
  8791. * @param scene Define the scene the camera belongs to.
  8792. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  8793. */
  8794. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8795. /**
  8796. * Attach a control to the HTML DOM element.
  8797. * @param element Defines the element that listens to the input events.
  8798. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  8799. */
  8800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8801. /**
  8802. * Detach a control from the HTML DOM element.
  8803. * The camera will stop reacting to that input.
  8804. * @param element Defines the element that listens to the input events.
  8805. */
  8806. detachControl(element: HTMLElement): void;
  8807. private _collisionMask;
  8808. /**
  8809. * Get the mask that the camera ignores in collision events.
  8810. */
  8811. /**
  8812. * Set the mask that the camera ignores in collision events.
  8813. */
  8814. collisionMask: number;
  8815. /** @hidden */
  8816. _collideWithWorld(displacement: Vector3): void;
  8817. /** @hidden */
  8818. private _onCollisionPositionChange;
  8819. /** @hidden */
  8820. _checkInputs(): void;
  8821. /** @hidden */
  8822. _decideIfNeedsToMove(): boolean;
  8823. /** @hidden */
  8824. _updatePosition(): void;
  8825. /**
  8826. * Restore the Roll to its target value at the rate specified.
  8827. * @param rate - Higher means slower restoring.
  8828. * @hidden
  8829. */
  8830. restoreRoll(rate: number): void;
  8831. /**
  8832. * Destroy the camera and release the current resources held by it.
  8833. */
  8834. dispose(): void;
  8835. /**
  8836. * Get the current object class name.
  8837. * @returns the class name.
  8838. */
  8839. getClassName(): string;
  8840. }
  8841. }
  8842. declare module BABYLON {
  8843. /**
  8844. * Default Inputs manager for the FlyCamera.
  8845. * It groups all the default supported inputs for ease of use.
  8846. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8847. */
  8848. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  8849. /**
  8850. * Instantiates a new FlyCameraInputsManager.
  8851. * @param camera Defines the camera the inputs belong to.
  8852. */
  8853. constructor(camera: FlyCamera);
  8854. /**
  8855. * Add keyboard input support to the input manager.
  8856. * @returns the new FlyCameraKeyboardMoveInput().
  8857. */
  8858. addKeyboard(): FlyCameraInputsManager;
  8859. /**
  8860. * Add mouse input support to the input manager.
  8861. * @param touchEnabled Enable touch screen support.
  8862. * @returns the new FlyCameraMouseInput().
  8863. */
  8864. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  8865. }
  8866. }
  8867. declare module BABYLON {
  8868. /**
  8869. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  8870. * an arc rotate version arcFollowCamera are available.
  8871. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8872. */
  8873. class FollowCamera extends TargetCamera {
  8874. /**
  8875. * Distance the follow camera should follow an object at
  8876. */
  8877. radius: number;
  8878. /**
  8879. * Define a rotation offset between the camera and the object it follows
  8880. */
  8881. rotationOffset: number;
  8882. /**
  8883. * Define a height offset between the camera and the object it follows.
  8884. * It can help following an object from the top (like a car chaing a plane)
  8885. */
  8886. heightOffset: number;
  8887. /**
  8888. * Define how fast the camera can accelerate to follow it s target.
  8889. */
  8890. cameraAcceleration: number;
  8891. /**
  8892. * Define the speed limit of the camera following an object.
  8893. */
  8894. maxCameraSpeed: number;
  8895. /**
  8896. * Define the target of the camera.
  8897. */
  8898. lockedTarget: Nullable<AbstractMesh>;
  8899. /**
  8900. * Instantiates the follow camera.
  8901. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8902. * @param name Define the name of the camera in the scene
  8903. * @param position Define the position of the camera
  8904. * @param scene Define the scene the camera belong to
  8905. * @param lockedTarget Define the target of the camera
  8906. */
  8907. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8908. private _follow;
  8909. /** @hidden */
  8910. _checkInputs(): void;
  8911. /**
  8912. * Gets the camera class name.
  8913. * @returns the class name
  8914. */
  8915. getClassName(): string;
  8916. }
  8917. /**
  8918. * Arc Rotate version of the follow camera.
  8919. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8920. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8921. */
  8922. class ArcFollowCamera extends TargetCamera {
  8923. /** The longitudinal angle of the camera */
  8924. alpha: number;
  8925. /** The latitudinal angle of the camera */
  8926. beta: number;
  8927. /** The radius of the camera from its target */
  8928. radius: number;
  8929. /** Define the camera target (the messh it should follow) */
  8930. target: Nullable<AbstractMesh>;
  8931. private _cartesianCoordinates;
  8932. /**
  8933. * Instantiates a new ArcFollowCamera
  8934. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8935. * @param name Define the name of the camera
  8936. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8937. * @param beta Define the rotation angle of the camera around the elevation axis
  8938. * @param radius Define the radius of the camera from its target point
  8939. * @param target Define the target of the camera
  8940. * @param scene Define the scene the camera belongs to
  8941. */
  8942. constructor(name: string,
  8943. /** The longitudinal angle of the camera */
  8944. alpha: number,
  8945. /** The latitudinal angle of the camera */
  8946. beta: number,
  8947. /** The radius of the camera from its target */
  8948. radius: number,
  8949. /** Define the camera target (the messh it should follow) */
  8950. target: Nullable<AbstractMesh>, scene: Scene);
  8951. private _follow;
  8952. /** @hidden */
  8953. _checkInputs(): void;
  8954. /**
  8955. * Returns the class name of the object.
  8956. * It is mostly used internally for serialization purposes.
  8957. */
  8958. getClassName(): string;
  8959. }
  8960. }
  8961. declare module BABYLON {
  8962. /**
  8963. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8964. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8965. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8966. */
  8967. class FreeCamera extends TargetCamera {
  8968. /**
  8969. * Define the collision ellipsoid of the camera.
  8970. * This is helpful to simulate a camera body like the player body around the camera
  8971. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8972. */
  8973. ellipsoid: Vector3;
  8974. /**
  8975. * Define an offset for the position of the ellipsoid around the camera.
  8976. * This can be helpful to determine the center of the body near the gravity center of the body
  8977. * instead of its head.
  8978. */
  8979. ellipsoidOffset: Vector3;
  8980. /**
  8981. * Enable or disable collisions of the camera with the rest of the scene objects.
  8982. */
  8983. checkCollisions: boolean;
  8984. /**
  8985. * Enable or disable gravity on the camera.
  8986. */
  8987. applyGravity: boolean;
  8988. /**
  8989. * Define the input manager associated to the camera.
  8990. */
  8991. inputs: FreeCameraInputsManager;
  8992. /**
  8993. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8994. * Higher values reduce sensitivity.
  8995. */
  8996. /**
  8997. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8998. * Higher values reduce sensitivity.
  8999. */
  9000. angularSensibility: number;
  9001. /**
  9002. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9003. */
  9004. keysUp: number[];
  9005. /**
  9006. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9007. */
  9008. keysDown: number[];
  9009. /**
  9010. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9011. */
  9012. keysLeft: number[];
  9013. /**
  9014. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9015. */
  9016. keysRight: number[];
  9017. /**
  9018. * Event raised when the camera collide with a mesh in the scene.
  9019. */
  9020. onCollide: (collidedMesh: AbstractMesh) => void;
  9021. private _collider;
  9022. private _needMoveForGravity;
  9023. private _oldPosition;
  9024. private _diffPosition;
  9025. private _newPosition;
  9026. /** @hidden */
  9027. _localDirection: Vector3;
  9028. /** @hidden */
  9029. _transformedDirection: Vector3;
  9030. /**
  9031. * Instantiates a Free Camera.
  9032. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  9033. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  9034. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9035. * @param name Define the name of the camera in the scene
  9036. * @param position Define the start position of the camera in the scene
  9037. * @param scene Define the scene the camera belongs to
  9038. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9039. */
  9040. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9041. /**
  9042. * Attached controls to the current camera.
  9043. * @param element Defines the element the controls should be listened from
  9044. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9045. */
  9046. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9047. /**
  9048. * Detach the current controls from the camera.
  9049. * The camera will stop reacting to inputs.
  9050. * @param element Defines the element to stop listening the inputs from
  9051. */
  9052. detachControl(element: HTMLElement): void;
  9053. private _collisionMask;
  9054. /**
  9055. * Define a collision mask to limit the list of object the camera can collide with
  9056. */
  9057. collisionMask: number;
  9058. /** @hidden */
  9059. _collideWithWorld(displacement: Vector3): void;
  9060. private _onCollisionPositionChange;
  9061. /** @hidden */
  9062. _checkInputs(): void;
  9063. /** @hidden */
  9064. _decideIfNeedsToMove(): boolean;
  9065. /** @hidden */
  9066. _updatePosition(): void;
  9067. /**
  9068. * Destroy the camera and release the current resources hold by it.
  9069. */
  9070. dispose(): void;
  9071. /**
  9072. * Gets the current object class name.
  9073. * @return the class name
  9074. */
  9075. getClassName(): string;
  9076. }
  9077. }
  9078. declare module BABYLON {
  9079. /**
  9080. * Default Inputs manager for the FreeCamera.
  9081. * It groups all the default supported inputs for ease of use.
  9082. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9083. */
  9084. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  9085. /**
  9086. * Instantiates a new FreeCameraInputsManager.
  9087. * @param camera Defines the camera the inputs belong to
  9088. */
  9089. constructor(camera: FreeCamera);
  9090. /**
  9091. * Add keyboard input support to the input manager.
  9092. * @returns the current input manager
  9093. */
  9094. addKeyboard(): FreeCameraInputsManager;
  9095. /**
  9096. * Add mouse input support to the input manager.
  9097. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  9098. * @returns the current input manager
  9099. */
  9100. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  9101. /**
  9102. * Add orientation input support to the input manager.
  9103. * @returns the current input manager
  9104. */
  9105. addDeviceOrientation(): FreeCameraInputsManager;
  9106. /**
  9107. * Add touch input support to the input manager.
  9108. * @returns the current input manager
  9109. */
  9110. addTouch(): FreeCameraInputsManager;
  9111. /**
  9112. * Add virtual joystick input support to the input manager.
  9113. * @returns the current input manager
  9114. */
  9115. addVirtualJoystick(): FreeCameraInputsManager;
  9116. }
  9117. }
  9118. declare module BABYLON {
  9119. /**
  9120. * This represents a FPS type of camera. This is only here for back compat purpose.
  9121. * Please use the UniversalCamera instead as both are identical.
  9122. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9123. */
  9124. class GamepadCamera extends UniversalCamera {
  9125. /**
  9126. * Instantiates a new Gamepad Camera
  9127. * This represents a FPS type of camera. This is only here for back compat purpose.
  9128. * Please use the UniversalCamera instead as both are identical.
  9129. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9130. * @param name Define the name of the camera in the scene
  9131. * @param position Define the start position of the camera in the scene
  9132. * @param scene Define the scene the camera belongs to
  9133. */
  9134. constructor(name: string, position: Vector3, scene: Scene);
  9135. /**
  9136. * Gets the current object class name.
  9137. * @return the class name
  9138. */
  9139. getClassName(): string;
  9140. }
  9141. }
  9142. declare module BABYLON {
  9143. /**
  9144. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9145. * This is the base of the follow, arc rotate cameras and Free camera
  9146. * @see http://doc.babylonjs.com/features/cameras
  9147. */
  9148. class TargetCamera extends Camera {
  9149. private static _RigCamTransformMatrix;
  9150. private static _TargetTransformMatrix;
  9151. private static _TargetFocalPoint;
  9152. /**
  9153. * Define the current direction the camera is moving to
  9154. */
  9155. cameraDirection: Vector3;
  9156. /**
  9157. * Define the current rotation the camera is rotating to
  9158. */
  9159. cameraRotation: Vector2;
  9160. /**
  9161. * When set, the up vector of the camera will be updated by the rotation of the camera
  9162. */
  9163. updateUpVectorFromRotation: boolean;
  9164. private _tmpQuaternion;
  9165. /**
  9166. * Define the current rotation of the camera
  9167. */
  9168. rotation: Vector3;
  9169. /**
  9170. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9171. */
  9172. rotationQuaternion: Quaternion;
  9173. /**
  9174. * Define the current speed of the camera
  9175. */
  9176. speed: number;
  9177. /**
  9178. * Add cconstraint to the camera to prevent it to move freely in all directions and
  9179. * around all axis.
  9180. */
  9181. noRotationConstraint: boolean;
  9182. /**
  9183. * Define the current target of the camera as an object or a position.
  9184. */
  9185. lockedTarget: any;
  9186. /** @hidden */
  9187. _currentTarget: Vector3;
  9188. /** @hidden */
  9189. _initialFocalDistance: number;
  9190. /** @hidden */
  9191. _viewMatrix: Matrix;
  9192. /** @hidden */
  9193. _camMatrix: Matrix;
  9194. /** @hidden */
  9195. _cameraTransformMatrix: Matrix;
  9196. /** @hidden */
  9197. _cameraRotationMatrix: Matrix;
  9198. /** @hidden */
  9199. _referencePoint: Vector3;
  9200. /** @hidden */
  9201. _transformedReferencePoint: Vector3;
  9202. protected _globalCurrentTarget: Vector3;
  9203. protected _globalCurrentUpVector: Vector3;
  9204. /** @hidden */
  9205. _reset: () => void;
  9206. private _defaultUp;
  9207. /**
  9208. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  9209. * This is the base of the follow, arc rotate cameras and Free camera
  9210. * @see http://doc.babylonjs.com/features/cameras
  9211. * @param name Defines the name of the camera in the scene
  9212. * @param position Defines the start position of the camera in the scene
  9213. * @param scene Defines the scene the camera belongs to
  9214. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9215. */
  9216. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9217. /**
  9218. * Gets the position in front of the camera at a given distance.
  9219. * @param distance The distance from the camera we want the position to be
  9220. * @returns the position
  9221. */
  9222. getFrontPosition(distance: number): Vector3;
  9223. /** @hidden */
  9224. _getLockedTargetPosition(): Nullable<Vector3>;
  9225. private _storedPosition;
  9226. private _storedRotation;
  9227. private _storedRotationQuaternion;
  9228. /**
  9229. * Store current camera state of the camera (fov, position, rotation, etc..)
  9230. * @returns the camera
  9231. */
  9232. storeState(): Camera;
  9233. /**
  9234. * Restored camera state. You must call storeState() first
  9235. * @returns whether it was successful or not
  9236. * @hidden
  9237. */
  9238. _restoreStateValues(): boolean;
  9239. /** @hidden */
  9240. _initCache(): void;
  9241. /** @hidden */
  9242. _updateCache(ignoreParentClass?: boolean): void;
  9243. /** @hidden */
  9244. _isSynchronizedViewMatrix(): boolean;
  9245. /** @hidden */
  9246. _computeLocalCameraSpeed(): number;
  9247. /** @hidden */
  9248. setTarget(target: Vector3): void;
  9249. /**
  9250. * Return the current target position of the camera. This value is expressed in local space.
  9251. * @returns the target position
  9252. */
  9253. getTarget(): Vector3;
  9254. /** @hidden */
  9255. _decideIfNeedsToMove(): boolean;
  9256. /** @hidden */
  9257. _updatePosition(): void;
  9258. /** @hidden */
  9259. _checkInputs(): void;
  9260. protected _updateCameraRotationMatrix(): void;
  9261. /**
  9262. * 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)
  9263. * @returns the current camera
  9264. */
  9265. private _rotateUpVectorWithCameraRotationMatrix;
  9266. private _cachedRotationZ;
  9267. private _cachedQuaternionRotationZ;
  9268. /** @hidden */
  9269. _getViewMatrix(): Matrix;
  9270. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9271. /**
  9272. * @hidden
  9273. */
  9274. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9275. /**
  9276. * @hidden
  9277. */
  9278. _updateRigCameras(): void;
  9279. private _getRigCamPositionAndTarget;
  9280. /**
  9281. * Gets the current object class name.
  9282. * @return the class name
  9283. */
  9284. getClassName(): string;
  9285. }
  9286. }
  9287. declare module BABYLON {
  9288. /**
  9289. * This represents a FPS type of camera controlled by touch.
  9290. * This is like a universal camera minus the Gamepad controls.
  9291. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9292. */
  9293. class TouchCamera extends FreeCamera {
  9294. /**
  9295. * Defines the touch sensibility for rotation.
  9296. * The higher the faster.
  9297. */
  9298. touchAngularSensibility: number;
  9299. /**
  9300. * Defines the touch sensibility for move.
  9301. * The higher the faster.
  9302. */
  9303. touchMoveSensibility: number;
  9304. /**
  9305. * Instantiates a new touch camera.
  9306. * This represents a FPS type of camera controlled by touch.
  9307. * This is like a universal camera minus the Gamepad controls.
  9308. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9309. * @param name Define the name of the camera in the scene
  9310. * @param position Define the start position of the camera in the scene
  9311. * @param scene Define the scene the camera belongs to
  9312. */
  9313. constructor(name: string, position: Vector3, scene: Scene);
  9314. /**
  9315. * Gets the current object class name.
  9316. * @return the class name
  9317. */
  9318. getClassName(): string;
  9319. /** @hidden */
  9320. _setupInputs(): void;
  9321. }
  9322. }
  9323. declare module BABYLON {
  9324. /**
  9325. * 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,
  9326. * which still works and will still be found in many Playgrounds.
  9327. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9328. */
  9329. class UniversalCamera extends TouchCamera {
  9330. /**
  9331. * Defines the gamepad rotation sensiblity.
  9332. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  9333. */
  9334. gamepadAngularSensibility: number;
  9335. /**
  9336. * Defines the gamepad move sensiblity.
  9337. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  9338. */
  9339. gamepadMoveSensibility: number;
  9340. /**
  9341. * 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,
  9342. * which still works and will still be found in many Playgrounds.
  9343. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9344. * @param name Define the name of the camera in the scene
  9345. * @param position Define the start position of the camera in the scene
  9346. * @param scene Define the scene the camera belongs to
  9347. */
  9348. constructor(name: string, position: Vector3, scene: Scene);
  9349. /**
  9350. * Gets the current object class name.
  9351. * @return the class name
  9352. */
  9353. getClassName(): string;
  9354. }
  9355. }
  9356. declare module BABYLON {
  9357. /**
  9358. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  9359. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9360. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9361. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9362. */
  9363. class VirtualJoysticksCamera extends FreeCamera {
  9364. /**
  9365. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  9366. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9367. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9368. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9369. * @param name Define the name of the camera in the scene
  9370. * @param position Define the start position of the camera in the scene
  9371. * @param scene Define the scene the camera belongs to
  9372. */
  9373. constructor(name: string, position: Vector3, scene: Scene);
  9374. /**
  9375. * Gets the current object class name.
  9376. * @return the class name
  9377. */
  9378. getClassName(): string;
  9379. }
  9380. }
  9381. interface VRDisplay extends EventTarget {
  9382. /**
  9383. * Dictionary of capabilities describing the VRDisplay.
  9384. */
  9385. readonly capabilities: VRDisplayCapabilities;
  9386. /**
  9387. * z-depth defining the far plane of the eye view frustum
  9388. * enables mapping of values in the render target depth
  9389. * attachment to scene coordinates. Initially set to 10000.0.
  9390. */
  9391. depthFar: number;
  9392. /**
  9393. * z-depth defining the near plane of the eye view frustum
  9394. * enables mapping of values in the render target depth
  9395. * attachment to scene coordinates. Initially set to 0.01.
  9396. */
  9397. depthNear: number;
  9398. /**
  9399. * An identifier for this distinct VRDisplay. Used as an
  9400. * association point in the Gamepad API.
  9401. */
  9402. readonly displayId: number;
  9403. /**
  9404. * A display name, a user-readable name identifying it.
  9405. */
  9406. readonly displayName: string;
  9407. readonly isConnected: boolean;
  9408. readonly isPresenting: boolean;
  9409. /**
  9410. * If this VRDisplay supports room-scale experiences, the optional
  9411. * stage attribute contains details on the room-scale parameters.
  9412. */
  9413. readonly stageParameters: VRStageParameters | null;
  9414. /**
  9415. * Passing the value returned by `requestAnimationFrame` to
  9416. * `cancelAnimationFrame` will unregister the callback.
  9417. * @param handle Define the hanle of the request to cancel
  9418. */
  9419. cancelAnimationFrame(handle: number): void;
  9420. /**
  9421. * Stops presenting to the VRDisplay.
  9422. * @returns a promise to know when it stopped
  9423. */
  9424. exitPresent(): Promise<void>;
  9425. /**
  9426. * Return the current VREyeParameters for the given eye.
  9427. * @param whichEye Define the eye we want the parameter for
  9428. * @returns the eye parameters
  9429. */
  9430. getEyeParameters(whichEye: string): VREyeParameters;
  9431. /**
  9432. * Populates the passed VRFrameData with the information required to render
  9433. * the current frame.
  9434. * @param frameData Define the data structure to populate
  9435. * @returns true if ok otherwise false
  9436. */
  9437. getFrameData(frameData: VRFrameData): boolean;
  9438. /**
  9439. * Get the layers currently being presented.
  9440. * @returns the list of VR layers
  9441. */
  9442. getLayers(): VRLayer[];
  9443. /**
  9444. * Return a VRPose containing the future predicted pose of the VRDisplay
  9445. * when the current frame will be presented. The value returned will not
  9446. * change until JavaScript has returned control to the browser.
  9447. *
  9448. * The VRPose will contain the position, orientation, velocity,
  9449. * and acceleration of each of these properties.
  9450. * @returns the pose object
  9451. */
  9452. getPose(): VRPose;
  9453. /**
  9454. * Return the current instantaneous pose of the VRDisplay, with no
  9455. * prediction applied.
  9456. * @returns the current instantaneous pose
  9457. */
  9458. getImmediatePose(): VRPose;
  9459. /**
  9460. * The callback passed to `requestAnimationFrame` will be called
  9461. * any time a new frame should be rendered. When the VRDisplay is
  9462. * presenting the callback will be called at the native refresh
  9463. * rate of the HMD. When not presenting this function acts
  9464. * identically to how window.requestAnimationFrame acts. Content should
  9465. * make no assumptions of frame rate or vsync behavior as the HMD runs
  9466. * asynchronously from other displays and at differing refresh rates.
  9467. * @param callback Define the eaction to run next frame
  9468. * @returns the request handle it
  9469. */
  9470. requestAnimationFrame(callback: FrameRequestCallback): number;
  9471. /**
  9472. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  9473. * Repeat calls while already presenting will update the VRLayers being displayed.
  9474. * @param layers Define the list of layer to present
  9475. * @returns a promise to know when the request has been fulfilled
  9476. */
  9477. requestPresent(layers: VRLayer[]): Promise<void>;
  9478. /**
  9479. * Reset the pose for this display, treating its current position and
  9480. * orientation as the "origin/zero" values. VRPose.position,
  9481. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  9482. * updated when calling resetPose(). This should be called in only
  9483. * sitting-space experiences.
  9484. */
  9485. resetPose(): void;
  9486. /**
  9487. * The VRLayer provided to the VRDisplay will be captured and presented
  9488. * in the HMD. Calling this function has the same effect on the source
  9489. * canvas as any other operation that uses its source image, and canvases
  9490. * created without preserveDrawingBuffer set to true will be cleared.
  9491. * @param pose Define the pose to submit
  9492. */
  9493. submitFrame(pose?: VRPose): void;
  9494. }
  9495. declare var VRDisplay: {
  9496. prototype: VRDisplay;
  9497. new (): VRDisplay;
  9498. };
  9499. interface VRLayer {
  9500. leftBounds?: number[] | Float32Array | null;
  9501. rightBounds?: number[] | Float32Array | null;
  9502. source?: HTMLCanvasElement | null;
  9503. }
  9504. interface VRDisplayCapabilities {
  9505. readonly canPresent: boolean;
  9506. readonly hasExternalDisplay: boolean;
  9507. readonly hasOrientation: boolean;
  9508. readonly hasPosition: boolean;
  9509. readonly maxLayers: number;
  9510. }
  9511. interface VREyeParameters {
  9512. /** @deprecated */
  9513. readonly fieldOfView: VRFieldOfView;
  9514. readonly offset: Float32Array;
  9515. readonly renderHeight: number;
  9516. readonly renderWidth: number;
  9517. }
  9518. interface VRFieldOfView {
  9519. readonly downDegrees: number;
  9520. readonly leftDegrees: number;
  9521. readonly rightDegrees: number;
  9522. readonly upDegrees: number;
  9523. }
  9524. interface VRFrameData {
  9525. readonly leftProjectionMatrix: Float32Array;
  9526. readonly leftViewMatrix: Float32Array;
  9527. readonly pose: VRPose;
  9528. readonly rightProjectionMatrix: Float32Array;
  9529. readonly rightViewMatrix: Float32Array;
  9530. readonly timestamp: number;
  9531. }
  9532. interface VRPose {
  9533. readonly angularAcceleration: Float32Array | null;
  9534. readonly angularVelocity: Float32Array | null;
  9535. readonly linearAcceleration: Float32Array | null;
  9536. readonly linearVelocity: Float32Array | null;
  9537. readonly orientation: Float32Array | null;
  9538. readonly position: Float32Array | null;
  9539. readonly timestamp: number;
  9540. }
  9541. interface VRStageParameters {
  9542. sittingToStandingTransform?: Float32Array;
  9543. sizeX?: number;
  9544. sizeY?: number;
  9545. }
  9546. interface Navigator {
  9547. getVRDisplays(): Promise<VRDisplay[]>;
  9548. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  9549. }
  9550. interface Window {
  9551. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  9552. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  9553. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  9554. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9555. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9556. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  9557. }
  9558. interface Gamepad {
  9559. readonly displayId: number;
  9560. }
  9561. /**
  9562. * Module Debug contains the (visual) components to debug a scene correctly
  9563. */
  9564. declare module BABYLON.Debug {
  9565. /**
  9566. * The Axes viewer will show 3 axes in a specific point in space
  9567. */
  9568. class AxesViewer {
  9569. private _xmesh;
  9570. private _ymesh;
  9571. private _zmesh;
  9572. /**
  9573. * Gets the hosting scene
  9574. */
  9575. scene: Nullable<Scene>;
  9576. /**
  9577. * Gets or sets a number used to scale line length
  9578. */
  9579. scaleLines: number;
  9580. /** Gets the mesh used to render x-axis */
  9581. readonly xAxisMesh: Nullable<AbstractMesh>;
  9582. /** Gets the mesh used to render x-axis */
  9583. readonly yAxisMesh: Nullable<AbstractMesh>;
  9584. /** Gets the mesh used to render x-axis */
  9585. readonly zAxisMesh: Nullable<AbstractMesh>;
  9586. private static _recursiveChangeRenderingGroupId;
  9587. /**
  9588. * Creates a new AxesViewer
  9589. * @param scene defines the hosting scene
  9590. * @param scaleLines defines a number used to scale line length (1 by default)
  9591. */
  9592. constructor(scene: Scene, scaleLines?: number);
  9593. /**
  9594. * Force the viewer to update
  9595. * @param position defines the position of the viewer
  9596. * @param xaxis defines the x axis of the viewer
  9597. * @param yaxis defines the y axis of the viewer
  9598. * @param zaxis defines the z axis of the viewer
  9599. */
  9600. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9601. /** Releases resources */
  9602. dispose(): void;
  9603. }
  9604. }
  9605. declare module BABYLON.Debug {
  9606. /**
  9607. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9608. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9609. */
  9610. class BoneAxesViewer extends AxesViewer {
  9611. /**
  9612. * Gets or sets the target mesh where to display the axes viewer
  9613. */
  9614. mesh: Nullable<Mesh>;
  9615. /**
  9616. * Gets or sets the target bone where to display the axes viewer
  9617. */
  9618. bone: Nullable<Bone>;
  9619. /** Gets current position */
  9620. pos: Vector3;
  9621. /** Gets direction of X axis */
  9622. xaxis: Vector3;
  9623. /** Gets direction of Y axis */
  9624. yaxis: Vector3;
  9625. /** Gets direction of Z axis */
  9626. zaxis: Vector3;
  9627. /**
  9628. * Creates a new BoneAxesViewer
  9629. * @param scene defines the hosting scene
  9630. * @param bone defines the target bone
  9631. * @param mesh defines the target mesh
  9632. * @param scaleLines defines a scaling factor for line length (1 by default)
  9633. */
  9634. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9635. /**
  9636. * Force the viewer to update
  9637. */
  9638. update(): void;
  9639. /** Releases resources */
  9640. dispose(): void;
  9641. }
  9642. }
  9643. declare module BABYLON {
  9644. /**
  9645. * Interface used to define scene explorer extensibility option
  9646. */
  9647. interface IExplorerExtensibilityOption {
  9648. /**
  9649. * Define the option label
  9650. */
  9651. label: string;
  9652. /**
  9653. * Defines the action to execute on click
  9654. */
  9655. action: (entity: any) => void;
  9656. }
  9657. /**
  9658. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  9659. */
  9660. interface IExplorerExtensibilityGroup {
  9661. /**
  9662. * Defines a predicate to test if a given type mut be extended
  9663. */
  9664. predicate: (entity: any) => boolean;
  9665. /**
  9666. * Gets the list of options added to a type
  9667. */
  9668. entries: IExplorerExtensibilityOption[];
  9669. }
  9670. /**
  9671. * Interface used to define the options to use to create the Inspector
  9672. */
  9673. interface IInspectorOptions {
  9674. /**
  9675. * Display in overlay mode (default: false)
  9676. */
  9677. overlay?: boolean;
  9678. /**
  9679. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  9680. */
  9681. globalRoot?: HTMLElement;
  9682. /**
  9683. * Display the Scene explorer
  9684. */
  9685. showExplorer?: boolean;
  9686. /**
  9687. * Display the property inspector
  9688. */
  9689. showInspector?: boolean;
  9690. /**
  9691. * Display in embed mode (both panes on the right)
  9692. */
  9693. embedMode?: boolean;
  9694. /**
  9695. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  9696. */
  9697. handleResize?: boolean;
  9698. /**
  9699. * Allow the panes to popup (default: true)
  9700. */
  9701. enablePopup?: boolean;
  9702. /**
  9703. * Optional list of extensibility entries
  9704. */
  9705. explorerExtensibility?: IExplorerExtensibilityGroup[];
  9706. }
  9707. interface Scene {
  9708. /**
  9709. * @hidden
  9710. * Backing field
  9711. */
  9712. _debugLayer: DebugLayer;
  9713. /**
  9714. * Gets the debug layer (aka Inspector) associated with the scene
  9715. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9716. */
  9717. debugLayer: DebugLayer;
  9718. }
  9719. /**
  9720. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9721. * what is happening in your scene
  9722. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9723. */
  9724. class DebugLayer {
  9725. /**
  9726. * Define the url to get the inspector script from.
  9727. * By default it uses the babylonjs CDN.
  9728. * @ignoreNaming
  9729. */
  9730. static InspectorURL: string;
  9731. private _scene;
  9732. private BJSINSPECTOR;
  9733. /**
  9734. * Observable triggered when a property is changed through the inspector.
  9735. */
  9736. onPropertyChangedObservable: Observable<{
  9737. object: any;
  9738. property: string;
  9739. value: any;
  9740. initialValue: any;
  9741. }>;
  9742. /**
  9743. * Instantiates a new debug layer.
  9744. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9745. * what is happening in your scene
  9746. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9747. * @param scene Defines the scene to inspect
  9748. */
  9749. constructor(scene: Scene);
  9750. /** Creates the inspector window. */
  9751. private _createInspector;
  9752. /**
  9753. * Get if the inspector is visible or not.
  9754. * @returns true if visible otherwise, false
  9755. */
  9756. isVisible(): boolean;
  9757. /**
  9758. * Hide the inspector and close its window.
  9759. */
  9760. hide(): void;
  9761. /**
  9762. * Launch the debugLayer.
  9763. * @param config Define the configuration of the inspector
  9764. */
  9765. show(config?: IInspectorOptions): void;
  9766. }
  9767. }
  9768. declare module BABYLON.Debug {
  9769. /**
  9770. * Used to show the physics impostor around the specific mesh
  9771. */
  9772. class PhysicsViewer {
  9773. /** @hidden */
  9774. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9775. /** @hidden */
  9776. protected _meshes: Array<Nullable<AbstractMesh>>;
  9777. /** @hidden */
  9778. protected _scene: Nullable<Scene>;
  9779. /** @hidden */
  9780. protected _numMeshes: number;
  9781. /** @hidden */
  9782. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9783. private _renderFunction;
  9784. private _utilityLayer;
  9785. private _debugBoxMesh;
  9786. private _debugSphereMesh;
  9787. private _debugMaterial;
  9788. /**
  9789. * Creates a new PhysicsViewer
  9790. * @param scene defines the hosting scene
  9791. */
  9792. constructor(scene: Scene);
  9793. /** @hidden */
  9794. protected _updateDebugMeshes(): void;
  9795. /**
  9796. * Renders a specified physic impostor
  9797. * @param impostor defines the impostor to render
  9798. * @returns the new debug mesh used to render the impostor
  9799. */
  9800. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  9801. /**
  9802. * Hides a specified physic impostor
  9803. * @param impostor defines the impostor to hide
  9804. */
  9805. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9806. private _getDebugMaterial;
  9807. private _getDebugBoxMesh;
  9808. private _getDebugSphereMesh;
  9809. private _getDebugMesh;
  9810. /** Releases all resources */
  9811. dispose(): void;
  9812. }
  9813. }
  9814. declare module BABYLON {
  9815. /**
  9816. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9817. * in order to better appreciate the issue one might have.
  9818. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9819. */
  9820. class RayHelper {
  9821. /**
  9822. * Defines the ray we are currently tryin to visualize.
  9823. */
  9824. ray: Nullable<Ray>;
  9825. private _renderPoints;
  9826. private _renderLine;
  9827. private _renderFunction;
  9828. private _scene;
  9829. private _updateToMeshFunction;
  9830. private _attachedToMesh;
  9831. private _meshSpaceDirection;
  9832. private _meshSpaceOrigin;
  9833. /**
  9834. * Helper function to create a colored helper in a scene in one line.
  9835. * @param ray Defines the ray we are currently tryin to visualize
  9836. * @param scene Defines the scene the ray is used in
  9837. * @param color Defines the color we want to see the ray in
  9838. * @returns The newly created ray helper.
  9839. */
  9840. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9841. /**
  9842. * Instantiate a new ray helper.
  9843. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9844. * in order to better appreciate the issue one might have.
  9845. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9846. * @param ray Defines the ray we are currently tryin to visualize
  9847. */
  9848. constructor(ray: Ray);
  9849. /**
  9850. * Shows the ray we are willing to debug.
  9851. * @param scene Defines the scene the ray needs to be rendered in
  9852. * @param color Defines the color the ray needs to be rendered in
  9853. */
  9854. show(scene: Scene, color?: Color3): void;
  9855. /**
  9856. * Hides the ray we are debugging.
  9857. */
  9858. hide(): void;
  9859. private _render;
  9860. /**
  9861. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  9862. * @param mesh Defines the mesh we want the helper attached to
  9863. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  9864. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  9865. * @param length Defines the length of the ray
  9866. */
  9867. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9868. /**
  9869. * Detach the ray helper from the mesh it has previously been attached to.
  9870. */
  9871. detachFromMesh(): void;
  9872. private _updateToMesh;
  9873. /**
  9874. * Dispose the helper and release its associated resources.
  9875. */
  9876. dispose(): void;
  9877. }
  9878. }
  9879. declare module BABYLON.Debug {
  9880. /**
  9881. * Class used to render a debug view of a given skeleton
  9882. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9883. */
  9884. class SkeletonViewer {
  9885. /** defines the skeleton to render */
  9886. skeleton: Skeleton;
  9887. /** defines the mesh attached to the skeleton */
  9888. mesh: AbstractMesh;
  9889. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9890. autoUpdateBonesMatrices: boolean;
  9891. /** defines the rendering group id to use with the viewer */
  9892. renderingGroupId: number;
  9893. /** Gets or sets the color used to render the skeleton */
  9894. color: Color3;
  9895. private _scene;
  9896. private _debugLines;
  9897. private _debugMesh;
  9898. private _isEnabled;
  9899. private _renderFunction;
  9900. private _utilityLayer;
  9901. /**
  9902. * Returns the mesh used to render the bones
  9903. */
  9904. readonly debugMesh: Nullable<LinesMesh>;
  9905. /**
  9906. * Creates a new SkeletonViewer
  9907. * @param skeleton defines the skeleton to render
  9908. * @param mesh defines the mesh attached to the skeleton
  9909. * @param scene defines the hosting scene
  9910. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9911. * @param renderingGroupId defines the rendering group id to use with the viewer
  9912. */
  9913. constructor(
  9914. /** defines the skeleton to render */
  9915. skeleton: Skeleton,
  9916. /** defines the mesh attached to the skeleton */
  9917. mesh: AbstractMesh, scene: Scene,
  9918. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9919. autoUpdateBonesMatrices?: boolean,
  9920. /** defines the rendering group id to use with the viewer */
  9921. renderingGroupId?: number);
  9922. /** Gets or sets a boolean indicating if the viewer is enabled */
  9923. isEnabled: boolean;
  9924. private _getBonePosition;
  9925. private _getLinesForBonesWithLength;
  9926. private _getLinesForBonesNoLength;
  9927. /** Update the viewer to sync with current skeleton state */
  9928. update(): void;
  9929. /** Release associated resources */
  9930. dispose(): void;
  9931. }
  9932. }
  9933. declare module BABYLON {
  9934. /**
  9935. * Interface for attribute information associated with buffer instanciation
  9936. */
  9937. class InstancingAttributeInfo {
  9938. /**
  9939. * Index/offset of the attribute in the vertex shader
  9940. */
  9941. index: number;
  9942. /**
  9943. * size of the attribute, 1, 2, 3 or 4
  9944. */
  9945. attributeSize: number;
  9946. /**
  9947. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9948. * default is FLOAT
  9949. */
  9950. attribyteType: number;
  9951. /**
  9952. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9953. */
  9954. normalized: boolean;
  9955. /**
  9956. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9957. */
  9958. offset: number;
  9959. /**
  9960. * Name of the GLSL attribute, for debugging purpose only
  9961. */
  9962. attributeName: string;
  9963. }
  9964. /**
  9965. * Define options used to create a render target texture
  9966. */
  9967. class RenderTargetCreationOptions {
  9968. /**
  9969. * Specifies is mipmaps must be generated
  9970. */
  9971. generateMipMaps?: boolean;
  9972. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9973. generateDepthBuffer?: boolean;
  9974. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9975. generateStencilBuffer?: boolean;
  9976. /** Defines texture type (int by default) */
  9977. type?: number;
  9978. /** Defines sampling mode (trilinear by default) */
  9979. samplingMode?: number;
  9980. /** Defines format (RGBA by default) */
  9981. format?: number;
  9982. }
  9983. /**
  9984. * Define options used to create a depth texture
  9985. */
  9986. class DepthTextureCreationOptions {
  9987. /** Specifies whether or not a stencil should be allocated in the texture */
  9988. generateStencil?: boolean;
  9989. /** Specifies whether or not bilinear filtering is enable on the texture */
  9990. bilinearFiltering?: boolean;
  9991. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  9992. comparisonFunction?: number;
  9993. /** Specifies if the created texture is a cube texture */
  9994. isCube?: boolean;
  9995. }
  9996. /**
  9997. * Class used to describe the capabilities of the engine relatively to the current browser
  9998. */
  9999. class EngineCapabilities {
  10000. /** Maximum textures units per fragment shader */
  10001. maxTexturesImageUnits: number;
  10002. /** Maximum texture units per vertex shader */
  10003. maxVertexTextureImageUnits: number;
  10004. /** Maximum textures units in the entire pipeline */
  10005. maxCombinedTexturesImageUnits: number;
  10006. /** Maximum texture size */
  10007. maxTextureSize: number;
  10008. /** Maximum cube texture size */
  10009. maxCubemapTextureSize: number;
  10010. /** Maximum render texture size */
  10011. maxRenderTextureSize: number;
  10012. /** Maximum number of vertex attributes */
  10013. maxVertexAttribs: number;
  10014. /** Maximum number of varyings */
  10015. maxVaryingVectors: number;
  10016. /** Maximum number of uniforms per vertex shader */
  10017. maxVertexUniformVectors: number;
  10018. /** Maximum number of uniforms per fragment shader */
  10019. maxFragmentUniformVectors: number;
  10020. /** Defines if standard derivates (dx/dy) are supported */
  10021. standardDerivatives: boolean;
  10022. /** Defines if s3tc texture compression is supported */
  10023. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  10024. /** Defines if pvrtc texture compression is supported */
  10025. pvrtc: any;
  10026. /** Defines if etc1 texture compression is supported */
  10027. etc1: any;
  10028. /** Defines if etc2 texture compression is supported */
  10029. etc2: any;
  10030. /** Defines if astc texture compression is supported */
  10031. astc: any;
  10032. /** Defines if float textures are supported */
  10033. textureFloat: boolean;
  10034. /** Defines if vertex array objects are supported */
  10035. vertexArrayObject: boolean;
  10036. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  10037. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  10038. /** Gets the maximum level of anisotropy supported */
  10039. maxAnisotropy: number;
  10040. /** Defines if instancing is supported */
  10041. instancedArrays: boolean;
  10042. /** Defines if 32 bits indices are supported */
  10043. uintIndices: boolean;
  10044. /** Defines if high precision shaders are supported */
  10045. highPrecisionShaderSupported: boolean;
  10046. /** Defines if depth reading in the fragment shader is supported */
  10047. fragmentDepthSupported: boolean;
  10048. /** Defines if float texture linear filtering is supported*/
  10049. textureFloatLinearFiltering: boolean;
  10050. /** Defines if rendering to float textures is supported */
  10051. textureFloatRender: boolean;
  10052. /** Defines if half float textures are supported*/
  10053. textureHalfFloat: boolean;
  10054. /** Defines if half float texture linear filtering is supported*/
  10055. textureHalfFloatLinearFiltering: boolean;
  10056. /** Defines if rendering to half float textures is supported */
  10057. textureHalfFloatRender: boolean;
  10058. /** Defines if textureLOD shader command is supported */
  10059. textureLOD: boolean;
  10060. /** Defines if draw buffers extension is supported */
  10061. drawBuffersExtension: boolean;
  10062. /** Defines if depth textures are supported */
  10063. depthTextureExtension: boolean;
  10064. /** Defines if float color buffer are supported */
  10065. colorBufferFloat: boolean;
  10066. /** Gets disjoint timer query extension (null if not supported) */
  10067. timerQuery: EXT_disjoint_timer_query;
  10068. /** Defines if timestamp can be used with timer query */
  10069. canUseTimestampForTimerQuery: boolean;
  10070. /** Function used to let the system compiles shaders in background */
  10071. parallelShaderCompile: {
  10072. MAX_SHADER_COMPILER_THREADS_KHR: number;
  10073. maxShaderCompilerThreadsKHR: (thread: number) => void;
  10074. COMPLETION_STATUS_KHR: number;
  10075. };
  10076. }
  10077. /** Interface defining initialization parameters for Engine class */
  10078. interface EngineOptions extends WebGLContextAttributes {
  10079. /**
  10080. * Defines if the engine should no exceed a specified device ratio
  10081. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  10082. */
  10083. limitDeviceRatio?: number;
  10084. /**
  10085. * Defines if webvr should be enabled automatically
  10086. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10087. */
  10088. autoEnableWebVR?: boolean;
  10089. /**
  10090. * Defines if webgl2 should be turned off even if supported
  10091. * @see http://doc.babylonjs.com/features/webgl2
  10092. */
  10093. disableWebGL2Support?: boolean;
  10094. /**
  10095. * Defines if webaudio should be initialized as well
  10096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10097. */
  10098. audioEngine?: boolean;
  10099. /**
  10100. * Defines if animations should run using a deterministic lock step
  10101. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10102. */
  10103. deterministicLockstep?: boolean;
  10104. /** Defines the maximum steps to use with deterministic lock step mode */
  10105. lockstepMaxSteps?: number;
  10106. /**
  10107. * Defines that engine should ignore context lost events
  10108. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  10109. */
  10110. doNotHandleContextLost?: boolean;
  10111. }
  10112. /**
  10113. * Defines the interface used by display changed events
  10114. */
  10115. interface IDisplayChangedEventArgs {
  10116. /** Gets the vrDisplay object (if any) */
  10117. vrDisplay: Nullable<any>;
  10118. /** Gets a boolean indicating if webVR is supported */
  10119. vrSupported: boolean;
  10120. }
  10121. /**
  10122. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  10123. */
  10124. class Engine {
  10125. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  10126. static ExceptionList: ({
  10127. key: string;
  10128. capture: string;
  10129. captureConstraint: number;
  10130. targets: string[];
  10131. } | {
  10132. key: string;
  10133. capture: null;
  10134. captureConstraint: null;
  10135. targets: string[];
  10136. })[];
  10137. /** Gets the list of created engines */
  10138. static Instances: Engine[];
  10139. /**
  10140. * Gets the latest created engine
  10141. */
  10142. static readonly LastCreatedEngine: Nullable<Engine>;
  10143. /**
  10144. * Gets the latest created scene
  10145. */
  10146. static readonly LastCreatedScene: Nullable<Scene>;
  10147. /**
  10148. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  10149. * @param flag defines which part of the materials must be marked as dirty
  10150. * @param predicate defines a predicate used to filter which materials should be affected
  10151. */
  10152. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  10153. /**
  10154. * Hidden
  10155. */
  10156. static _TextureLoaders: IInternalTextureLoader[];
  10157. /** Defines that alpha blending is disabled */
  10158. static readonly ALPHA_DISABLE: number;
  10159. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  10160. static readonly ALPHA_ADD: number;
  10161. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  10162. static readonly ALPHA_COMBINE: number;
  10163. /** Defines that alpha blending to DEST - SRC * DEST */
  10164. static readonly ALPHA_SUBTRACT: number;
  10165. /** Defines that alpha blending to SRC * DEST */
  10166. static readonly ALPHA_MULTIPLY: number;
  10167. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  10168. static readonly ALPHA_MAXIMIZED: number;
  10169. /** Defines that alpha blending to SRC + DEST */
  10170. static readonly ALPHA_ONEONE: number;
  10171. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  10172. static readonly ALPHA_PREMULTIPLIED: number;
  10173. /**
  10174. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  10175. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  10176. */
  10177. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  10178. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  10179. static readonly ALPHA_INTERPOLATE: number;
  10180. /**
  10181. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  10182. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  10183. */
  10184. static readonly ALPHA_SCREENMODE: number;
  10185. /** Defines that the ressource is not delayed*/
  10186. static readonly DELAYLOADSTATE_NONE: number;
  10187. /** Defines that the ressource was successfully delay loaded */
  10188. static readonly DELAYLOADSTATE_LOADED: number;
  10189. /** Defines that the ressource is currently delay loading */
  10190. static readonly DELAYLOADSTATE_LOADING: number;
  10191. /** Defines that the ressource is delayed and has not started loading */
  10192. static readonly DELAYLOADSTATE_NOTLOADED: number;
  10193. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  10194. static readonly NEVER: number;
  10195. /** 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 */
  10196. static readonly ALWAYS: number;
  10197. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  10198. static readonly LESS: number;
  10199. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  10200. static readonly EQUAL: number;
  10201. /** 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 */
  10202. static readonly LEQUAL: number;
  10203. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  10204. static readonly GREATER: number;
  10205. /** 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 */
  10206. static readonly GEQUAL: number;
  10207. /** 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 */
  10208. static readonly NOTEQUAL: number;
  10209. /** Passed to stencilOperation to specify that stencil value must be kept */
  10210. static readonly KEEP: number;
  10211. /** Passed to stencilOperation to specify that stencil value must be replaced */
  10212. static readonly REPLACE: number;
  10213. /** Passed to stencilOperation to specify that stencil value must be incremented */
  10214. static readonly INCR: number;
  10215. /** Passed to stencilOperation to specify that stencil value must be decremented */
  10216. static readonly DECR: number;
  10217. /** Passed to stencilOperation to specify that stencil value must be inverted */
  10218. static readonly INVERT: number;
  10219. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10220. static readonly INCR_WRAP: number;
  10221. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10222. static readonly DECR_WRAP: number;
  10223. /** Texture is not repeating outside of 0..1 UVs */
  10224. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10225. /** Texture is repeating outside of 0..1 UVs */
  10226. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10227. /** Texture is repeating and mirrored */
  10228. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10229. /** ALPHA */
  10230. static readonly TEXTUREFORMAT_ALPHA: number;
  10231. /** LUMINANCE */
  10232. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10233. /** LUMINANCE_ALPHA */
  10234. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10235. /** RGB */
  10236. static readonly TEXTUREFORMAT_RGB: number;
  10237. /** RGBA */
  10238. static readonly TEXTUREFORMAT_RGBA: number;
  10239. /** RED */
  10240. static readonly TEXTUREFORMAT_RED: number;
  10241. /** RED (2nd reference) */
  10242. static readonly TEXTUREFORMAT_R: number;
  10243. /** RG */
  10244. static readonly TEXTUREFORMAT_RG: number;
  10245. /** RED_INTEGER */
  10246. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10247. /** RED_INTEGER (2nd reference) */
  10248. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10249. /** RG_INTEGER */
  10250. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10251. /** RGB_INTEGER */
  10252. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10253. /** RGBA_INTEGER */
  10254. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10255. /** UNSIGNED_BYTE */
  10256. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10257. /** UNSIGNED_BYTE (2nd reference) */
  10258. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10259. /** FLOAT */
  10260. static readonly TEXTURETYPE_FLOAT: number;
  10261. /** HALF_FLOAT */
  10262. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10263. /** BYTE */
  10264. static readonly TEXTURETYPE_BYTE: number;
  10265. /** SHORT */
  10266. static readonly TEXTURETYPE_SHORT: number;
  10267. /** UNSIGNED_SHORT */
  10268. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10269. /** INT */
  10270. static readonly TEXTURETYPE_INT: number;
  10271. /** UNSIGNED_INT */
  10272. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10273. /** UNSIGNED_SHORT_4_4_4_4 */
  10274. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10275. /** UNSIGNED_SHORT_5_5_5_1 */
  10276. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10277. /** UNSIGNED_SHORT_5_6_5 */
  10278. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10279. /** UNSIGNED_INT_2_10_10_10_REV */
  10280. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10281. /** UNSIGNED_INT_24_8 */
  10282. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10283. /** UNSIGNED_INT_10F_11F_11F_REV */
  10284. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10285. /** UNSIGNED_INT_5_9_9_9_REV */
  10286. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10287. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10288. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10289. /** nearest is mag = nearest and min = nearest and mip = linear */
  10290. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10291. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10292. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10293. /** Trilinear is mag = linear and min = linear and mip = linear */
  10294. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10295. /** nearest is mag = nearest and min = nearest and mip = linear */
  10296. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10297. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10298. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10299. /** Trilinear is mag = linear and min = linear and mip = linear */
  10300. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10301. /** mag = nearest and min = nearest and mip = nearest */
  10302. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10303. /** mag = nearest and min = linear and mip = nearest */
  10304. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10305. /** mag = nearest and min = linear and mip = linear */
  10306. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10307. /** mag = nearest and min = linear and mip = none */
  10308. static readonly TEXTURE_NEAREST_LINEAR: number;
  10309. /** mag = nearest and min = nearest and mip = none */
  10310. static readonly TEXTURE_NEAREST_NEAREST: number;
  10311. /** mag = linear and min = nearest and mip = nearest */
  10312. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10313. /** mag = linear and min = nearest and mip = linear */
  10314. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10315. /** mag = linear and min = linear and mip = none */
  10316. static readonly TEXTURE_LINEAR_LINEAR: number;
  10317. /** mag = linear and min = nearest and mip = none */
  10318. static readonly TEXTURE_LINEAR_NEAREST: number;
  10319. /** Explicit coordinates mode */
  10320. static readonly TEXTURE_EXPLICIT_MODE: number;
  10321. /** Spherical coordinates mode */
  10322. static readonly TEXTURE_SPHERICAL_MODE: number;
  10323. /** Planar coordinates mode */
  10324. static readonly TEXTURE_PLANAR_MODE: number;
  10325. /** Cubic coordinates mode */
  10326. static readonly TEXTURE_CUBIC_MODE: number;
  10327. /** Projection coordinates mode */
  10328. static readonly TEXTURE_PROJECTION_MODE: number;
  10329. /** Skybox coordinates mode */
  10330. static readonly TEXTURE_SKYBOX_MODE: number;
  10331. /** Inverse Cubic coordinates mode */
  10332. static readonly TEXTURE_INVCUBIC_MODE: number;
  10333. /** Equirectangular coordinates mode */
  10334. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10335. /** Equirectangular Fixed coordinates mode */
  10336. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10337. /** Equirectangular Fixed Mirrored coordinates mode */
  10338. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10339. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10340. static readonly SCALEMODE_FLOOR: number;
  10341. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10342. static readonly SCALEMODE_NEAREST: number;
  10343. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10344. static readonly SCALEMODE_CEILING: number;
  10345. /**
  10346. * Returns the current version of the framework
  10347. */
  10348. static readonly Version: string;
  10349. /**
  10350. * Returns a string describing the current engine
  10351. */
  10352. readonly description: string;
  10353. /**
  10354. * Gets or sets the epsilon value used by collision engine
  10355. */
  10356. static CollisionsEpsilon: number;
  10357. /**
  10358. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10359. */
  10360. static CodeRepository: string;
  10361. /**
  10362. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10363. */
  10364. static ShadersRepository: string;
  10365. /**
  10366. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10367. */
  10368. forcePOTTextures: boolean;
  10369. /**
  10370. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10371. */
  10372. isFullscreen: boolean;
  10373. /**
  10374. * Gets a boolean indicating if the pointer is currently locked
  10375. */
  10376. isPointerLock: boolean;
  10377. /**
  10378. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10379. */
  10380. cullBackFaces: boolean;
  10381. /**
  10382. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10383. */
  10384. renderEvenInBackground: boolean;
  10385. /**
  10386. * Gets or sets a boolean indicating that cache can be kept between frames
  10387. */
  10388. preventCacheWipeBetweenFrames: boolean;
  10389. /**
  10390. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10391. **/
  10392. enableOfflineSupport: boolean;
  10393. /**
  10394. * 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)
  10395. **/
  10396. disableManifestCheck: boolean;
  10397. /**
  10398. * Gets the list of created scenes
  10399. */
  10400. scenes: Scene[];
  10401. /**
  10402. * Event raised when a new scene is created
  10403. */
  10404. onNewSceneAddedObservable: Observable<Scene>;
  10405. /**
  10406. * Gets the list of created postprocesses
  10407. */
  10408. postProcesses: PostProcess[];
  10409. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10410. validateShaderPrograms: boolean;
  10411. /**
  10412. * Observable event triggered each time the rendering canvas is resized
  10413. */
  10414. onResizeObservable: Observable<Engine>;
  10415. /**
  10416. * Observable event triggered each time the canvas loses focus
  10417. */
  10418. onCanvasBlurObservable: Observable<Engine>;
  10419. /**
  10420. * Observable event triggered each time the canvas gains focus
  10421. */
  10422. onCanvasFocusObservable: Observable<Engine>;
  10423. /**
  10424. * Observable event triggered each time the canvas receives pointerout event
  10425. */
  10426. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10427. /**
  10428. * Observable event triggered before each texture is initialized
  10429. */
  10430. onBeforeTextureInitObservable: Observable<Texture>;
  10431. private _vrDisplay;
  10432. private _vrSupported;
  10433. private _oldSize;
  10434. private _oldHardwareScaleFactor;
  10435. private _vrExclusivePointerMode;
  10436. private _webVRInitPromise;
  10437. /**
  10438. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10439. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10440. */
  10441. readonly isInVRExclusivePointerMode: boolean;
  10442. /**
  10443. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10444. */
  10445. disableUniformBuffers: boolean;
  10446. /** @hidden */
  10447. _uniformBuffers: UniformBuffer[];
  10448. /**
  10449. * Gets a boolean indicating that the engine supports uniform buffers
  10450. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10451. */
  10452. readonly supportsUniformBuffers: boolean;
  10453. /**
  10454. * Observable raised when the engine begins a new frame
  10455. */
  10456. onBeginFrameObservable: Observable<Engine>;
  10457. /**
  10458. * If set, will be used to request the next animation frame for the render loop
  10459. */
  10460. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  10461. /**
  10462. * Observable raised when the engine ends the current frame
  10463. */
  10464. onEndFrameObservable: Observable<Engine>;
  10465. /**
  10466. * Observable raised when the engine is about to compile a shader
  10467. */
  10468. onBeforeShaderCompilationObservable: Observable<Engine>;
  10469. /**
  10470. * Observable raised when the engine has jsut compiled a shader
  10471. */
  10472. onAfterShaderCompilationObservable: Observable<Engine>;
  10473. /** @hidden */
  10474. _gl: WebGLRenderingContext;
  10475. private _renderingCanvas;
  10476. private _windowIsBackground;
  10477. private _webGLVersion;
  10478. /**
  10479. * Gets a boolean indicating that only power of 2 textures are supported
  10480. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10481. */
  10482. readonly needPOTTextures: boolean;
  10483. /** @hidden */
  10484. _badOS: boolean;
  10485. /** @hidden */
  10486. _badDesktopOS: boolean;
  10487. /**
  10488. * Gets or sets a value indicating if we want to disable texture binding optimization.
  10489. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10490. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10491. */
  10492. disableTextureBindingOptimization: boolean;
  10493. /**
  10494. * Gets the audio engine
  10495. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10496. * @ignorenaming
  10497. */
  10498. static audioEngine: IAudioEngine;
  10499. /**
  10500. * Default AudioEngine factory responsible of creating the Audio Engine.
  10501. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  10502. */
  10503. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10504. /**
  10505. * Default offline support factory responsible of creating a tool used to store data locally.
  10506. * By default, this will create a Database object if the workload has been embedded.
  10507. */
  10508. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  10509. private _onFocus;
  10510. private _onBlur;
  10511. private _onCanvasPointerOut;
  10512. private _onCanvasBlur;
  10513. private _onCanvasFocus;
  10514. private _onFullscreenChange;
  10515. private _onPointerLockChange;
  10516. private _onVRDisplayPointerRestricted;
  10517. private _onVRDisplayPointerUnrestricted;
  10518. private _onVrDisplayConnect;
  10519. private _onVrDisplayDisconnect;
  10520. private _onVrDisplayPresentChange;
  10521. /**
  10522. * Observable signaled when VR display mode changes
  10523. */
  10524. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10525. /**
  10526. * Observable signaled when VR request present is complete
  10527. */
  10528. onVRRequestPresentComplete: Observable<boolean>;
  10529. /**
  10530. * Observable signaled when VR request present starts
  10531. */
  10532. onVRRequestPresentStart: Observable<Engine>;
  10533. private _hardwareScalingLevel;
  10534. /** @hidden */
  10535. protected _caps: EngineCapabilities;
  10536. private _pointerLockRequested;
  10537. private _isStencilEnable;
  10538. private _colorWrite;
  10539. private _loadingScreen;
  10540. /** @hidden */
  10541. _drawCalls: PerfCounter;
  10542. /** @hidden */
  10543. _textureCollisions: PerfCounter;
  10544. private _glVersion;
  10545. private _glRenderer;
  10546. private _glVendor;
  10547. private _videoTextureSupported;
  10548. private _renderingQueueLaunched;
  10549. private _activeRenderLoops;
  10550. private _deterministicLockstep;
  10551. private _lockstepMaxSteps;
  10552. /**
  10553. * Observable signaled when a context lost event is raised
  10554. */
  10555. onContextLostObservable: Observable<Engine>;
  10556. /**
  10557. * Observable signaled when a context restored event is raised
  10558. */
  10559. onContextRestoredObservable: Observable<Engine>;
  10560. private _onContextLost;
  10561. private _onContextRestored;
  10562. private _contextWasLost;
  10563. private _doNotHandleContextLost;
  10564. /**
  10565. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10566. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10567. */
  10568. doNotHandleContextLost: boolean;
  10569. private _performanceMonitor;
  10570. private _fps;
  10571. private _deltaTime;
  10572. /**
  10573. * Turn this value on if you want to pause FPS computation when in background
  10574. */
  10575. disablePerformanceMonitorInBackground: boolean;
  10576. /**
  10577. * Gets the performance monitor attached to this engine
  10578. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10579. */
  10580. readonly performanceMonitor: PerformanceMonitor;
  10581. /** @hidden */
  10582. protected _depthCullingState: _DepthCullingState;
  10583. /** @hidden */
  10584. protected _stencilState: _StencilState;
  10585. /** @hidden */
  10586. protected _alphaState: _AlphaState;
  10587. /** @hidden */
  10588. protected _alphaMode: number;
  10589. protected _internalTexturesCache: InternalTexture[];
  10590. /** @hidden */
  10591. protected _activeChannel: number;
  10592. private _currentTextureChannel;
  10593. /** @hidden */
  10594. protected _boundTexturesCache: {
  10595. [key: string]: Nullable<InternalTexture>;
  10596. };
  10597. /** @hidden */
  10598. protected _currentEffect: Nullable<Effect>;
  10599. /** @hidden */
  10600. protected _currentProgram: Nullable<WebGLProgram>;
  10601. private _compiledEffects;
  10602. private _vertexAttribArraysEnabled;
  10603. /** @hidden */
  10604. protected _cachedViewport: Nullable<Viewport>;
  10605. private _cachedVertexArrayObject;
  10606. /** @hidden */
  10607. protected _cachedVertexBuffers: any;
  10608. /** @hidden */
  10609. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10610. /** @hidden */
  10611. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10612. /** @hidden */
  10613. protected _currentRenderTarget: Nullable<InternalTexture>;
  10614. private _uintIndicesCurrentlySet;
  10615. private _currentBoundBuffer;
  10616. /** @hidden */
  10617. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10618. private _currentBufferPointers;
  10619. private _currentInstanceLocations;
  10620. private _currentInstanceBuffers;
  10621. private _textureUnits;
  10622. private _firstBoundInternalTextureTracker;
  10623. private _lastBoundInternalTextureTracker;
  10624. private _workingCanvas;
  10625. private _workingContext;
  10626. private _rescalePostProcess;
  10627. private _dummyFramebuffer;
  10628. private _externalData;
  10629. private _bindedRenderFunction;
  10630. private _vaoRecordInProgress;
  10631. private _mustWipeVertexAttributes;
  10632. private _emptyTexture;
  10633. private _emptyCubeTexture;
  10634. private _emptyTexture3D;
  10635. /** @hidden */
  10636. _frameHandler: number;
  10637. private _nextFreeTextureSlots;
  10638. private _maxSimultaneousTextures;
  10639. private _activeRequests;
  10640. private _texturesSupported;
  10641. private _textureFormatInUse;
  10642. /**
  10643. * Gets the list of texture formats supported
  10644. */
  10645. readonly texturesSupported: Array<string>;
  10646. /**
  10647. * Gets the list of texture formats in use
  10648. */
  10649. readonly textureFormatInUse: Nullable<string>;
  10650. /**
  10651. * Gets the current viewport
  10652. */
  10653. readonly currentViewport: Nullable<Viewport>;
  10654. /**
  10655. * Gets the default empty texture
  10656. */
  10657. readonly emptyTexture: InternalTexture;
  10658. /**
  10659. * Gets the default empty 3D texture
  10660. */
  10661. readonly emptyTexture3D: InternalTexture;
  10662. /**
  10663. * Gets the default empty cube texture
  10664. */
  10665. readonly emptyCubeTexture: InternalTexture;
  10666. /**
  10667. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10668. */
  10669. readonly premultipliedAlpha: boolean;
  10670. /**
  10671. * Creates a new engine
  10672. * @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
  10673. * @param antialias defines enable antialiasing (default: false)
  10674. * @param options defines further options to be sent to the getContext() function
  10675. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10676. */
  10677. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10678. private _rebuildInternalTextures;
  10679. private _rebuildEffects;
  10680. /**
  10681. * Gets a boolean indicating if all created effects are ready
  10682. * @returns true if all effects are ready
  10683. */
  10684. areAllEffectsReady(): boolean;
  10685. private _rebuildBuffers;
  10686. private _initGLContext;
  10687. /**
  10688. * Gets version of the current webGL context
  10689. */
  10690. readonly webGLVersion: number;
  10691. /**
  10692. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10693. */
  10694. readonly isStencilEnable: boolean;
  10695. private _prepareWorkingCanvas;
  10696. /**
  10697. * Reset the texture cache to empty state
  10698. */
  10699. resetTextureCache(): void;
  10700. /**
  10701. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10702. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10703. * @returns true if engine is in deterministic lock step mode
  10704. */
  10705. isDeterministicLockStep(): boolean;
  10706. /**
  10707. * Gets the max steps when engine is running in deterministic lock step
  10708. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10709. * @returns the max steps
  10710. */
  10711. getLockstepMaxSteps(): number;
  10712. /**
  10713. * Gets an object containing information about the current webGL context
  10714. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10715. */
  10716. getGlInfo(): {
  10717. vendor: string;
  10718. renderer: string;
  10719. version: string;
  10720. };
  10721. /**
  10722. * Gets current aspect ratio
  10723. * @param camera defines the camera to use to get the aspect ratio
  10724. * @param useScreen defines if screen size must be used (or the current render target if any)
  10725. * @returns a number defining the aspect ratio
  10726. */
  10727. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10728. /**
  10729. * Gets current screen aspect ratio
  10730. * @returns a number defining the aspect ratio
  10731. */
  10732. getScreenAspectRatio(): number;
  10733. /**
  10734. * Gets the current render width
  10735. * @param useScreen defines if screen size must be used (or the current render target if any)
  10736. * @returns a number defining the current render width
  10737. */
  10738. getRenderWidth(useScreen?: boolean): number;
  10739. /**
  10740. * Gets the current render height
  10741. * @param useScreen defines if screen size must be used (or the current render target if any)
  10742. * @returns a number defining the current render height
  10743. */
  10744. getRenderHeight(useScreen?: boolean): number;
  10745. /**
  10746. * Gets the HTML canvas attached with the current webGL context
  10747. * @returns a HTML canvas
  10748. */
  10749. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10750. /**
  10751. * Gets the client rect of the HTML canvas attached with the current webGL context
  10752. * @returns a client rectanglee
  10753. */
  10754. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10755. /**
  10756. * Defines the hardware scaling level.
  10757. * By default the hardware scaling level is computed from the window device ratio.
  10758. * 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.
  10759. * @param level defines the level to use
  10760. */
  10761. setHardwareScalingLevel(level: number): void;
  10762. /**
  10763. * Gets the current hardware scaling level.
  10764. * By default the hardware scaling level is computed from the window device ratio.
  10765. * 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.
  10766. * @returns a number indicating the current hardware scaling level
  10767. */
  10768. getHardwareScalingLevel(): number;
  10769. /**
  10770. * Gets the list of loaded textures
  10771. * @returns an array containing all loaded textures
  10772. */
  10773. getLoadedTexturesCache(): InternalTexture[];
  10774. /**
  10775. * Gets the object containing all engine capabilities
  10776. * @returns the EngineCapabilities object
  10777. */
  10778. getCaps(): EngineCapabilities;
  10779. /**
  10780. * Gets the current depth function
  10781. * @returns a number defining the depth function
  10782. */
  10783. getDepthFunction(): Nullable<number>;
  10784. /**
  10785. * Sets the current depth function
  10786. * @param depthFunc defines the function to use
  10787. */
  10788. setDepthFunction(depthFunc: number): void;
  10789. /**
  10790. * Sets the current depth function to GREATER
  10791. */
  10792. setDepthFunctionToGreater(): void;
  10793. /**
  10794. * Sets the current depth function to GEQUAL
  10795. */
  10796. setDepthFunctionToGreaterOrEqual(): void;
  10797. /**
  10798. * Sets the current depth function to LESS
  10799. */
  10800. setDepthFunctionToLess(): void;
  10801. /**
  10802. * Sets the current depth function to LEQUAL
  10803. */
  10804. setDepthFunctionToLessOrEqual(): void;
  10805. /**
  10806. * Gets a boolean indicating if stencil buffer is enabled
  10807. * @returns the current stencil buffer state
  10808. */
  10809. getStencilBuffer(): boolean;
  10810. /**
  10811. * Enable or disable the stencil buffer
  10812. * @param enable defines if the stencil buffer must be enabled or disabled
  10813. */
  10814. setStencilBuffer(enable: boolean): void;
  10815. /**
  10816. * Gets the current stencil mask
  10817. * @returns a number defining the new stencil mask to use
  10818. */
  10819. getStencilMask(): number;
  10820. /**
  10821. * Sets the current stencil mask
  10822. * @param mask defines the new stencil mask to use
  10823. */
  10824. setStencilMask(mask: number): void;
  10825. /**
  10826. * Gets the current stencil function
  10827. * @returns a number defining the stencil function to use
  10828. */
  10829. getStencilFunction(): number;
  10830. /**
  10831. * Gets the current stencil reference value
  10832. * @returns a number defining the stencil reference value to use
  10833. */
  10834. getStencilFunctionReference(): number;
  10835. /**
  10836. * Gets the current stencil mask
  10837. * @returns a number defining the stencil mask to use
  10838. */
  10839. getStencilFunctionMask(): number;
  10840. /**
  10841. * Sets the current stencil function
  10842. * @param stencilFunc defines the new stencil function to use
  10843. */
  10844. setStencilFunction(stencilFunc: number): void;
  10845. /**
  10846. * Sets the current stencil reference
  10847. * @param reference defines the new stencil reference to use
  10848. */
  10849. setStencilFunctionReference(reference: number): void;
  10850. /**
  10851. * Sets the current stencil mask
  10852. * @param mask defines the new stencil mask to use
  10853. */
  10854. setStencilFunctionMask(mask: number): void;
  10855. /**
  10856. * Gets the current stencil operation when stencil fails
  10857. * @returns a number defining stencil operation to use when stencil fails
  10858. */
  10859. getStencilOperationFail(): number;
  10860. /**
  10861. * Gets the current stencil operation when depth fails
  10862. * @returns a number defining stencil operation to use when depth fails
  10863. */
  10864. getStencilOperationDepthFail(): number;
  10865. /**
  10866. * Gets the current stencil operation when stencil passes
  10867. * @returns a number defining stencil operation to use when stencil passes
  10868. */
  10869. getStencilOperationPass(): number;
  10870. /**
  10871. * Sets the stencil operation to use when stencil fails
  10872. * @param operation defines the stencil operation to use when stencil fails
  10873. */
  10874. setStencilOperationFail(operation: number): void;
  10875. /**
  10876. * Sets the stencil operation to use when depth fails
  10877. * @param operation defines the stencil operation to use when depth fails
  10878. */
  10879. setStencilOperationDepthFail(operation: number): void;
  10880. /**
  10881. * Sets the stencil operation to use when stencil passes
  10882. * @param operation defines the stencil operation to use when stencil passes
  10883. */
  10884. setStencilOperationPass(operation: number): void;
  10885. /**
  10886. * Sets a boolean indicating if the dithering state is enabled or disabled
  10887. * @param value defines the dithering state
  10888. */
  10889. setDitheringState(value: boolean): void;
  10890. /**
  10891. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10892. * @param value defines the rasterizer state
  10893. */
  10894. setRasterizerState(value: boolean): void;
  10895. /**
  10896. * stop executing a render loop function and remove it from the execution array
  10897. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10898. */
  10899. stopRenderLoop(renderFunction?: () => void): void;
  10900. /** @hidden */
  10901. _renderLoop(): void;
  10902. /**
  10903. * Register and execute a render loop. The engine can have more than one render function
  10904. * @param renderFunction defines the function to continuously execute
  10905. */
  10906. runRenderLoop(renderFunction: () => void): void;
  10907. /**
  10908. * Toggle full screen mode
  10909. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10910. */
  10911. switchFullscreen(requestPointerLock: boolean): void;
  10912. /**
  10913. * Clear the current render buffer or the current render target (if any is set up)
  10914. * @param color defines the color to use
  10915. * @param backBuffer defines if the back buffer must be cleared
  10916. * @param depth defines if the depth buffer must be cleared
  10917. * @param stencil defines if the stencil buffer must be cleared
  10918. */
  10919. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10920. /**
  10921. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10922. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10923. * @param y defines the y-coordinate of the corner of the clear rectangle
  10924. * @param width defines the width of the clear rectangle
  10925. * @param height defines the height of the clear rectangle
  10926. * @param clearColor defines the clear color
  10927. */
  10928. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10929. private _viewportCached;
  10930. /** @hidden */
  10931. _viewport(x: number, y: number, width: number, height: number): void;
  10932. /**
  10933. * Set the WebGL's viewport
  10934. * @param viewport defines the viewport element to be used
  10935. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10936. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10937. */
  10938. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10939. /**
  10940. * Directly set the WebGL Viewport
  10941. * @param x defines the x coordinate of the viewport (in screen space)
  10942. * @param y defines the y coordinate of the viewport (in screen space)
  10943. * @param width defines the width of the viewport (in screen space)
  10944. * @param height defines the height of the viewport (in screen space)
  10945. * @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
  10946. */
  10947. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10948. /**
  10949. * Begin a new frame
  10950. */
  10951. beginFrame(): void;
  10952. /**
  10953. * Enf the current frame
  10954. */
  10955. endFrame(): void;
  10956. /**
  10957. * Resize the view according to the canvas' size
  10958. */
  10959. resize(): void;
  10960. /**
  10961. * Force a specific size of the canvas
  10962. * @param width defines the new canvas' width
  10963. * @param height defines the new canvas' height
  10964. */
  10965. setSize(width: number, height: number): void;
  10966. /**
  10967. * Gets a boolean indicating if a webVR device was detected
  10968. * @returns true if a webVR device was detected
  10969. */
  10970. isVRDevicePresent(): boolean;
  10971. /**
  10972. * Gets the current webVR device
  10973. * @returns the current webVR device (or null)
  10974. */
  10975. getVRDevice(): any;
  10976. /**
  10977. * Initializes a webVR display and starts listening to display change events
  10978. * The onVRDisplayChangedObservable will be notified upon these changes
  10979. * @returns The onVRDisplayChangedObservable
  10980. */
  10981. initWebVR(): Observable<IDisplayChangedEventArgs>;
  10982. /**
  10983. * Initializes a webVR display and starts listening to display change events
  10984. * The onVRDisplayChangedObservable will be notified upon these changes
  10985. * @returns A promise containing a VRDisplay and if vr is supported
  10986. */
  10987. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  10988. /**
  10989. * Call this function to switch to webVR mode
  10990. * Will do nothing if webVR is not supported or if there is no webVR device
  10991. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10992. */
  10993. enableVR(): void;
  10994. /**
  10995. * Call this function to leave webVR mode
  10996. * Will do nothing if webVR is not supported or if there is no webVR device
  10997. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10998. */
  10999. disableVR(): void;
  11000. private _onVRFullScreenTriggered;
  11001. private _getVRDisplaysAsync;
  11002. /**
  11003. * Binds the frame buffer to the specified texture.
  11004. * @param texture The texture to render to or null for the default canvas
  11005. * @param faceIndex The face of the texture to render to in case of cube texture
  11006. * @param requiredWidth The width of the target to render to
  11007. * @param requiredHeight The height of the target to render to
  11008. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  11009. * @param depthStencilTexture The depth stencil texture to use to render
  11010. * @param lodLevel defines le lod level to bind to the frame buffer
  11011. */
  11012. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  11013. private bindUnboundFramebuffer;
  11014. /**
  11015. * Unbind the current render target texture from the webGL context
  11016. * @param texture defines the render target texture to unbind
  11017. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11018. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11019. */
  11020. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11021. /**
  11022. * Unbind a list of render target textures from the webGL context
  11023. * This is used only when drawBuffer extension or webGL2 are active
  11024. * @param textures defines the render target textures to unbind
  11025. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11026. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11027. */
  11028. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11029. /**
  11030. * Force the mipmap generation for the given render target texture
  11031. * @param texture defines the render target texture to use
  11032. */
  11033. generateMipMapsForCubemap(texture: InternalTexture): void;
  11034. /**
  11035. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  11036. */
  11037. flushFramebuffer(): void;
  11038. /**
  11039. * Unbind the current render target and bind the default framebuffer
  11040. */
  11041. restoreDefaultFramebuffer(): void;
  11042. /**
  11043. * Create an uniform buffer
  11044. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11045. * @param elements defines the content of the uniform buffer
  11046. * @returns the webGL uniform buffer
  11047. */
  11048. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  11049. /**
  11050. * Create a dynamic uniform buffer
  11051. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11052. * @param elements defines the content of the uniform buffer
  11053. * @returns the webGL uniform buffer
  11054. */
  11055. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  11056. /**
  11057. * Update an existing uniform buffer
  11058. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11059. * @param uniformBuffer defines the target uniform buffer
  11060. * @param elements defines the content to update
  11061. * @param offset defines the offset in the uniform buffer where update should start
  11062. * @param count defines the size of the data to update
  11063. */
  11064. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  11065. private _resetVertexBufferBinding;
  11066. /**
  11067. * Creates a vertex buffer
  11068. * @param data the data for the vertex buffer
  11069. * @returns the new WebGL static buffer
  11070. */
  11071. createVertexBuffer(data: DataArray): WebGLBuffer;
  11072. /**
  11073. * Creates a dynamic vertex buffer
  11074. * @param data the data for the dynamic vertex buffer
  11075. * @returns the new WebGL dynamic buffer
  11076. */
  11077. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  11078. /**
  11079. * Update a dynamic index buffer
  11080. * @param indexBuffer defines the target index buffer
  11081. * @param indices defines the data to update
  11082. * @param offset defines the offset in the target index buffer where update should start
  11083. */
  11084. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11085. /**
  11086. * Updates a dynamic vertex buffer.
  11087. * @param vertexBuffer the vertex buffer to update
  11088. * @param data the data used to update the vertex buffer
  11089. * @param byteOffset the byte offset of the data
  11090. * @param byteLength the byte length of the data
  11091. */
  11092. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11093. private _resetIndexBufferBinding;
  11094. /**
  11095. * Creates a new index buffer
  11096. * @param indices defines the content of the index buffer
  11097. * @param updatable defines if the index buffer must be updatable
  11098. * @returns a new webGL buffer
  11099. */
  11100. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  11101. /**
  11102. * Bind a webGL buffer to the webGL context
  11103. * @param buffer defines the buffer to bind
  11104. */
  11105. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  11106. /**
  11107. * Bind an uniform buffer to the current webGL context
  11108. * @param buffer defines the buffer to bind
  11109. */
  11110. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  11111. /**
  11112. * Bind a buffer to the current webGL context at a given location
  11113. * @param buffer defines the buffer to bind
  11114. * @param location defines the index where to bind the buffer
  11115. */
  11116. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  11117. /**
  11118. * Bind a specific block at a given index in a specific shader program
  11119. * @param shaderProgram defines the shader program
  11120. * @param blockName defines the block name
  11121. * @param index defines the index where to bind the block
  11122. */
  11123. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  11124. private bindIndexBuffer;
  11125. private bindBuffer;
  11126. /**
  11127. * update the bound buffer with the given data
  11128. * @param data defines the data to update
  11129. */
  11130. updateArrayBuffer(data: Float32Array): void;
  11131. private _vertexAttribPointer;
  11132. private _bindIndexBufferWithCache;
  11133. private _bindVertexBuffersAttributes;
  11134. /**
  11135. * Records a vertex array object
  11136. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11137. * @param vertexBuffers defines the list of vertex buffers to store
  11138. * @param indexBuffer defines the index buffer to store
  11139. * @param effect defines the effect to store
  11140. * @returns the new vertex array object
  11141. */
  11142. recordVertexArrayObject(vertexBuffers: {
  11143. [key: string]: VertexBuffer;
  11144. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  11145. /**
  11146. * Bind a specific vertex array object
  11147. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11148. * @param vertexArrayObject defines the vertex array object to bind
  11149. * @param indexBuffer defines the index buffer to bind
  11150. */
  11151. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  11152. /**
  11153. * Bind webGl buffers directly to the webGL context
  11154. * @param vertexBuffer defines the vertex buffer to bind
  11155. * @param indexBuffer defines the index buffer to bind
  11156. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  11157. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  11158. * @param effect defines the effect associated with the vertex buffer
  11159. */
  11160. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  11161. private _unbindVertexArrayObject;
  11162. /**
  11163. * Bind a list of vertex buffers to the webGL context
  11164. * @param vertexBuffers defines the list of vertex buffers to bind
  11165. * @param indexBuffer defines the index buffer to bind
  11166. * @param effect defines the effect associated with the vertex buffers
  11167. */
  11168. bindBuffers(vertexBuffers: {
  11169. [key: string]: Nullable<VertexBuffer>;
  11170. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  11171. /**
  11172. * Unbind all instance attributes
  11173. */
  11174. unbindInstanceAttributes(): void;
  11175. /**
  11176. * Release and free the memory of a vertex array object
  11177. * @param vao defines the vertex array object to delete
  11178. */
  11179. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  11180. /** @hidden */
  11181. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11182. /**
  11183. * Creates a webGL buffer to use with instanciation
  11184. * @param capacity defines the size of the buffer
  11185. * @returns the webGL buffer
  11186. */
  11187. createInstancesBuffer(capacity: number): WebGLBuffer;
  11188. /**
  11189. * Delete a webGL buffer used with instanciation
  11190. * @param buffer defines the webGL buffer to delete
  11191. */
  11192. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  11193. /**
  11194. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  11195. * @param instancesBuffer defines the webGL buffer to update and bind
  11196. * @param data defines the data to store in the buffer
  11197. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  11198. */
  11199. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  11200. /**
  11201. * Apply all cached states (depth, culling, stencil and alpha)
  11202. */
  11203. applyStates(): void;
  11204. /**
  11205. * Send a draw order
  11206. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11207. * @param indexStart defines the starting index
  11208. * @param indexCount defines the number of index to draw
  11209. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11210. */
  11211. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11212. /**
  11213. * Draw a list of points
  11214. * @param verticesStart defines the index of first vertex to draw
  11215. * @param verticesCount defines the count of vertices to draw
  11216. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11217. */
  11218. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11219. /**
  11220. * Draw a list of unindexed primitives
  11221. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11222. * @param verticesStart defines the index of first vertex to draw
  11223. * @param verticesCount defines the count of vertices to draw
  11224. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11225. */
  11226. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11227. /**
  11228. * Draw a list of indexed primitives
  11229. * @param fillMode defines the primitive to use
  11230. * @param indexStart defines the starting index
  11231. * @param indexCount defines the number of index to draw
  11232. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11233. */
  11234. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11235. /**
  11236. * Draw a list of unindexed primitives
  11237. * @param fillMode defines the primitive to use
  11238. * @param verticesStart defines the index of first vertex to draw
  11239. * @param verticesCount defines the count of vertices to draw
  11240. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11241. */
  11242. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11243. private _drawMode;
  11244. /** @hidden */
  11245. _releaseEffect(effect: Effect): void;
  11246. /** @hidden */
  11247. _deleteProgram(program: WebGLProgram): void;
  11248. /**
  11249. * Create a new effect (used to store vertex/fragment shaders)
  11250. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11251. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11252. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11253. * @param samplers defines an array of string used to represent textures
  11254. * @param defines defines the string containing the defines to use to compile the shaders
  11255. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11256. * @param onCompiled defines a function to call when the effect creation is successful
  11257. * @param onError defines a function to call when the effect creation has failed
  11258. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11259. * @returns the new Effect
  11260. */
  11261. 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;
  11262. private _compileShader;
  11263. private _compileRawShader;
  11264. /**
  11265. * Directly creates a webGL program
  11266. * @param vertexCode defines the vertex shader code to use
  11267. * @param fragmentCode defines the fragment shader code to use
  11268. * @param context defines the webGL context to use (if not set, the current one will be used)
  11269. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11270. * @returns the new webGL program
  11271. */
  11272. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11273. /**
  11274. * Creates a webGL program
  11275. * @param vertexCode defines the vertex shader code to use
  11276. * @param fragmentCode defines the fragment shader code to use
  11277. * @param defines defines the string containing the defines to use to compile the shaders
  11278. * @param context defines the webGL context to use (if not set, the current one will be used)
  11279. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11280. * @returns the new webGL program
  11281. */
  11282. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11283. private _createShaderProgram;
  11284. private _finalizeProgram;
  11285. /** @hidden */
  11286. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11287. /** @hidden */
  11288. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11289. /**
  11290. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11291. * @param shaderProgram defines the webGL program to use
  11292. * @param uniformsNames defines the list of uniform names
  11293. * @returns an array of webGL uniform locations
  11294. */
  11295. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11296. /**
  11297. * Gets the lsit of active attributes for a given webGL program
  11298. * @param shaderProgram defines the webGL program to use
  11299. * @param attributesNames defines the list of attribute names to get
  11300. * @returns an array of indices indicating the offset of each attribute
  11301. */
  11302. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11303. /**
  11304. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11305. * @param effect defines the effect to activate
  11306. */
  11307. enableEffect(effect: Nullable<Effect>): void;
  11308. /**
  11309. * Set the value of an uniform to an array of int32
  11310. * @param uniform defines the webGL uniform location where to store the value
  11311. * @param array defines the array of int32 to store
  11312. */
  11313. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11314. /**
  11315. * Set the value of an uniform to an array of int32 (stored as vec2)
  11316. * @param uniform defines the webGL uniform location where to store the value
  11317. * @param array defines the array of int32 to store
  11318. */
  11319. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11320. /**
  11321. * Set the value of an uniform to an array of int32 (stored as vec3)
  11322. * @param uniform defines the webGL uniform location where to store the value
  11323. * @param array defines the array of int32 to store
  11324. */
  11325. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11326. /**
  11327. * Set the value of an uniform to an array of int32 (stored as vec4)
  11328. * @param uniform defines the webGL uniform location where to store the value
  11329. * @param array defines the array of int32 to store
  11330. */
  11331. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11332. /**
  11333. * Set the value of an uniform to an array of float32
  11334. * @param uniform defines the webGL uniform location where to store the value
  11335. * @param array defines the array of float32 to store
  11336. */
  11337. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11338. /**
  11339. * Set the value of an uniform to an array of float32 (stored as vec2)
  11340. * @param uniform defines the webGL uniform location where to store the value
  11341. * @param array defines the array of float32 to store
  11342. */
  11343. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11344. /**
  11345. * Set the value of an uniform to an array of float32 (stored as vec3)
  11346. * @param uniform defines the webGL uniform location where to store the value
  11347. * @param array defines the array of float32 to store
  11348. */
  11349. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11350. /**
  11351. * Set the value of an uniform to an array of float32 (stored as vec4)
  11352. * @param uniform defines the webGL uniform location where to store the value
  11353. * @param array defines the array of float32 to store
  11354. */
  11355. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11356. /**
  11357. * Set the value of an uniform to an array of number
  11358. * @param uniform defines the webGL uniform location where to store the value
  11359. * @param array defines the array of number to store
  11360. */
  11361. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11362. /**
  11363. * Set the value of an uniform to an array of number (stored as vec2)
  11364. * @param uniform defines the webGL uniform location where to store the value
  11365. * @param array defines the array of number to store
  11366. */
  11367. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11368. /**
  11369. * Set the value of an uniform to an array of number (stored as vec3)
  11370. * @param uniform defines the webGL uniform location where to store the value
  11371. * @param array defines the array of number to store
  11372. */
  11373. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11374. /**
  11375. * Set the value of an uniform to an array of number (stored as vec4)
  11376. * @param uniform defines the webGL uniform location where to store the value
  11377. * @param array defines the array of number to store
  11378. */
  11379. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11380. /**
  11381. * Set the value of an uniform to an array of float32 (stored as matrices)
  11382. * @param uniform defines the webGL uniform location where to store the value
  11383. * @param matrices defines the array of float32 to store
  11384. */
  11385. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11386. /**
  11387. * Set the value of an uniform to a matrix
  11388. * @param uniform defines the webGL uniform location where to store the value
  11389. * @param matrix defines the matrix to store
  11390. */
  11391. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11392. /**
  11393. * Set the value of an uniform to a matrix (3x3)
  11394. * @param uniform defines the webGL uniform location where to store the value
  11395. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11396. */
  11397. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11398. /**
  11399. * Set the value of an uniform to a matrix (2x2)
  11400. * @param uniform defines the webGL uniform location where to store the value
  11401. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11402. */
  11403. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11404. /**
  11405. * Set the value of an uniform to a number (int)
  11406. * @param uniform defines the webGL uniform location where to store the value
  11407. * @param value defines the int number to store
  11408. */
  11409. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11410. /**
  11411. * Set the value of an uniform to a number (float)
  11412. * @param uniform defines the webGL uniform location where to store the value
  11413. * @param value defines the float number to store
  11414. */
  11415. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11416. /**
  11417. * Set the value of an uniform to a vec2
  11418. * @param uniform defines the webGL uniform location where to store the value
  11419. * @param x defines the 1st component of the value
  11420. * @param y defines the 2nd component of the value
  11421. */
  11422. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11423. /**
  11424. * Set the value of an uniform to a vec3
  11425. * @param uniform defines the webGL uniform location where to store the value
  11426. * @param x defines the 1st component of the value
  11427. * @param y defines the 2nd component of the value
  11428. * @param z defines the 3rd component of the value
  11429. */
  11430. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11431. /**
  11432. * Set the value of an uniform to a boolean
  11433. * @param uniform defines the webGL uniform location where to store the value
  11434. * @param bool defines the boolean to store
  11435. */
  11436. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11437. /**
  11438. * Set the value of an uniform to a vec4
  11439. * @param uniform defines the webGL uniform location where to store the value
  11440. * @param x defines the 1st component of the value
  11441. * @param y defines the 2nd component of the value
  11442. * @param z defines the 3rd component of the value
  11443. * @param w defines the 4th component of the value
  11444. */
  11445. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11446. /**
  11447. * Set the value of an uniform to a Color3
  11448. * @param uniform defines the webGL uniform location where to store the value
  11449. * @param color3 defines the color to store
  11450. */
  11451. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11452. /**
  11453. * Set the value of an uniform to a Color3 and an alpha value
  11454. * @param uniform defines the webGL uniform location where to store the value
  11455. * @param color3 defines the color to store
  11456. * @param alpha defines the alpha component to store
  11457. */
  11458. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11459. /**
  11460. * Sets a Color4 on a uniform variable
  11461. * @param uniform defines the uniform location
  11462. * @param color4 defines the value to be set
  11463. */
  11464. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11465. /**
  11466. * Set various states to the webGL context
  11467. * @param culling defines backface culling state
  11468. * @param zOffset defines the value to apply to zOffset (0 by default)
  11469. * @param force defines if states must be applied even if cache is up to date
  11470. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11471. */
  11472. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11473. /**
  11474. * Set the z offset to apply to current rendering
  11475. * @param value defines the offset to apply
  11476. */
  11477. setZOffset(value: number): void;
  11478. /**
  11479. * Gets the current value of the zOffset
  11480. * @returns the current zOffset state
  11481. */
  11482. getZOffset(): number;
  11483. /**
  11484. * Enable or disable depth buffering
  11485. * @param enable defines the state to set
  11486. */
  11487. setDepthBuffer(enable: boolean): void;
  11488. /**
  11489. * Gets a boolean indicating if depth writing is enabled
  11490. * @returns the current depth writing state
  11491. */
  11492. getDepthWrite(): boolean;
  11493. /**
  11494. * Enable or disable depth writing
  11495. * @param enable defines the state to set
  11496. */
  11497. setDepthWrite(enable: boolean): void;
  11498. /**
  11499. * Enable or disable color writing
  11500. * @param enable defines the state to set
  11501. */
  11502. setColorWrite(enable: boolean): void;
  11503. /**
  11504. * Gets a boolean indicating if color writing is enabled
  11505. * @returns the current color writing state
  11506. */
  11507. getColorWrite(): boolean;
  11508. /**
  11509. * Sets alpha constants used by some alpha blending modes
  11510. * @param r defines the red component
  11511. * @param g defines the green component
  11512. * @param b defines the blue component
  11513. * @param a defines the alpha component
  11514. */
  11515. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11516. /**
  11517. * Sets the current alpha mode
  11518. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11519. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11520. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11521. */
  11522. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11523. /**
  11524. * Gets the current alpha mode
  11525. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11526. * @returns the current alpha mode
  11527. */
  11528. getAlphaMode(): number;
  11529. /**
  11530. * Clears the list of texture accessible through engine.
  11531. * This can help preventing texture load conflict due to name collision.
  11532. */
  11533. clearInternalTexturesCache(): void;
  11534. /**
  11535. * Force the entire cache to be cleared
  11536. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11537. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11538. */
  11539. wipeCaches(bruteForce?: boolean): void;
  11540. /**
  11541. * Set the compressed texture format to use, based on the formats you have, and the formats
  11542. * supported by the hardware / browser.
  11543. *
  11544. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11545. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11546. * to API arguments needed to compressed textures. This puts the burden on the container
  11547. * generator to house the arcane code for determining these for current & future formats.
  11548. *
  11549. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11550. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11551. *
  11552. * Note: The result of this call is not taken into account when a texture is base64.
  11553. *
  11554. * @param formatsAvailable defines the list of those format families you have created
  11555. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11556. *
  11557. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11558. * @returns The extension selected.
  11559. */
  11560. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11561. private _getSamplingParameters;
  11562. private _partialLoadImg;
  11563. private _cascadeLoadImgs;
  11564. /** @hidden */
  11565. _createTexture(): WebGLTexture;
  11566. /**
  11567. * Usually called from BABYLON.Texture.ts.
  11568. * Passed information to create a WebGLTexture
  11569. * @param urlArg defines a value which contains one of the following:
  11570. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11571. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11572. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11573. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11574. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  11575. * @param scene needed for loading to the correct scene
  11576. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11577. * @param onLoad optional callback to be called upon successful completion
  11578. * @param onError optional callback to be called upon failure
  11579. * @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
  11580. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11581. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11582. * @param forcedExtension defines the extension to use to pick the right loader
  11583. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  11584. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11585. */
  11586. 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;
  11587. private _rescaleTexture;
  11588. /**
  11589. * Update a raw texture
  11590. * @param texture defines the texture to update
  11591. * @param data defines the data to store in the texture
  11592. * @param format defines the format of the data
  11593. * @param invertY defines if data must be stored with Y axis inverted
  11594. * @param compression defines the compression used (null by default)
  11595. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11596. */
  11597. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11598. /**
  11599. * Creates a raw texture
  11600. * @param data defines the data to store in the texture
  11601. * @param width defines the width of the texture
  11602. * @param height defines the height of the texture
  11603. * @param format defines the format of the data
  11604. * @param generateMipMaps defines if the engine should generate the mip levels
  11605. * @param invertY defines if data must be stored with Y axis inverted
  11606. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11607. * @param compression defines the compression used (null by default)
  11608. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11609. * @returns the raw texture inside an InternalTexture
  11610. */
  11611. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11612. private _unpackFlipYCached;
  11613. /**
  11614. * In case you are sharing the context with other applications, it might
  11615. * be interested to not cache the unpack flip y state to ensure a consistent
  11616. * value would be set.
  11617. */
  11618. enableUnpackFlipYCached: boolean;
  11619. /** @hidden */
  11620. _unpackFlipY(value: boolean): void;
  11621. /** @hidden */
  11622. _getUnpackAlignement(): number;
  11623. /**
  11624. * Creates a dynamic texture
  11625. * @param width defines the width of the texture
  11626. * @param height defines the height of the texture
  11627. * @param generateMipMaps defines if the engine should generate the mip levels
  11628. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11629. * @returns the dynamic texture inside an InternalTexture
  11630. */
  11631. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11632. /**
  11633. * Update the sampling mode of a given texture
  11634. * @param samplingMode defines the required sampling mode
  11635. * @param texture defines the texture to update
  11636. */
  11637. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11638. /**
  11639. * Update the content of a dynamic texture
  11640. * @param texture defines the texture to update
  11641. * @param canvas defines the canvas containing the source
  11642. * @param invertY defines if data must be stored with Y axis inverted
  11643. * @param premulAlpha defines if alpha is stored as premultiplied
  11644. * @param format defines the format of the data
  11645. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11646. */
  11647. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11648. /**
  11649. * Update a video texture
  11650. * @param texture defines the texture to update
  11651. * @param video defines the video element to use
  11652. * @param invertY defines if data must be stored with Y axis inverted
  11653. */
  11654. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11655. /**
  11656. * Updates a depth texture Comparison Mode and Function.
  11657. * If the comparison Function is equal to 0, the mode will be set to none.
  11658. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11659. * @param texture The texture to set the comparison function for
  11660. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11661. */
  11662. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11663. private _setupDepthStencilTexture;
  11664. /**
  11665. * Creates a depth stencil texture.
  11666. * This is only available in WebGL 2 or with the depth texture extension available.
  11667. * @param size The size of face edge in the texture.
  11668. * @param options The options defining the texture.
  11669. * @returns The texture
  11670. */
  11671. createDepthStencilTexture(size: number | {
  11672. width: number;
  11673. height: number;
  11674. }, options: DepthTextureCreationOptions): InternalTexture;
  11675. /**
  11676. * Creates a depth stencil texture.
  11677. * This is only available in WebGL 2 or with the depth texture extension available.
  11678. * @param size The size of face edge in the texture.
  11679. * @param options The options defining the texture.
  11680. * @returns The texture
  11681. */
  11682. private _createDepthStencilTexture;
  11683. /**
  11684. * Creates a depth stencil cube texture.
  11685. * This is only available in WebGL 2.
  11686. * @param size The size of face edge in the cube texture.
  11687. * @param options The options defining the cube texture.
  11688. * @returns The cube texture
  11689. */
  11690. private _createDepthStencilCubeTexture;
  11691. /**
  11692. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11693. * @param renderTarget The render target to set the frame buffer for
  11694. */
  11695. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11696. /**
  11697. * Creates a new render target texture
  11698. * @param size defines the size of the texture
  11699. * @param options defines the options used to create the texture
  11700. * @returns a new render target texture stored in an InternalTexture
  11701. */
  11702. createRenderTargetTexture(size: number | {
  11703. width: number;
  11704. height: number;
  11705. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11706. /**
  11707. * Create a multi render target texture
  11708. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11709. * @param size defines the size of the texture
  11710. * @param options defines the creation options
  11711. * @returns the cube texture as an InternalTexture
  11712. */
  11713. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11714. private _setupFramebufferDepthAttachments;
  11715. /**
  11716. * Updates the sample count of a render target texture
  11717. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11718. * @param texture defines the texture to update
  11719. * @param samples defines the sample count to set
  11720. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11721. */
  11722. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11723. /**
  11724. * Update the sample count for a given multiple render target texture
  11725. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11726. * @param textures defines the textures to update
  11727. * @param samples defines the sample count to set
  11728. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11729. */
  11730. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11731. /** @hidden */
  11732. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11733. /** @hidden */
  11734. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11735. /** @hidden */
  11736. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11737. /** @hidden */
  11738. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11739. /**
  11740. * Creates a new render target cube texture
  11741. * @param size defines the size of the texture
  11742. * @param options defines the options used to create the texture
  11743. * @returns a new render target cube texture stored in an InternalTexture
  11744. */
  11745. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11746. /**
  11747. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11748. * @param rootUrl defines the url where the file to load is located
  11749. * @param scene defines the current scene
  11750. * @param lodScale defines scale to apply to the mip map selection
  11751. * @param lodOffset defines offset to apply to the mip map selection
  11752. * @param onLoad defines an optional callback raised when the texture is loaded
  11753. * @param onError defines an optional callback raised if there is an issue to load the texture
  11754. * @param format defines the format of the data
  11755. * @param forcedExtension defines the extension to use to pick the right loader
  11756. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11757. * @returns the cube texture as an InternalTexture
  11758. */
  11759. 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;
  11760. /**
  11761. * Creates a cube texture
  11762. * @param rootUrl defines the url where the files to load is located
  11763. * @param scene defines the current scene
  11764. * @param files defines the list of files to load (1 per face)
  11765. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11766. * @param onLoad defines an optional callback raised when the texture is loaded
  11767. * @param onError defines an optional callback raised if there is an issue to load the texture
  11768. * @param format defines the format of the data
  11769. * @param forcedExtension defines the extension to use to pick the right loader
  11770. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11771. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11772. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11773. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11774. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  11775. * @returns the cube texture as an InternalTexture
  11776. */
  11777. 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;
  11778. /**
  11779. * @hidden
  11780. */
  11781. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11782. /**
  11783. * Update a raw cube texture
  11784. * @param texture defines the texture to udpdate
  11785. * @param data defines the data to store
  11786. * @param format defines the data format
  11787. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11788. * @param invertY defines if data must be stored with Y axis inverted
  11789. * @param compression defines the compression used (null by default)
  11790. * @param level defines which level of the texture to update
  11791. */
  11792. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11793. /**
  11794. * Creates a new raw cube texture
  11795. * @param data defines the array of data to use to create each face
  11796. * @param size defines the size of the textures
  11797. * @param format defines the format of the data
  11798. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11799. * @param generateMipMaps defines if the engine should generate the mip levels
  11800. * @param invertY defines if data must be stored with Y axis inverted
  11801. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11802. * @param compression defines the compression used (null by default)
  11803. * @returns the cube texture as an InternalTexture
  11804. */
  11805. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11806. /**
  11807. * Creates a new raw cube texture from a specified url
  11808. * @param url defines the url where the data is located
  11809. * @param scene defines the current scene
  11810. * @param size defines the size of the textures
  11811. * @param format defines the format of the data
  11812. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11813. * @param noMipmap defines if the engine should avoid generating the mip levels
  11814. * @param callback defines a callback used to extract texture data from loaded data
  11815. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11816. * @param onLoad defines a callback called when texture is loaded
  11817. * @param onError defines a callback called if there is an error
  11818. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11819. * @param invertY defines if data must be stored with Y axis inverted
  11820. * @returns the cube texture as an InternalTexture
  11821. */
  11822. 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;
  11823. /**
  11824. * Update a raw 3D texture
  11825. * @param texture defines the texture to update
  11826. * @param data defines the data to store
  11827. * @param format defines the data format
  11828. * @param invertY defines if data must be stored with Y axis inverted
  11829. * @param compression defines the used compression (can be null)
  11830. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11831. */
  11832. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11833. /**
  11834. * Creates a new raw 3D texture
  11835. * @param data defines the data used to create the texture
  11836. * @param width defines the width of the texture
  11837. * @param height defines the height of the texture
  11838. * @param depth defines the depth of the texture
  11839. * @param format defines the format of the texture
  11840. * @param generateMipMaps defines if the engine must generate mip levels
  11841. * @param invertY defines if data must be stored with Y axis inverted
  11842. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11843. * @param compression defines the compressed used (can be null)
  11844. * @param textureType defines the compressed used (can be null)
  11845. * @returns a new raw 3D texture (stored in an InternalTexture)
  11846. */
  11847. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11848. private _prepareWebGLTextureContinuation;
  11849. private _prepareWebGLTexture;
  11850. private _convertRGBtoRGBATextureData;
  11851. /** @hidden */
  11852. _releaseFramebufferObjects(texture: InternalTexture): void;
  11853. /** @hidden */
  11854. _releaseTexture(texture: InternalTexture): void;
  11855. private setProgram;
  11856. private _boundUniforms;
  11857. /**
  11858. * Binds an effect to the webGL context
  11859. * @param effect defines the effect to bind
  11860. */
  11861. bindSamplers(effect: Effect): void;
  11862. private _moveBoundTextureOnTop;
  11863. private _getCorrectTextureChannel;
  11864. private _linkTrackers;
  11865. private _removeDesignatedSlot;
  11866. private _activateCurrentTexture;
  11867. /** @hidden */
  11868. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11869. /** @hidden */
  11870. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11871. /**
  11872. * Sets a texture to the webGL context from a postprocess
  11873. * @param channel defines the channel to use
  11874. * @param postProcess defines the source postprocess
  11875. */
  11876. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11877. /**
  11878. * Binds the output of the passed in post process to the texture channel specified
  11879. * @param channel The channel the texture should be bound to
  11880. * @param postProcess The post process which's output should be bound
  11881. */
  11882. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11883. /**
  11884. * Unbind all textures from the webGL context
  11885. */
  11886. unbindAllTextures(): void;
  11887. /**
  11888. * Sets a texture to the according uniform.
  11889. * @param channel The texture channel
  11890. * @param uniform The uniform to set
  11891. * @param texture The texture to apply
  11892. */
  11893. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11894. /**
  11895. * Sets a depth stencil texture from a render target to the according uniform.
  11896. * @param channel The texture channel
  11897. * @param uniform The uniform to set
  11898. * @param texture The render target texture containing the depth stencil texture to apply
  11899. */
  11900. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11901. private _bindSamplerUniformToChannel;
  11902. private _getTextureWrapMode;
  11903. private _setTexture;
  11904. /**
  11905. * Sets an array of texture to the webGL context
  11906. * @param channel defines the channel where the texture array must be set
  11907. * @param uniform defines the associated uniform location
  11908. * @param textures defines the array of textures to bind
  11909. */
  11910. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11911. /** @hidden */
  11912. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11913. private _setTextureParameterFloat;
  11914. private _setTextureParameterInteger;
  11915. /**
  11916. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11917. * @param x defines the x coordinate of the rectangle where pixels must be read
  11918. * @param y defines the y coordinate of the rectangle where pixels must be read
  11919. * @param width defines the width of the rectangle where pixels must be read
  11920. * @param height defines the height of the rectangle where pixels must be read
  11921. * @returns a Uint8Array containing RGBA colors
  11922. */
  11923. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11924. /**
  11925. * Add an externaly attached data from its key.
  11926. * This method call will fail and return false, if such key already exists.
  11927. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11928. * @param key the unique key that identifies the data
  11929. * @param data the data object to associate to the key for this Engine instance
  11930. * @return true if no such key were already present and the data was added successfully, false otherwise
  11931. */
  11932. addExternalData<T>(key: string, data: T): boolean;
  11933. /**
  11934. * Get an externaly attached data from its key
  11935. * @param key the unique key that identifies the data
  11936. * @return the associated data, if present (can be null), or undefined if not present
  11937. */
  11938. getExternalData<T>(key: string): T;
  11939. /**
  11940. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11941. * @param key the unique key that identifies the data
  11942. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  11943. * @return the associated data, can be null if the factory returned null.
  11944. */
  11945. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  11946. /**
  11947. * Remove an externaly attached data from the Engine instance
  11948. * @param key the unique key that identifies the data
  11949. * @return true if the data was successfully removed, false if it doesn't exist
  11950. */
  11951. removeExternalData(key: string): boolean;
  11952. /**
  11953. * Unbind all vertex attributes from the webGL context
  11954. */
  11955. unbindAllAttributes(): void;
  11956. /**
  11957. * 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
  11958. */
  11959. releaseEffects(): void;
  11960. /**
  11961. * Dispose and release all associated resources
  11962. */
  11963. dispose(): void;
  11964. /**
  11965. * Display the loading screen
  11966. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11967. */
  11968. displayLoadingUI(): void;
  11969. /**
  11970. * Hide the loading screen
  11971. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11972. */
  11973. hideLoadingUI(): void;
  11974. /**
  11975. * Gets the current loading screen object
  11976. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11977. */
  11978. /**
  11979. * Sets the current loading screen object
  11980. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11981. */
  11982. loadingScreen: ILoadingScreen;
  11983. /**
  11984. * Sets the current loading screen text
  11985. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11986. */
  11987. loadingUIText: string;
  11988. /**
  11989. * Sets the current loading screen background color
  11990. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11991. */
  11992. loadingUIBackgroundColor: string;
  11993. /**
  11994. * Attach a new callback raised when context lost event is fired
  11995. * @param callback defines the callback to call
  11996. */
  11997. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11998. /**
  11999. * Attach a new callback raised when context restored event is fired
  12000. * @param callback defines the callback to call
  12001. */
  12002. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  12003. /**
  12004. * Gets the source code of the vertex shader associated with a specific webGL program
  12005. * @param program defines the program to use
  12006. * @returns a string containing the source code of the vertex shader associated with the program
  12007. */
  12008. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  12009. /**
  12010. * Gets the source code of the fragment shader associated with a specific webGL program
  12011. * @param program defines the program to use
  12012. * @returns a string containing the source code of the fragment shader associated with the program
  12013. */
  12014. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  12015. /**
  12016. * Get the current error code of the webGL context
  12017. * @returns the error code
  12018. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12019. */
  12020. getError(): number;
  12021. /**
  12022. * Gets the current framerate
  12023. * @returns a number representing the framerate
  12024. */
  12025. getFps(): number;
  12026. /**
  12027. * Gets the time spent between current and previous frame
  12028. * @returns a number representing the delta time in ms
  12029. */
  12030. getDeltaTime(): number;
  12031. private _measureFps;
  12032. /** @hidden */
  12033. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  12034. private _canRenderToFloatFramebuffer;
  12035. private _canRenderToHalfFloatFramebuffer;
  12036. private _canRenderToFramebuffer;
  12037. /** @hidden */
  12038. _getWebGLTextureType(type: number): number;
  12039. private _getInternalFormat;
  12040. /** @hidden */
  12041. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  12042. /** @hidden */
  12043. _getRGBAMultiSampleBufferFormat(type: number): number;
  12044. /** @hidden */
  12045. _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;
  12046. /** @hidden */
  12047. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  12048. private _partialLoadFile;
  12049. private _cascadeLoadFiles;
  12050. /**
  12051. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  12052. * @returns true if the engine can be created
  12053. * @ignorenaming
  12054. */
  12055. static isSupported(): boolean;
  12056. }
  12057. }
  12058. declare module BABYLON {
  12059. /**
  12060. * Options to create the null engine
  12061. */
  12062. class NullEngineOptions {
  12063. /**
  12064. * Render width (Default: 512)
  12065. */
  12066. renderWidth: number;
  12067. /**
  12068. * Render height (Default: 256)
  12069. */
  12070. renderHeight: number;
  12071. /**
  12072. * Texture size (Default: 512)
  12073. */
  12074. textureSize: number;
  12075. /**
  12076. * If delta time between frames should be constant
  12077. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12078. */
  12079. deterministicLockstep: boolean;
  12080. /**
  12081. * Maximum about of steps between frames (Default: 4)
  12082. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12083. */
  12084. lockstepMaxSteps: number;
  12085. }
  12086. /**
  12087. * The null engine class provides support for headless version of babylon.js.
  12088. * This can be used in server side scenario or for testing purposes
  12089. */
  12090. class NullEngine extends Engine {
  12091. private _options;
  12092. /**
  12093. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12094. */
  12095. isDeterministicLockStep(): boolean;
  12096. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  12097. getLockstepMaxSteps(): number;
  12098. /**
  12099. * Sets hardware scaling, used to save performance if needed
  12100. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  12101. */
  12102. getHardwareScalingLevel(): number;
  12103. constructor(options?: NullEngineOptions);
  12104. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12105. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  12106. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  12107. getRenderWidth(useScreen?: boolean): number;
  12108. getRenderHeight(useScreen?: boolean): number;
  12109. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  12110. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  12111. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  12112. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  12113. bindSamplers(effect: Effect): void;
  12114. enableEffect(effect: Effect): void;
  12115. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  12116. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  12117. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  12118. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  12119. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  12120. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  12121. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  12122. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  12123. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  12124. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  12125. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  12126. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  12127. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  12128. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  12129. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  12130. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12131. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12132. setFloat(uniform: WebGLUniformLocation, value: number): void;
  12133. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  12134. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  12135. setBool(uniform: WebGLUniformLocation, bool: number): void;
  12136. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  12137. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  12138. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  12139. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12140. bindBuffers(vertexBuffers: {
  12141. [key: string]: VertexBuffer;
  12142. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  12143. wipeCaches(bruteForce?: boolean): void;
  12144. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  12145. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  12146. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  12147. /** @hidden */
  12148. _createTexture(): WebGLTexture;
  12149. /** @hidden */
  12150. _releaseTexture(texture: InternalTexture): void;
  12151. 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;
  12152. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12153. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  12154. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  12155. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  12156. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12157. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  12158. areAllEffectsReady(): boolean;
  12159. /**
  12160. * @hidden
  12161. * Get the current error code of the webGL context
  12162. * @returns the error code
  12163. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12164. */
  12165. getError(): number;
  12166. /** @hidden */
  12167. _getUnpackAlignement(): number;
  12168. /** @hidden */
  12169. _unpackFlipY(value: boolean): void;
  12170. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  12171. /**
  12172. * Updates a dynamic vertex buffer.
  12173. * @param vertexBuffer the vertex buffer to update
  12174. * @param data the data used to update the vertex buffer
  12175. * @param byteOffset the byte offset of the data (optional)
  12176. * @param byteLength the byte length of the data (optional)
  12177. */
  12178. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  12179. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  12180. /** @hidden */
  12181. _bindTexture(channel: number, texture: InternalTexture): void;
  12182. /** @hidden */
  12183. _releaseBuffer(buffer: WebGLBuffer): boolean;
  12184. releaseEffects(): void;
  12185. displayLoadingUI(): void;
  12186. hideLoadingUI(): void;
  12187. /** @hidden */
  12188. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12189. /** @hidden */
  12190. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12191. /** @hidden */
  12192. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12193. /** @hidden */
  12194. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  12195. }
  12196. }
  12197. interface WebGLRenderingContext {
  12198. readonly RASTERIZER_DISCARD: number;
  12199. readonly DEPTH_COMPONENT24: number;
  12200. readonly TEXTURE_3D: number;
  12201. readonly TEXTURE_2D_ARRAY: number;
  12202. readonly TEXTURE_COMPARE_FUNC: number;
  12203. readonly TEXTURE_COMPARE_MODE: number;
  12204. readonly COMPARE_REF_TO_TEXTURE: number;
  12205. readonly TEXTURE_WRAP_R: number;
  12206. readonly HALF_FLOAT: number;
  12207. readonly RGB8: number;
  12208. readonly RED_INTEGER: number;
  12209. readonly RG_INTEGER: number;
  12210. readonly RGB_INTEGER: number;
  12211. readonly RGBA_INTEGER: number;
  12212. readonly R8_SNORM: number;
  12213. readonly RG8_SNORM: number;
  12214. readonly RGB8_SNORM: number;
  12215. readonly RGBA8_SNORM: number;
  12216. readonly R8I: number;
  12217. readonly RG8I: number;
  12218. readonly RGB8I: number;
  12219. readonly RGBA8I: number;
  12220. readonly R8UI: number;
  12221. readonly RG8UI: number;
  12222. readonly RGB8UI: number;
  12223. readonly RGBA8UI: number;
  12224. readonly R16I: number;
  12225. readonly RG16I: number;
  12226. readonly RGB16I: number;
  12227. readonly RGBA16I: number;
  12228. readonly R16UI: number;
  12229. readonly RG16UI: number;
  12230. readonly RGB16UI: number;
  12231. readonly RGBA16UI: number;
  12232. readonly R32I: number;
  12233. readonly RG32I: number;
  12234. readonly RGB32I: number;
  12235. readonly RGBA32I: number;
  12236. readonly R32UI: number;
  12237. readonly RG32UI: number;
  12238. readonly RGB32UI: number;
  12239. readonly RGBA32UI: number;
  12240. readonly RGB10_A2UI: number;
  12241. readonly R11F_G11F_B10F: number;
  12242. readonly RGB9_E5: number;
  12243. readonly RGB10_A2: number;
  12244. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12245. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12246. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12247. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12248. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12249. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12250. 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;
  12251. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12252. readonly TRANSFORM_FEEDBACK: number;
  12253. readonly INTERLEAVED_ATTRIBS: number;
  12254. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12255. createTransformFeedback(): WebGLTransformFeedback;
  12256. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12257. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12258. beginTransformFeedback(primitiveMode: number): void;
  12259. endTransformFeedback(): void;
  12260. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12261. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12262. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12263. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12264. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12265. }
  12266. interface ImageBitmap {
  12267. readonly width: number;
  12268. readonly height: number;
  12269. close(): void;
  12270. }
  12271. interface WebGLQuery extends WebGLObject {
  12272. }
  12273. declare var WebGLQuery: {
  12274. prototype: WebGLQuery;
  12275. new (): WebGLQuery;
  12276. };
  12277. interface WebGLSampler extends WebGLObject {
  12278. }
  12279. declare var WebGLSampler: {
  12280. prototype: WebGLSampler;
  12281. new (): WebGLSampler;
  12282. };
  12283. interface WebGLSync extends WebGLObject {
  12284. }
  12285. declare var WebGLSync: {
  12286. prototype: WebGLSync;
  12287. new (): WebGLSync;
  12288. };
  12289. interface WebGLTransformFeedback extends WebGLObject {
  12290. }
  12291. declare var WebGLTransformFeedback: {
  12292. prototype: WebGLTransformFeedback;
  12293. new (): WebGLTransformFeedback;
  12294. };
  12295. interface WebGLVertexArrayObject extends WebGLObject {
  12296. }
  12297. declare var WebGLVertexArrayObject: {
  12298. prototype: WebGLVertexArrayObject;
  12299. new (): WebGLVertexArrayObject;
  12300. };
  12301. declare module BABYLON {
  12302. /**
  12303. * Gather the list of clipboard event types as constants.
  12304. */
  12305. class ClipboardEventTypes {
  12306. /**
  12307. * The clipboard event is fired when a copy command is active (pressed).
  12308. */
  12309. static readonly COPY: number;
  12310. /**
  12311. * The clipboard event is fired when a cut command is active (pressed).
  12312. */
  12313. static readonly CUT: number;
  12314. /**
  12315. * The clipboard event is fired when a paste command is active (pressed).
  12316. */
  12317. static readonly PASTE: number;
  12318. }
  12319. /**
  12320. * This class is used to store clipboard related info for the onClipboardObservable event.
  12321. */
  12322. class ClipboardInfo {
  12323. /**
  12324. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12325. */
  12326. type: number;
  12327. /**
  12328. * Defines the related dom event
  12329. */
  12330. event: ClipboardEvent;
  12331. /**
  12332. *Creates an instance of ClipboardInfo.
  12333. * @param {number} type
  12334. * @param {ClipboardEvent} event
  12335. */
  12336. constructor(
  12337. /**
  12338. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12339. */
  12340. type: number,
  12341. /**
  12342. * Defines the related dom event
  12343. */
  12344. event: ClipboardEvent);
  12345. /**
  12346. * Get the clipboard event's type from the keycode.
  12347. * @param keyCode Defines the keyCode for the current keyboard event.
  12348. * @return {number}
  12349. */
  12350. static GetTypeFromCharacter(keyCode: number): number;
  12351. }
  12352. }
  12353. declare module BABYLON {
  12354. /**
  12355. * Gather the list of keyboard event types as constants.
  12356. */
  12357. class KeyboardEventTypes {
  12358. /**
  12359. * The keydown event is fired when a key becomes active (pressed).
  12360. */
  12361. static readonly KEYDOWN: number;
  12362. /**
  12363. * The keyup event is fired when a key has been released.
  12364. */
  12365. static readonly KEYUP: number;
  12366. }
  12367. /**
  12368. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12369. */
  12370. class KeyboardInfo {
  12371. /**
  12372. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12373. */
  12374. type: number;
  12375. /**
  12376. * Defines the related dom event
  12377. */
  12378. event: KeyboardEvent;
  12379. /**
  12380. * Instantiates a new keyboard info.
  12381. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12382. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12383. * @param event Defines the related dom event
  12384. */
  12385. constructor(
  12386. /**
  12387. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12388. */
  12389. type: number,
  12390. /**
  12391. * Defines the related dom event
  12392. */
  12393. event: KeyboardEvent);
  12394. }
  12395. /**
  12396. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12397. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12398. */
  12399. class KeyboardInfoPre extends KeyboardInfo {
  12400. /**
  12401. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12402. */
  12403. type: number;
  12404. /**
  12405. * Defines the related dom event
  12406. */
  12407. event: KeyboardEvent;
  12408. /**
  12409. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12410. */
  12411. skipOnPointerObservable: boolean;
  12412. /**
  12413. * Instantiates a new keyboard pre info.
  12414. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12415. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12416. * @param event Defines the related dom event
  12417. */
  12418. constructor(
  12419. /**
  12420. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12421. */
  12422. type: number,
  12423. /**
  12424. * Defines the related dom event
  12425. */
  12426. event: KeyboardEvent);
  12427. }
  12428. }
  12429. declare module BABYLON {
  12430. /**
  12431. * Gather the list of pointer event types as constants.
  12432. */
  12433. class PointerEventTypes {
  12434. /**
  12435. * 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.
  12436. */
  12437. static readonly POINTERDOWN: number;
  12438. /**
  12439. * The pointerup event is fired when a pointer is no longer active.
  12440. */
  12441. static readonly POINTERUP: number;
  12442. /**
  12443. * The pointermove event is fired when a pointer changes coordinates.
  12444. */
  12445. static readonly POINTERMOVE: number;
  12446. /**
  12447. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12448. */
  12449. static readonly POINTERWHEEL: number;
  12450. /**
  12451. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12452. */
  12453. static readonly POINTERPICK: number;
  12454. /**
  12455. * The pointertap event is fired when a the object has been touched and released without drag.
  12456. */
  12457. static readonly POINTERTAP: number;
  12458. /**
  12459. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12460. */
  12461. static readonly POINTERDOUBLETAP: number;
  12462. }
  12463. /**
  12464. * Base class of pointer info types.
  12465. */
  12466. class PointerInfoBase {
  12467. /**
  12468. * Defines the type of event (BABYLON.PointerEventTypes)
  12469. */
  12470. type: number;
  12471. /**
  12472. * Defines the related dom event
  12473. */
  12474. event: PointerEvent | MouseWheelEvent;
  12475. /**
  12476. * Instantiates the base class of pointers info.
  12477. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12478. * @param event Defines the related dom event
  12479. */
  12480. constructor(
  12481. /**
  12482. * Defines the type of event (BABYLON.PointerEventTypes)
  12483. */
  12484. type: number,
  12485. /**
  12486. * Defines the related dom event
  12487. */
  12488. event: PointerEvent | MouseWheelEvent);
  12489. }
  12490. /**
  12491. * This class is used to store pointer related info for the onPrePointerObservable event.
  12492. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12493. */
  12494. class PointerInfoPre extends PointerInfoBase {
  12495. /**
  12496. * Ray from a pointer if availible (eg. 6dof controller)
  12497. */
  12498. ray: Nullable<Ray>;
  12499. /**
  12500. * Defines the local position of the pointer on the canvas.
  12501. */
  12502. localPosition: Vector2;
  12503. /**
  12504. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12505. */
  12506. skipOnPointerObservable: boolean;
  12507. /**
  12508. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12509. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12510. * @param event Defines the related dom event
  12511. * @param localX Defines the local x coordinates of the pointer when the event occured
  12512. * @param localY Defines the local y coordinates of the pointer when the event occured
  12513. */
  12514. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12515. }
  12516. /**
  12517. * This type contains all the data related to a pointer event in Babylon.js.
  12518. * 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.
  12519. */
  12520. class PointerInfo extends PointerInfoBase {
  12521. /**
  12522. * Defines the picking info associated to the info (if any)\
  12523. */
  12524. pickInfo: Nullable<PickingInfo>;
  12525. /**
  12526. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12527. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12528. * @param event Defines the related dom event
  12529. * @param pickInfo Defines the picking info associated to the info (if any)\
  12530. */
  12531. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12532. /**
  12533. * Defines the picking info associated to the info (if any)\
  12534. */
  12535. pickInfo: Nullable<PickingInfo>);
  12536. }
  12537. }
  12538. declare module BABYLON {
  12539. /**
  12540. * Represents a gamepad control stick position
  12541. */
  12542. class StickValues {
  12543. /**
  12544. * The x component of the control stick
  12545. */
  12546. x: number;
  12547. /**
  12548. * The y component of the control stick
  12549. */
  12550. y: number;
  12551. /**
  12552. * Initializes the gamepad x and y control stick values
  12553. * @param x The x component of the gamepad control stick value
  12554. * @param y The y component of the gamepad control stick value
  12555. */
  12556. constructor(
  12557. /**
  12558. * The x component of the control stick
  12559. */
  12560. x: number,
  12561. /**
  12562. * The y component of the control stick
  12563. */
  12564. y: number);
  12565. }
  12566. /**
  12567. * An interface which manages callbacks for gamepad button changes
  12568. */
  12569. interface GamepadButtonChanges {
  12570. /**
  12571. * Called when a gamepad has been changed
  12572. */
  12573. changed: boolean;
  12574. /**
  12575. * Called when a gamepad press event has been triggered
  12576. */
  12577. pressChanged: boolean;
  12578. /**
  12579. * Called when a touch event has been triggered
  12580. */
  12581. touchChanged: boolean;
  12582. /**
  12583. * Called when a value has changed
  12584. */
  12585. valueChanged: boolean;
  12586. }
  12587. /**
  12588. * Represents a gamepad
  12589. */
  12590. class Gamepad {
  12591. /**
  12592. * The id of the gamepad
  12593. */
  12594. id: string;
  12595. /**
  12596. * The index of the gamepad
  12597. */
  12598. index: number;
  12599. /**
  12600. * The browser gamepad
  12601. */
  12602. browserGamepad: any;
  12603. /**
  12604. * Specifies what type of gamepad this represents
  12605. */
  12606. type: number;
  12607. private _leftStick;
  12608. private _rightStick;
  12609. /** @hidden */
  12610. _isConnected: boolean;
  12611. private _leftStickAxisX;
  12612. private _leftStickAxisY;
  12613. private _rightStickAxisX;
  12614. private _rightStickAxisY;
  12615. /**
  12616. * Triggered when the left control stick has been changed
  12617. */
  12618. private _onleftstickchanged;
  12619. /**
  12620. * Triggered when the right control stick has been changed
  12621. */
  12622. private _onrightstickchanged;
  12623. /**
  12624. * Represents a gamepad controller
  12625. */
  12626. static GAMEPAD: number;
  12627. /**
  12628. * Represents a generic controller
  12629. */
  12630. static GENERIC: number;
  12631. /**
  12632. * Represents an XBox controller
  12633. */
  12634. static XBOX: number;
  12635. /**
  12636. * Represents a pose-enabled controller
  12637. */
  12638. static POSE_ENABLED: number;
  12639. /**
  12640. * Specifies whether the left control stick should be Y-inverted
  12641. */
  12642. protected _invertLeftStickY: boolean;
  12643. /**
  12644. * Specifies if the gamepad has been connected
  12645. */
  12646. readonly isConnected: boolean;
  12647. /**
  12648. * Initializes the gamepad
  12649. * @param id The id of the gamepad
  12650. * @param index The index of the gamepad
  12651. * @param browserGamepad The browser gamepad
  12652. * @param leftStickX The x component of the left joystick
  12653. * @param leftStickY The y component of the left joystick
  12654. * @param rightStickX The x component of the right joystick
  12655. * @param rightStickY The y component of the right joystick
  12656. */
  12657. constructor(
  12658. /**
  12659. * The id of the gamepad
  12660. */
  12661. id: string,
  12662. /**
  12663. * The index of the gamepad
  12664. */
  12665. index: number,
  12666. /**
  12667. * The browser gamepad
  12668. */
  12669. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12670. /**
  12671. * Callback triggered when the left joystick has changed
  12672. * @param callback
  12673. */
  12674. onleftstickchanged(callback: (values: StickValues) => void): void;
  12675. /**
  12676. * Callback triggered when the right joystick has changed
  12677. * @param callback
  12678. */
  12679. onrightstickchanged(callback: (values: StickValues) => void): void;
  12680. /**
  12681. * Gets the left joystick
  12682. */
  12683. /**
  12684. * Sets the left joystick values
  12685. */
  12686. leftStick: StickValues;
  12687. /**
  12688. * Gets the right joystick
  12689. */
  12690. /**
  12691. * Sets the right joystick value
  12692. */
  12693. rightStick: StickValues;
  12694. /**
  12695. * Updates the gamepad joystick positions
  12696. */
  12697. update(): void;
  12698. /**
  12699. * Disposes the gamepad
  12700. */
  12701. dispose(): void;
  12702. }
  12703. /**
  12704. * Represents a generic gamepad
  12705. */
  12706. class GenericPad extends Gamepad {
  12707. private _buttons;
  12708. private _onbuttondown;
  12709. private _onbuttonup;
  12710. /**
  12711. * Observable triggered when a button has been pressed
  12712. */
  12713. onButtonDownObservable: Observable<number>;
  12714. /**
  12715. * Observable triggered when a button has been released
  12716. */
  12717. onButtonUpObservable: Observable<number>;
  12718. /**
  12719. * Callback triggered when a button has been pressed
  12720. * @param callback Called when a button has been pressed
  12721. */
  12722. onbuttondown(callback: (buttonPressed: number) => void): void;
  12723. /**
  12724. * Callback triggered when a button has been released
  12725. * @param callback Called when a button has been released
  12726. */
  12727. onbuttonup(callback: (buttonReleased: number) => void): void;
  12728. /**
  12729. * Initializes the generic gamepad
  12730. * @param id The id of the generic gamepad
  12731. * @param index The index of the generic gamepad
  12732. * @param browserGamepad The browser gamepad
  12733. */
  12734. constructor(id: string, index: number, browserGamepad: any);
  12735. private _setButtonValue;
  12736. /**
  12737. * Updates the generic gamepad
  12738. */
  12739. update(): void;
  12740. /**
  12741. * Disposes the generic gamepad
  12742. */
  12743. dispose(): void;
  12744. }
  12745. }
  12746. declare module BABYLON {
  12747. /**
  12748. * Manager for handling gamepads
  12749. */
  12750. class GamepadManager {
  12751. private _scene?;
  12752. private _babylonGamepads;
  12753. private _oneGamepadConnected;
  12754. /** @hidden */
  12755. _isMonitoring: boolean;
  12756. private _gamepadEventSupported;
  12757. private _gamepadSupport;
  12758. /**
  12759. * observable to be triggered when the gamepad controller has been connected
  12760. */
  12761. onGamepadConnectedObservable: Observable<Gamepad>;
  12762. /**
  12763. * observable to be triggered when the gamepad controller has been disconnected
  12764. */
  12765. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12766. private _onGamepadConnectedEvent;
  12767. private _onGamepadDisconnectedEvent;
  12768. /**
  12769. * Initializes the gamepad manager
  12770. * @param _scene BabylonJS scene
  12771. */
  12772. constructor(_scene?: Scene | undefined);
  12773. /**
  12774. * The gamepads in the game pad manager
  12775. */
  12776. readonly gamepads: Gamepad[];
  12777. /**
  12778. * Get the gamepad controllers based on type
  12779. * @param type The type of gamepad controller
  12780. * @returns Nullable gamepad
  12781. */
  12782. getGamepadByType(type?: number): Nullable<Gamepad>;
  12783. /**
  12784. * Disposes the gamepad manager
  12785. */
  12786. dispose(): void;
  12787. private _addNewGamepad;
  12788. private _startMonitoringGamepads;
  12789. private _stopMonitoringGamepads;
  12790. /** @hidden */
  12791. _checkGamepadsStatus(): void;
  12792. private _updateGamepadObjects;
  12793. }
  12794. }
  12795. declare module BABYLON {
  12796. interface Scene {
  12797. /** @hidden */
  12798. _gamepadManager: Nullable<GamepadManager>;
  12799. /**
  12800. * Gets the gamepad manager associated with the scene
  12801. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12802. */
  12803. gamepadManager: GamepadManager;
  12804. }
  12805. /**
  12806. * Interface representing a free camera inputs manager
  12807. */
  12808. interface FreeCameraInputsManager {
  12809. /**
  12810. * Adds gamepad input support to the FreeCameraInputsManager.
  12811. * @returns the FreeCameraInputsManager
  12812. */
  12813. addGamepad(): FreeCameraInputsManager;
  12814. }
  12815. /**
  12816. * Interface representing an arc rotate camera inputs manager
  12817. */
  12818. interface ArcRotateCameraInputsManager {
  12819. /**
  12820. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12821. * @returns the camera inputs manager
  12822. */
  12823. addGamepad(): ArcRotateCameraInputsManager;
  12824. }
  12825. /**
  12826. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12827. */
  12828. class GamepadSystemSceneComponent implements ISceneComponent {
  12829. /**
  12830. * The component name helpfull to identify the component in the list of scene components.
  12831. */
  12832. readonly name: string;
  12833. /**
  12834. * The scene the component belongs to.
  12835. */
  12836. scene: Scene;
  12837. /**
  12838. * Creates a new instance of the component for the given scene
  12839. * @param scene Defines the scene to register the component in
  12840. */
  12841. constructor(scene: Scene);
  12842. /**
  12843. * Registers the component in a given scene
  12844. */
  12845. register(): void;
  12846. /**
  12847. * Rebuilds the elements related to this component in case of
  12848. * context lost for instance.
  12849. */
  12850. rebuild(): void;
  12851. /**
  12852. * Disposes the component and the associated ressources
  12853. */
  12854. dispose(): void;
  12855. private _beforeCameraUpdate;
  12856. }
  12857. }
  12858. declare module BABYLON {
  12859. /**
  12860. * Defines supported buttons for XBox360 compatible gamepads
  12861. */
  12862. enum Xbox360Button {
  12863. /** A */
  12864. A = 0,
  12865. /** B */
  12866. B = 1,
  12867. /** X */
  12868. X = 2,
  12869. /** Y */
  12870. Y = 3,
  12871. /** Start */
  12872. Start = 4,
  12873. /** Back */
  12874. Back = 5,
  12875. /** Left button */
  12876. LB = 6,
  12877. /** Right button */
  12878. RB = 7,
  12879. /** Left stick */
  12880. LeftStick = 8,
  12881. /** Right stick */
  12882. RightStick = 9
  12883. }
  12884. /** Defines values for XBox360 DPad */
  12885. enum Xbox360Dpad {
  12886. /** Up */
  12887. Up = 0,
  12888. /** Down */
  12889. Down = 1,
  12890. /** Left */
  12891. Left = 2,
  12892. /** Right */
  12893. Right = 3
  12894. }
  12895. /**
  12896. * Defines a XBox360 gamepad
  12897. */
  12898. class Xbox360Pad extends Gamepad {
  12899. private _leftTrigger;
  12900. private _rightTrigger;
  12901. private _onlefttriggerchanged;
  12902. private _onrighttriggerchanged;
  12903. private _onbuttondown;
  12904. private _onbuttonup;
  12905. private _ondpaddown;
  12906. private _ondpadup;
  12907. /** Observable raised when a button is pressed */
  12908. onButtonDownObservable: Observable<Xbox360Button>;
  12909. /** Observable raised when a button is released */
  12910. onButtonUpObservable: Observable<Xbox360Button>;
  12911. /** Observable raised when a pad is pressed */
  12912. onPadDownObservable: Observable<Xbox360Dpad>;
  12913. /** Observable raised when a pad is released */
  12914. onPadUpObservable: Observable<Xbox360Dpad>;
  12915. private _buttonA;
  12916. private _buttonB;
  12917. private _buttonX;
  12918. private _buttonY;
  12919. private _buttonBack;
  12920. private _buttonStart;
  12921. private _buttonLB;
  12922. private _buttonRB;
  12923. private _buttonLeftStick;
  12924. private _buttonRightStick;
  12925. private _dPadUp;
  12926. private _dPadDown;
  12927. private _dPadLeft;
  12928. private _dPadRight;
  12929. private _isXboxOnePad;
  12930. /**
  12931. * Creates a new XBox360 gamepad object
  12932. * @param id defines the id of this gamepad
  12933. * @param index defines its index
  12934. * @param gamepad defines the internal HTML gamepad object
  12935. * @param xboxOne defines if it is a XBox One gamepad
  12936. */
  12937. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12938. /**
  12939. * Defines the callback to call when left trigger is pressed
  12940. * @param callback defines the callback to use
  12941. */
  12942. onlefttriggerchanged(callback: (value: number) => void): void;
  12943. /**
  12944. * Defines the callback to call when right trigger is pressed
  12945. * @param callback defines the callback to use
  12946. */
  12947. onrighttriggerchanged(callback: (value: number) => void): void;
  12948. /**
  12949. * Gets the left trigger value
  12950. */
  12951. /**
  12952. * Sets the left trigger value
  12953. */
  12954. leftTrigger: number;
  12955. /**
  12956. * Gets the right trigger value
  12957. */
  12958. /**
  12959. * Sets the right trigger value
  12960. */
  12961. rightTrigger: number;
  12962. /**
  12963. * Defines the callback to call when a button is pressed
  12964. * @param callback defines the callback to use
  12965. */
  12966. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12967. /**
  12968. * Defines the callback to call when a button is released
  12969. * @param callback defines the callback to use
  12970. */
  12971. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  12972. /**
  12973. * Defines the callback to call when a pad is pressed
  12974. * @param callback defines the callback to use
  12975. */
  12976. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  12977. /**
  12978. * Defines the callback to call when a pad is released
  12979. * @param callback defines the callback to use
  12980. */
  12981. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  12982. private _setButtonValue;
  12983. private _setDPadValue;
  12984. /**
  12985. * Gets the value of the `A` button
  12986. */
  12987. /**
  12988. * Sets the value of the `A` button
  12989. */
  12990. buttonA: number;
  12991. /**
  12992. * Gets the value of the `B` button
  12993. */
  12994. /**
  12995. * Sets the value of the `B` button
  12996. */
  12997. buttonB: number;
  12998. /**
  12999. * Gets the value of the `X` button
  13000. */
  13001. /**
  13002. * Sets the value of the `X` button
  13003. */
  13004. buttonX: number;
  13005. /**
  13006. * Gets the value of the `Y` button
  13007. */
  13008. /**
  13009. * Sets the value of the `Y` button
  13010. */
  13011. buttonY: number;
  13012. /**
  13013. * Gets the value of the `Start` button
  13014. */
  13015. /**
  13016. * Sets the value of the `Start` button
  13017. */
  13018. buttonStart: number;
  13019. /**
  13020. * Gets the value of the `Back` button
  13021. */
  13022. /**
  13023. * Sets the value of the `Back` button
  13024. */
  13025. buttonBack: number;
  13026. /**
  13027. * Gets the value of the `Left` button
  13028. */
  13029. /**
  13030. * Sets the value of the `Left` button
  13031. */
  13032. buttonLB: number;
  13033. /**
  13034. * Gets the value of the `Right` button
  13035. */
  13036. /**
  13037. * Sets the value of the `Right` button
  13038. */
  13039. buttonRB: number;
  13040. /**
  13041. * Gets the value of the Left joystick
  13042. */
  13043. /**
  13044. * Sets the value of the Left joystick
  13045. */
  13046. buttonLeftStick: number;
  13047. /**
  13048. * Gets the value of the Right joystick
  13049. */
  13050. /**
  13051. * Sets the value of the Right joystick
  13052. */
  13053. buttonRightStick: number;
  13054. /**
  13055. * Gets the value of D-pad up
  13056. */
  13057. /**
  13058. * Sets the value of D-pad up
  13059. */
  13060. dPadUp: number;
  13061. /**
  13062. * Gets the value of D-pad down
  13063. */
  13064. /**
  13065. * Sets the value of D-pad down
  13066. */
  13067. dPadDown: number;
  13068. /**
  13069. * Gets the value of D-pad left
  13070. */
  13071. /**
  13072. * Sets the value of D-pad left
  13073. */
  13074. dPadLeft: number;
  13075. /**
  13076. * Gets the value of D-pad right
  13077. */
  13078. /**
  13079. * Sets the value of D-pad right
  13080. */
  13081. dPadRight: number;
  13082. /**
  13083. * Force the gamepad to synchronize with device values
  13084. */
  13085. update(): void;
  13086. /**
  13087. * Disposes the gamepad
  13088. */
  13089. dispose(): void;
  13090. }
  13091. }
  13092. declare module BABYLON {
  13093. /**
  13094. * Single axis drag gizmo
  13095. */
  13096. class AxisDragGizmo extends Gizmo {
  13097. /**
  13098. * Drag behavior responsible for the gizmos dragging interactions
  13099. */
  13100. dragBehavior: PointerDragBehavior;
  13101. private _pointerObserver;
  13102. /**
  13103. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13104. */
  13105. snapDistance: number;
  13106. /**
  13107. * Event that fires each time the gizmo snaps to a new location.
  13108. * * snapDistance is the the change in distance
  13109. */
  13110. onSnapObservable: Observable<{
  13111. snapDistance: number;
  13112. }>;
  13113. /** @hidden */
  13114. static _CreateArrow(scene: Scene, material: StandardMaterial): AbstractMesh;
  13115. /**
  13116. * Creates an AxisDragGizmo
  13117. * @param gizmoLayer The utility layer the gizmo will be added to
  13118. * @param dragAxis The axis which the gizmo will be able to drag on
  13119. * @param color The color of the gizmo
  13120. */
  13121. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13122. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13123. /**
  13124. * Disposes of the gizmo
  13125. */
  13126. dispose(): void;
  13127. }
  13128. }
  13129. declare module BABYLON {
  13130. /**
  13131. * Single axis scale gizmo
  13132. */
  13133. class AxisScaleGizmo extends Gizmo {
  13134. private _coloredMaterial;
  13135. /**
  13136. * Drag behavior responsible for the gizmos dragging interactions
  13137. */
  13138. dragBehavior: PointerDragBehavior;
  13139. private _pointerObserver;
  13140. /**
  13141. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13142. */
  13143. snapDistance: number;
  13144. /**
  13145. * Event that fires each time the gizmo snaps to a new location.
  13146. * * snapDistance is the the change in distance
  13147. */
  13148. onSnapObservable: Observable<{
  13149. snapDistance: number;
  13150. }>;
  13151. /**
  13152. * If the scaling operation should be done on all axis (default: false)
  13153. */
  13154. uniformScaling: boolean;
  13155. /**
  13156. * Creates an AxisScaleGizmo
  13157. * @param gizmoLayer The utility layer the gizmo will be added to
  13158. * @param dragAxis The axis which the gizmo will be able to scale on
  13159. * @param color The color of the gizmo
  13160. */
  13161. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13162. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13163. /**
  13164. * Disposes of the gizmo
  13165. */
  13166. dispose(): void;
  13167. /**
  13168. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13169. * @param mesh The mesh to replace the default mesh of the gizmo
  13170. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  13171. */
  13172. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  13173. }
  13174. }
  13175. declare module BABYLON {
  13176. /**
  13177. * Bounding box gizmo
  13178. */
  13179. class BoundingBoxGizmo extends Gizmo {
  13180. private _lineBoundingBox;
  13181. private _rotateSpheresParent;
  13182. private _scaleBoxesParent;
  13183. private _boundingDimensions;
  13184. private _renderObserver;
  13185. private _pointerObserver;
  13186. private _scaleDragSpeed;
  13187. private _tmpQuaternion;
  13188. private _tmpVector;
  13189. private _tmpRotationMatrix;
  13190. /**
  13191. * 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)
  13192. */
  13193. ignoreChildren: boolean;
  13194. /**
  13195. * 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)
  13196. */
  13197. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  13198. /**
  13199. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  13200. */
  13201. rotationSphereSize: number;
  13202. /**
  13203. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  13204. */
  13205. scaleBoxSize: number;
  13206. /**
  13207. * 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)
  13208. */
  13209. fixedDragMeshScreenSize: boolean;
  13210. /**
  13211. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  13212. */
  13213. fixedDragMeshScreenSizeDistanceFactor: number;
  13214. /**
  13215. * Fired when a rotation sphere or scale box is dragged
  13216. */
  13217. onDragStartObservable: Observable<{}>;
  13218. /**
  13219. * Fired when a scale box is dragged
  13220. */
  13221. onScaleBoxDragObservable: Observable<{}>;
  13222. /**
  13223. * Fired when a scale box drag is ended
  13224. */
  13225. onScaleBoxDragEndObservable: Observable<{}>;
  13226. /**
  13227. * Fired when a rotation sphere is dragged
  13228. */
  13229. onRotationSphereDragObservable: Observable<{}>;
  13230. /**
  13231. * Fired when a rotation sphere drag is ended
  13232. */
  13233. onRotationSphereDragEndObservable: Observable<{}>;
  13234. /**
  13235. * 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)
  13236. */
  13237. scalePivot: Nullable<Vector3>;
  13238. private _anchorMesh;
  13239. private _existingMeshScale;
  13240. private static _PivotCached;
  13241. private static _OldPivotPoint;
  13242. private static _PivotTranslation;
  13243. private static _PivotTmpVector;
  13244. /** @hidden */
  13245. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  13246. /** @hidden */
  13247. static _RestorePivotPoint(mesh: AbstractMesh): void;
  13248. /**
  13249. * Creates an BoundingBoxGizmo
  13250. * @param gizmoLayer The utility layer the gizmo will be added to
  13251. * @param color The color of the gizmo
  13252. */
  13253. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13254. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13255. private _selectNode;
  13256. /**
  13257. * Updates the bounding box information for the Gizmo
  13258. */
  13259. updateBoundingBox(): void;
  13260. private _updateRotationSpheres;
  13261. private _updateScaleBoxes;
  13262. /**
  13263. * Enables rotation on the specified axis and disables rotation on the others
  13264. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  13265. */
  13266. setEnabledRotationAxis(axis: string): void;
  13267. /**
  13268. * Disposes of the gizmo
  13269. */
  13270. dispose(): void;
  13271. /**
  13272. * 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)
  13273. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  13274. * @returns the bounding box mesh with the passed in mesh as a child
  13275. */
  13276. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  13277. /**
  13278. * CustomMeshes are not supported by this gizmo
  13279. * @param mesh The mesh to replace the default mesh of the gizmo
  13280. */
  13281. setCustomMesh(mesh: Mesh): void;
  13282. }
  13283. }
  13284. declare module BABYLON {
  13285. /**
  13286. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  13287. */
  13288. class Gizmo implements IDisposable {
  13289. /** The utility layer the gizmo will be added to */
  13290. gizmoLayer: UtilityLayerRenderer;
  13291. /**
  13292. * The root mesh of the gizmo
  13293. */
  13294. protected _rootMesh: Mesh;
  13295. private _attachedMesh;
  13296. /**
  13297. * Ratio for the scale of the gizmo (Default: 1)
  13298. */
  13299. scaleRatio: number;
  13300. private _tmpMatrix;
  13301. /**
  13302. * If a custom mesh has been set (Default: false)
  13303. */
  13304. protected _customMeshSet: boolean;
  13305. /**
  13306. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  13307. * * When set, interactions will be enabled
  13308. */
  13309. attachedMesh: Nullable<AbstractMesh>;
  13310. /**
  13311. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13312. * @param mesh The mesh to replace the default mesh of the gizmo
  13313. */
  13314. setCustomMesh(mesh: Mesh): void;
  13315. /**
  13316. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  13317. */
  13318. updateGizmoRotationToMatchAttachedMesh: boolean;
  13319. /**
  13320. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  13321. */
  13322. updateGizmoPositionToMatchAttachedMesh: boolean;
  13323. /**
  13324. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  13325. */
  13326. protected _updateScale: boolean;
  13327. protected _interactionsEnabled: boolean;
  13328. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13329. private _beforeRenderObserver;
  13330. /**
  13331. * Creates a gizmo
  13332. * @param gizmoLayer The utility layer the gizmo will be added to
  13333. */
  13334. constructor(
  13335. /** The utility layer the gizmo will be added to */
  13336. gizmoLayer?: UtilityLayerRenderer);
  13337. private _tempVector;
  13338. /**
  13339. * @hidden
  13340. * Updates the gizmo to match the attached mesh's position/rotation
  13341. */
  13342. protected _update(): void;
  13343. /**
  13344. * Disposes of the gizmo
  13345. */
  13346. dispose(): void;
  13347. }
  13348. }
  13349. declare module BABYLON {
  13350. /**
  13351. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  13352. */
  13353. class GizmoManager implements IDisposable {
  13354. private scene;
  13355. /**
  13356. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  13357. */
  13358. gizmos: {
  13359. positionGizmo: Nullable<PositionGizmo>;
  13360. rotationGizmo: Nullable<RotationGizmo>;
  13361. scaleGizmo: Nullable<ScaleGizmo>;
  13362. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  13363. };
  13364. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  13365. clearGizmoOnEmptyPointerEvent: boolean;
  13366. /** Fires an event when the manager is attached to a mesh */
  13367. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  13368. private _gizmosEnabled;
  13369. private _pointerObserver;
  13370. private _attachedMesh;
  13371. private _boundingBoxColor;
  13372. private _defaultUtilityLayer;
  13373. private _defaultKeepDepthUtilityLayer;
  13374. /**
  13375. * When bounding box gizmo is enabled, this can be used to track drag/end events
  13376. */
  13377. boundingBoxDragBehavior: SixDofDragBehavior;
  13378. /**
  13379. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  13380. */
  13381. attachableMeshes: Nullable<Array<AbstractMesh>>;
  13382. /**
  13383. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  13384. */
  13385. usePointerToAttachGizmos: boolean;
  13386. /**
  13387. * Instatiates a gizmo manager
  13388. * @param scene the scene to overlay the gizmos on top of
  13389. */
  13390. constructor(scene: Scene);
  13391. /**
  13392. * Attaches a set of gizmos to the specified mesh
  13393. * @param mesh The mesh the gizmo's should be attached to
  13394. */
  13395. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  13396. /**
  13397. * If the position gizmo is enabled
  13398. */
  13399. positionGizmoEnabled: boolean;
  13400. /**
  13401. * If the rotation gizmo is enabled
  13402. */
  13403. rotationGizmoEnabled: boolean;
  13404. /**
  13405. * If the scale gizmo is enabled
  13406. */
  13407. scaleGizmoEnabled: boolean;
  13408. /**
  13409. * If the boundingBox gizmo is enabled
  13410. */
  13411. boundingBoxGizmoEnabled: boolean;
  13412. /**
  13413. * Disposes of the gizmo manager
  13414. */
  13415. dispose(): void;
  13416. }
  13417. }
  13418. declare module BABYLON {
  13419. /**
  13420. * Single plane rotation gizmo
  13421. */
  13422. class PlaneRotationGizmo extends Gizmo {
  13423. /**
  13424. * Drag behavior responsible for the gizmos dragging interactions
  13425. */
  13426. dragBehavior: PointerDragBehavior;
  13427. private _pointerObserver;
  13428. /**
  13429. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  13430. */
  13431. snapDistance: number;
  13432. /**
  13433. * Event that fires each time the gizmo snaps to a new location.
  13434. * * snapDistance is the the change in distance
  13435. */
  13436. onSnapObservable: Observable<{
  13437. snapDistance: number;
  13438. }>;
  13439. /**
  13440. * Creates a PlaneRotationGizmo
  13441. * @param gizmoLayer The utility layer the gizmo will be added to
  13442. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  13443. * @param color The color of the gizmo
  13444. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13445. */
  13446. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13447. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13448. /**
  13449. * Disposes of the gizmo
  13450. */
  13451. dispose(): void;
  13452. }
  13453. }
  13454. declare module BABYLON {
  13455. /**
  13456. * Gizmo that enables dragging a mesh along 3 axis
  13457. */
  13458. class PositionGizmo extends Gizmo {
  13459. /**
  13460. * Internal gizmo used for interactions on the x axis
  13461. */
  13462. xGizmo: AxisDragGizmo;
  13463. /**
  13464. * Internal gizmo used for interactions on the y axis
  13465. */
  13466. yGizmo: AxisDragGizmo;
  13467. /**
  13468. * Internal gizmo used for interactions on the z axis
  13469. */
  13470. zGizmo: AxisDragGizmo;
  13471. /** Fires an event when any of it's sub gizmos are dragged */
  13472. onDragStartObservable: Observable<{}>;
  13473. /** Fires an event when any of it's sub gizmos are released from dragging */
  13474. onDragEndObservable: Observable<{}>;
  13475. attachedMesh: Nullable<AbstractMesh>;
  13476. /**
  13477. * Creates a PositionGizmo
  13478. * @param gizmoLayer The utility layer the gizmo will be added to
  13479. */
  13480. constructor(gizmoLayer?: UtilityLayerRenderer);
  13481. updateGizmoRotationToMatchAttachedMesh: boolean;
  13482. /**
  13483. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13484. */
  13485. snapDistance: number;
  13486. /**
  13487. * Ratio for the scale of the gizmo (Default: 1)
  13488. */
  13489. scaleRatio: number;
  13490. /**
  13491. * Disposes of the gizmo
  13492. */
  13493. dispose(): void;
  13494. /**
  13495. * CustomMeshes are not supported by this gizmo
  13496. * @param mesh The mesh to replace the default mesh of the gizmo
  13497. */
  13498. setCustomMesh(mesh: Mesh): void;
  13499. }
  13500. }
  13501. declare module BABYLON {
  13502. /**
  13503. * Gizmo that enables rotating a mesh along 3 axis
  13504. */
  13505. class RotationGizmo extends Gizmo {
  13506. /**
  13507. * Internal gizmo used for interactions on the x axis
  13508. */
  13509. xGizmo: PlaneRotationGizmo;
  13510. /**
  13511. * Internal gizmo used for interactions on the y axis
  13512. */
  13513. yGizmo: PlaneRotationGizmo;
  13514. /**
  13515. * Internal gizmo used for interactions on the z axis
  13516. */
  13517. zGizmo: PlaneRotationGizmo;
  13518. /** Fires an event when any of it's sub gizmos are dragged */
  13519. onDragStartObservable: Observable<{}>;
  13520. /** Fires an event when any of it's sub gizmos are released from dragging */
  13521. onDragEndObservable: Observable<{}>;
  13522. attachedMesh: Nullable<AbstractMesh>;
  13523. /**
  13524. * Creates a RotationGizmo
  13525. * @param gizmoLayer The utility layer the gizmo will be added to
  13526. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13527. */
  13528. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13529. updateGizmoRotationToMatchAttachedMesh: boolean;
  13530. /**
  13531. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13532. */
  13533. snapDistance: number;
  13534. /**
  13535. * Ratio for the scale of the gizmo (Default: 1)
  13536. */
  13537. scaleRatio: number;
  13538. /**
  13539. * Disposes of the gizmo
  13540. */
  13541. dispose(): void;
  13542. /**
  13543. * CustomMeshes are not supported by this gizmo
  13544. * @param mesh The mesh to replace the default mesh of the gizmo
  13545. */
  13546. setCustomMesh(mesh: Mesh): void;
  13547. }
  13548. }
  13549. declare module BABYLON {
  13550. /**
  13551. * Gizmo that enables scaling a mesh along 3 axis
  13552. */
  13553. class ScaleGizmo extends Gizmo {
  13554. /**
  13555. * Internal gizmo used for interactions on the x axis
  13556. */
  13557. xGizmo: AxisScaleGizmo;
  13558. /**
  13559. * Internal gizmo used for interactions on the y axis
  13560. */
  13561. yGizmo: AxisScaleGizmo;
  13562. /**
  13563. * Internal gizmo used for interactions on the z axis
  13564. */
  13565. zGizmo: AxisScaleGizmo;
  13566. /**
  13567. * Internal gizmo used to scale all axis equally
  13568. */
  13569. uniformScaleGizmo: AxisScaleGizmo;
  13570. /** Fires an event when any of it's sub gizmos are dragged */
  13571. onDragStartObservable: Observable<{}>;
  13572. /** Fires an event when any of it's sub gizmos are released from dragging */
  13573. onDragEndObservable: Observable<{}>;
  13574. attachedMesh: Nullable<AbstractMesh>;
  13575. /**
  13576. * Creates a ScaleGizmo
  13577. * @param gizmoLayer The utility layer the gizmo will be added to
  13578. */
  13579. constructor(gizmoLayer?: UtilityLayerRenderer);
  13580. updateGizmoRotationToMatchAttachedMesh: boolean;
  13581. /**
  13582. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13583. */
  13584. snapDistance: number;
  13585. /**
  13586. * Ratio for the scale of the gizmo (Default: 1)
  13587. */
  13588. scaleRatio: number;
  13589. /**
  13590. * Disposes of the gizmo
  13591. */
  13592. dispose(): void;
  13593. }
  13594. }
  13595. declare module BABYLON {
  13596. /**
  13597. * Represents the different options available during the creation of
  13598. * a Environment helper.
  13599. *
  13600. * This can control the default ground, skybox and image processing setup of your scene.
  13601. */
  13602. interface IEnvironmentHelperOptions {
  13603. /**
  13604. * Specifies wether or not to create a ground.
  13605. * True by default.
  13606. */
  13607. createGround: boolean;
  13608. /**
  13609. * Specifies the ground size.
  13610. * 15 by default.
  13611. */
  13612. groundSize: number;
  13613. /**
  13614. * The texture used on the ground for the main color.
  13615. * Comes from the BabylonJS CDN by default.
  13616. *
  13617. * Remarks: Can be either a texture or a url.
  13618. */
  13619. groundTexture: string | BaseTexture;
  13620. /**
  13621. * The color mixed in the ground texture by default.
  13622. * BabylonJS clearColor by default.
  13623. */
  13624. groundColor: Color3;
  13625. /**
  13626. * Specifies the ground opacity.
  13627. * 1 by default.
  13628. */
  13629. groundOpacity: number;
  13630. /**
  13631. * Enables the ground to receive shadows.
  13632. * True by default.
  13633. */
  13634. enableGroundShadow: boolean;
  13635. /**
  13636. * Helps preventing the shadow to be fully black on the ground.
  13637. * 0.5 by default.
  13638. */
  13639. groundShadowLevel: number;
  13640. /**
  13641. * Creates a mirror texture attach to the ground.
  13642. * false by default.
  13643. */
  13644. enableGroundMirror: boolean;
  13645. /**
  13646. * Specifies the ground mirror size ratio.
  13647. * 0.3 by default as the default kernel is 64.
  13648. */
  13649. groundMirrorSizeRatio: number;
  13650. /**
  13651. * Specifies the ground mirror blur kernel size.
  13652. * 64 by default.
  13653. */
  13654. groundMirrorBlurKernel: number;
  13655. /**
  13656. * Specifies the ground mirror visibility amount.
  13657. * 1 by default
  13658. */
  13659. groundMirrorAmount: number;
  13660. /**
  13661. * Specifies the ground mirror reflectance weight.
  13662. * This uses the standard weight of the background material to setup the fresnel effect
  13663. * of the mirror.
  13664. * 1 by default.
  13665. */
  13666. groundMirrorFresnelWeight: number;
  13667. /**
  13668. * Specifies the ground mirror Falloff distance.
  13669. * This can helps reducing the size of the reflection.
  13670. * 0 by Default.
  13671. */
  13672. groundMirrorFallOffDistance: number;
  13673. /**
  13674. * Specifies the ground mirror texture type.
  13675. * Unsigned Int by Default.
  13676. */
  13677. groundMirrorTextureType: number;
  13678. /**
  13679. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13680. * the shown objects.
  13681. */
  13682. groundYBias: number;
  13683. /**
  13684. * Specifies wether or not to create a skybox.
  13685. * True by default.
  13686. */
  13687. createSkybox: boolean;
  13688. /**
  13689. * Specifies the skybox size.
  13690. * 20 by default.
  13691. */
  13692. skyboxSize: number;
  13693. /**
  13694. * The texture used on the skybox for the main color.
  13695. * Comes from the BabylonJS CDN by default.
  13696. *
  13697. * Remarks: Can be either a texture or a url.
  13698. */
  13699. skyboxTexture: string | BaseTexture;
  13700. /**
  13701. * The color mixed in the skybox texture by default.
  13702. * BabylonJS clearColor by default.
  13703. */
  13704. skyboxColor: Color3;
  13705. /**
  13706. * The background rotation around the Y axis of the scene.
  13707. * This helps aligning the key lights of your scene with the background.
  13708. * 0 by default.
  13709. */
  13710. backgroundYRotation: number;
  13711. /**
  13712. * Compute automatically the size of the elements to best fit with the scene.
  13713. */
  13714. sizeAuto: boolean;
  13715. /**
  13716. * Default position of the rootMesh if autoSize is not true.
  13717. */
  13718. rootPosition: Vector3;
  13719. /**
  13720. * Sets up the image processing in the scene.
  13721. * true by default.
  13722. */
  13723. setupImageProcessing: boolean;
  13724. /**
  13725. * The texture used as your environment texture in the scene.
  13726. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13727. *
  13728. * Remarks: Can be either a texture or a url.
  13729. */
  13730. environmentTexture: string | BaseTexture;
  13731. /**
  13732. * The value of the exposure to apply to the scene.
  13733. * 0.6 by default if setupImageProcessing is true.
  13734. */
  13735. cameraExposure: number;
  13736. /**
  13737. * The value of the contrast to apply to the scene.
  13738. * 1.6 by default if setupImageProcessing is true.
  13739. */
  13740. cameraContrast: number;
  13741. /**
  13742. * Specifies wether or not tonemapping should be enabled in the scene.
  13743. * true by default if setupImageProcessing is true.
  13744. */
  13745. toneMappingEnabled: boolean;
  13746. }
  13747. /**
  13748. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13749. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13750. * It also helps with the default setup of your imageProcessing configuration.
  13751. */
  13752. class EnvironmentHelper {
  13753. /**
  13754. * Default ground texture URL.
  13755. */
  13756. private static _groundTextureCDNUrl;
  13757. /**
  13758. * Default skybox texture URL.
  13759. */
  13760. private static _skyboxTextureCDNUrl;
  13761. /**
  13762. * Default environment texture URL.
  13763. */
  13764. private static _environmentTextureCDNUrl;
  13765. /**
  13766. * Creates the default options for the helper.
  13767. */
  13768. private static _getDefaultOptions;
  13769. private _rootMesh;
  13770. /**
  13771. * Gets the root mesh created by the helper.
  13772. */
  13773. readonly rootMesh: Mesh;
  13774. private _skybox;
  13775. /**
  13776. * Gets the skybox created by the helper.
  13777. */
  13778. readonly skybox: Nullable<Mesh>;
  13779. private _skyboxTexture;
  13780. /**
  13781. * Gets the skybox texture created by the helper.
  13782. */
  13783. readonly skyboxTexture: Nullable<BaseTexture>;
  13784. private _skyboxMaterial;
  13785. /**
  13786. * Gets the skybox material created by the helper.
  13787. */
  13788. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13789. private _ground;
  13790. /**
  13791. * Gets the ground mesh created by the helper.
  13792. */
  13793. readonly ground: Nullable<Mesh>;
  13794. private _groundTexture;
  13795. /**
  13796. * Gets the ground texture created by the helper.
  13797. */
  13798. readonly groundTexture: Nullable<BaseTexture>;
  13799. private _groundMirror;
  13800. /**
  13801. * Gets the ground mirror created by the helper.
  13802. */
  13803. readonly groundMirror: Nullable<MirrorTexture>;
  13804. /**
  13805. * Gets the ground mirror render list to helps pushing the meshes
  13806. * you wish in the ground reflection.
  13807. */
  13808. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13809. private _groundMaterial;
  13810. /**
  13811. * Gets the ground material created by the helper.
  13812. */
  13813. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13814. /**
  13815. * Stores the creation options.
  13816. */
  13817. private readonly _scene;
  13818. private _options;
  13819. /**
  13820. * This observable will be notified with any error during the creation of the environment,
  13821. * mainly texture creation errors.
  13822. */
  13823. onErrorObservable: Observable<{
  13824. message?: string;
  13825. exception?: any;
  13826. }>;
  13827. /**
  13828. * constructor
  13829. * @param options
  13830. * @param scene The scene to add the material to
  13831. */
  13832. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13833. /**
  13834. * Updates the background according to the new options
  13835. * @param options
  13836. */
  13837. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13838. /**
  13839. * Sets the primary color of all the available elements.
  13840. * @param color the main color to affect to the ground and the background
  13841. */
  13842. setMainColor(color: Color3): void;
  13843. /**
  13844. * Setup the image processing according to the specified options.
  13845. */
  13846. private _setupImageProcessing;
  13847. /**
  13848. * Setup the environment texture according to the specified options.
  13849. */
  13850. private _setupEnvironmentTexture;
  13851. /**
  13852. * Setup the background according to the specified options.
  13853. */
  13854. private _setupBackground;
  13855. /**
  13856. * Get the scene sizes according to the setup.
  13857. */
  13858. private _getSceneSize;
  13859. /**
  13860. * Setup the ground according to the specified options.
  13861. */
  13862. private _setupGround;
  13863. /**
  13864. * Setup the ground material according to the specified options.
  13865. */
  13866. private _setupGroundMaterial;
  13867. /**
  13868. * Setup the ground diffuse texture according to the specified options.
  13869. */
  13870. private _setupGroundDiffuseTexture;
  13871. /**
  13872. * Setup the ground mirror texture according to the specified options.
  13873. */
  13874. private _setupGroundMirrorTexture;
  13875. /**
  13876. * Setup the ground to receive the mirror texture.
  13877. */
  13878. private _setupMirrorInGroundMaterial;
  13879. /**
  13880. * Setup the skybox according to the specified options.
  13881. */
  13882. private _setupSkybox;
  13883. /**
  13884. * Setup the skybox material according to the specified options.
  13885. */
  13886. private _setupSkyboxMaterial;
  13887. /**
  13888. * Setup the skybox reflection texture according to the specified options.
  13889. */
  13890. private _setupSkyboxReflectionTexture;
  13891. private _errorHandler;
  13892. /**
  13893. * Dispose all the elements created by the Helper.
  13894. */
  13895. dispose(): void;
  13896. }
  13897. }
  13898. declare module BABYLON {
  13899. /**
  13900. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13901. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13902. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13903. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13904. */
  13905. class PhotoDome extends TransformNode {
  13906. private _useDirectMapping;
  13907. /**
  13908. * The texture being displayed on the sphere
  13909. */
  13910. protected _photoTexture: Texture;
  13911. /**
  13912. * Gets or sets the texture being displayed on the sphere
  13913. */
  13914. photoTexture: Texture;
  13915. /**
  13916. * Observable raised when an error occured while loading the 360 image
  13917. */
  13918. onLoadErrorObservable: Observable<string>;
  13919. /**
  13920. * The skybox material
  13921. */
  13922. protected _material: BackgroundMaterial;
  13923. /**
  13924. * The surface used for the skybox
  13925. */
  13926. protected _mesh: Mesh;
  13927. /**
  13928. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13929. * Also see the options.resolution property.
  13930. */
  13931. fovMultiplier: number;
  13932. /**
  13933. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13934. * @param name Element's name, child elements will append suffixes for their own names.
  13935. * @param urlsOfPhoto defines the url of the photo to display
  13936. * @param options defines an object containing optional or exposed sub element properties
  13937. * @param onError defines a callback called when an error occured while loading the texture
  13938. */
  13939. constructor(name: string, urlOfPhoto: string, options: {
  13940. resolution?: number;
  13941. size?: number;
  13942. useDirectMapping?: boolean;
  13943. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13944. /**
  13945. * Releases resources associated with this node.
  13946. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13947. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13948. */
  13949. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13950. }
  13951. }
  13952. declare module BABYLON {
  13953. interface Scene {
  13954. /**
  13955. * Creates a default light for the scene.
  13956. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13957. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13958. */
  13959. createDefaultLight(replace?: boolean): void;
  13960. /**
  13961. * Creates a default camera for the scene.
  13962. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13963. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13964. * @param replace has default false, when true replaces the active camera in the scene
  13965. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13966. */
  13967. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13968. /**
  13969. * Creates a default camera and a default light.
  13970. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  13971. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13972. * @param replace has the default false, when true replaces the active camera/light in the scene
  13973. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  13974. */
  13975. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13976. /**
  13977. * Creates a new sky box
  13978. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  13979. * @param environmentTexture defines the texture to use as environment texture
  13980. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  13981. * @param scale defines the overall scale of the skybox
  13982. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  13983. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  13984. * @returns a new mesh holding the sky box
  13985. */
  13986. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  13987. /**
  13988. * Creates a new environment
  13989. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  13990. * @param options defines the options you can use to configure the environment
  13991. * @returns the new EnvironmentHelper
  13992. */
  13993. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  13994. /**
  13995. * Creates a new VREXperienceHelper
  13996. * @see http://doc.babylonjs.com/how_to/webvr_helper
  13997. * @param webVROptions defines the options used to create the new VREXperienceHelper
  13998. * @returns a new VREXperienceHelper
  13999. */
  14000. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  14001. /**
  14002. * Creates a new XREXperienceHelper
  14003. * @see http://doc.babylonjs.com/how_to/webxr
  14004. * @returns a promise for a new XREXperienceHelper
  14005. */
  14006. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  14007. }
  14008. }
  14009. declare module BABYLON {
  14010. /**
  14011. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  14012. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  14013. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  14014. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  14015. */
  14016. class VideoDome extends TransformNode {
  14017. private _useDirectMapping;
  14018. /**
  14019. * The video texture being displayed on the sphere
  14020. */
  14021. protected _videoTexture: VideoTexture;
  14022. /**
  14023. * Gets the video texture being displayed on the sphere
  14024. */
  14025. readonly videoTexture: VideoTexture;
  14026. /**
  14027. * The skybox material
  14028. */
  14029. protected _material: BackgroundMaterial;
  14030. /**
  14031. * The surface used for the skybox
  14032. */
  14033. protected _mesh: Mesh;
  14034. /**
  14035. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  14036. * Also see the options.resolution property.
  14037. */
  14038. fovMultiplier: number;
  14039. /**
  14040. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  14041. * @param name Element's name, child elements will append suffixes for their own names.
  14042. * @param urlsOrVideo defines the url(s) or the video element to use
  14043. * @param options An object containing optional or exposed sub element properties
  14044. */
  14045. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  14046. resolution?: number;
  14047. clickToPlay?: boolean;
  14048. autoPlay?: boolean;
  14049. loop?: boolean;
  14050. size?: number;
  14051. poster?: string;
  14052. useDirectMapping?: boolean;
  14053. }, scene: Scene);
  14054. /**
  14055. * Releases resources associated with this node.
  14056. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14057. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14058. */
  14059. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14060. }
  14061. }
  14062. declare module BABYLON {
  14063. /**
  14064. * This class can be used to get instrumentation data from a Babylon engine
  14065. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14066. */
  14067. class EngineInstrumentation implements IDisposable {
  14068. /**
  14069. * Define the instrumented engine.
  14070. */
  14071. engine: Engine;
  14072. private _captureGPUFrameTime;
  14073. private _gpuFrameTimeToken;
  14074. private _gpuFrameTime;
  14075. private _captureShaderCompilationTime;
  14076. private _shaderCompilationTime;
  14077. private _onBeginFrameObserver;
  14078. private _onEndFrameObserver;
  14079. private _onBeforeShaderCompilationObserver;
  14080. private _onAfterShaderCompilationObserver;
  14081. /**
  14082. * Gets the perf counter used for GPU frame time
  14083. */
  14084. readonly gpuFrameTimeCounter: PerfCounter;
  14085. /**
  14086. * Gets the GPU frame time capture status
  14087. */
  14088. /**
  14089. * Enable or disable the GPU frame time capture
  14090. */
  14091. captureGPUFrameTime: boolean;
  14092. /**
  14093. * Gets the perf counter used for shader compilation time
  14094. */
  14095. readonly shaderCompilationTimeCounter: PerfCounter;
  14096. /**
  14097. * Gets the shader compilation time capture status
  14098. */
  14099. /**
  14100. * Enable or disable the shader compilation time capture
  14101. */
  14102. captureShaderCompilationTime: boolean;
  14103. /**
  14104. * Instantiates a new engine instrumentation.
  14105. * This class can be used to get instrumentation data from a Babylon engine
  14106. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14107. * @param engine Defines the engine to instrument
  14108. */
  14109. constructor(
  14110. /**
  14111. * Define the instrumented engine.
  14112. */
  14113. engine: Engine);
  14114. /**
  14115. * Dispose and release associated resources.
  14116. */
  14117. dispose(): void;
  14118. }
  14119. }
  14120. declare module BABYLON {
  14121. /**
  14122. * This class can be used to get instrumentation data from a Babylon engine
  14123. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14124. */
  14125. class SceneInstrumentation implements IDisposable {
  14126. /**
  14127. * Defines the scene to instrument
  14128. */
  14129. scene: Scene;
  14130. private _captureActiveMeshesEvaluationTime;
  14131. private _activeMeshesEvaluationTime;
  14132. private _captureRenderTargetsRenderTime;
  14133. private _renderTargetsRenderTime;
  14134. private _captureFrameTime;
  14135. private _frameTime;
  14136. private _captureRenderTime;
  14137. private _renderTime;
  14138. private _captureInterFrameTime;
  14139. private _interFrameTime;
  14140. private _captureParticlesRenderTime;
  14141. private _particlesRenderTime;
  14142. private _captureSpritesRenderTime;
  14143. private _spritesRenderTime;
  14144. private _capturePhysicsTime;
  14145. private _physicsTime;
  14146. private _captureAnimationsTime;
  14147. private _animationsTime;
  14148. private _captureCameraRenderTime;
  14149. private _cameraRenderTime;
  14150. private _onBeforeActiveMeshesEvaluationObserver;
  14151. private _onAfterActiveMeshesEvaluationObserver;
  14152. private _onBeforeRenderTargetsRenderObserver;
  14153. private _onAfterRenderTargetsRenderObserver;
  14154. private _onAfterRenderObserver;
  14155. private _onBeforeDrawPhaseObserver;
  14156. private _onAfterDrawPhaseObserver;
  14157. private _onBeforeAnimationsObserver;
  14158. private _onBeforeParticlesRenderingObserver;
  14159. private _onAfterParticlesRenderingObserver;
  14160. private _onBeforeSpritesRenderingObserver;
  14161. private _onAfterSpritesRenderingObserver;
  14162. private _onBeforePhysicsObserver;
  14163. private _onAfterPhysicsObserver;
  14164. private _onAfterAnimationsObserver;
  14165. private _onBeforeCameraRenderObserver;
  14166. private _onAfterCameraRenderObserver;
  14167. /**
  14168. * Gets the perf counter used for active meshes evaluation time
  14169. */
  14170. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  14171. /**
  14172. * Gets the active meshes evaluation time capture status
  14173. */
  14174. /**
  14175. * Enable or disable the active meshes evaluation time capture
  14176. */
  14177. captureActiveMeshesEvaluationTime: boolean;
  14178. /**
  14179. * Gets the perf counter used for render targets render time
  14180. */
  14181. readonly renderTargetsRenderTimeCounter: PerfCounter;
  14182. /**
  14183. * Gets the render targets render time capture status
  14184. */
  14185. /**
  14186. * Enable or disable the render targets render time capture
  14187. */
  14188. captureRenderTargetsRenderTime: boolean;
  14189. /**
  14190. * Gets the perf counter used for particles render time
  14191. */
  14192. readonly particlesRenderTimeCounter: PerfCounter;
  14193. /**
  14194. * Gets the particles render time capture status
  14195. */
  14196. /**
  14197. * Enable or disable the particles render time capture
  14198. */
  14199. captureParticlesRenderTime: boolean;
  14200. /**
  14201. * Gets the perf counter used for sprites render time
  14202. */
  14203. readonly spritesRenderTimeCounter: PerfCounter;
  14204. /**
  14205. * Gets the sprites render time capture status
  14206. */
  14207. /**
  14208. * Enable or disable the sprites render time capture
  14209. */
  14210. captureSpritesRenderTime: boolean;
  14211. /**
  14212. * Gets the perf counter used for physics time
  14213. */
  14214. readonly physicsTimeCounter: PerfCounter;
  14215. /**
  14216. * Gets the physics time capture status
  14217. */
  14218. /**
  14219. * Enable or disable the physics time capture
  14220. */
  14221. capturePhysicsTime: boolean;
  14222. /**
  14223. * Gets the perf counter used for animations time
  14224. */
  14225. readonly animationsTimeCounter: PerfCounter;
  14226. /**
  14227. * Gets the animations time capture status
  14228. */
  14229. /**
  14230. * Enable or disable the animations time capture
  14231. */
  14232. captureAnimationsTime: boolean;
  14233. /**
  14234. * Gets the perf counter used for frame time capture
  14235. */
  14236. readonly frameTimeCounter: PerfCounter;
  14237. /**
  14238. * Gets the frame time capture status
  14239. */
  14240. /**
  14241. * Enable or disable the frame time capture
  14242. */
  14243. captureFrameTime: boolean;
  14244. /**
  14245. * Gets the perf counter used for inter-frames time capture
  14246. */
  14247. readonly interFrameTimeCounter: PerfCounter;
  14248. /**
  14249. * Gets the inter-frames time capture status
  14250. */
  14251. /**
  14252. * Enable or disable the inter-frames time capture
  14253. */
  14254. captureInterFrameTime: boolean;
  14255. /**
  14256. * Gets the perf counter used for render time capture
  14257. */
  14258. readonly renderTimeCounter: PerfCounter;
  14259. /**
  14260. * Gets the render time capture status
  14261. */
  14262. /**
  14263. * Enable or disable the render time capture
  14264. */
  14265. captureRenderTime: boolean;
  14266. /**
  14267. * Gets the perf counter used for camera render time capture
  14268. */
  14269. readonly cameraRenderTimeCounter: PerfCounter;
  14270. /**
  14271. * Gets the camera render time capture status
  14272. */
  14273. /**
  14274. * Enable or disable the camera render time capture
  14275. */
  14276. captureCameraRenderTime: boolean;
  14277. /**
  14278. * Gets the perf counter used for draw calls
  14279. */
  14280. readonly drawCallsCounter: PerfCounter;
  14281. /**
  14282. * Gets the perf counter used for texture collisions
  14283. */
  14284. readonly textureCollisionsCounter: PerfCounter;
  14285. /**
  14286. * Instantiates a new scene instrumentation.
  14287. * This class can be used to get instrumentation data from a Babylon engine
  14288. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14289. * @param scene Defines the scene to instrument
  14290. */
  14291. constructor(
  14292. /**
  14293. * Defines the scene to instrument
  14294. */
  14295. scene: Scene);
  14296. /**
  14297. * Dispose and release associated resources.
  14298. */
  14299. dispose(): void;
  14300. }
  14301. }
  14302. declare module BABYLON {
  14303. /**
  14304. * @hidden
  14305. **/
  14306. class _TimeToken {
  14307. _startTimeQuery: Nullable<WebGLQuery>;
  14308. _endTimeQuery: Nullable<WebGLQuery>;
  14309. _timeElapsedQuery: Nullable<WebGLQuery>;
  14310. _timeElapsedQueryEnded: boolean;
  14311. }
  14312. }
  14313. declare module BABYLON {
  14314. /**
  14315. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14316. * It controls one of the indiviual texture used in the effect.
  14317. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14318. */
  14319. class LensFlare {
  14320. /**
  14321. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  14322. */
  14323. size: number;
  14324. /**
  14325. * 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.
  14326. */
  14327. position: number;
  14328. /**
  14329. * Define the lens color.
  14330. */
  14331. color: Color3;
  14332. /**
  14333. * Define the lens texture.
  14334. */
  14335. texture: Nullable<Texture>;
  14336. /**
  14337. * Define the alpha mode to render this particular lens.
  14338. */
  14339. alphaMode: number;
  14340. private _system;
  14341. /**
  14342. * Creates a new Lens Flare.
  14343. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14344. * It controls one of the indiviual texture used in the effect.
  14345. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14346. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  14347. * @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.
  14348. * @param color Define the lens color
  14349. * @param imgUrl Define the lens texture url
  14350. * @param system Define the `lensFlareSystem` this flare is part of
  14351. * @returns The newly created Lens Flare
  14352. */
  14353. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  14354. /**
  14355. * Instantiates a new Lens Flare.
  14356. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14357. * It controls one of the indiviual texture used in the effect.
  14358. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14359. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  14360. * @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.
  14361. * @param color Define the lens color
  14362. * @param imgUrl Define the lens texture url
  14363. * @param system Define the `lensFlareSystem` this flare is part of
  14364. */
  14365. constructor(
  14366. /**
  14367. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  14368. */
  14369. size: number,
  14370. /**
  14371. * 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.
  14372. */
  14373. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  14374. /**
  14375. * Dispose and release the lens flare with its associated resources.
  14376. */
  14377. dispose(): void;
  14378. }
  14379. }
  14380. declare module BABYLON {
  14381. /**
  14382. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  14383. * It is usually composed of several `BABYLON.lensFlare`.
  14384. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14385. */
  14386. class LensFlareSystem {
  14387. /**
  14388. * Define the name of the lens flare system
  14389. */
  14390. name: string;
  14391. /**
  14392. * List of lens flares used in this system.
  14393. */
  14394. lensFlares: LensFlare[];
  14395. /**
  14396. * Define a limit from the border the lens flare can be visible.
  14397. */
  14398. borderLimit: number;
  14399. /**
  14400. * Define a viewport border we do not want to see the lens flare in.
  14401. */
  14402. viewportBorder: number;
  14403. /**
  14404. * Define a predicate which could limit the list of meshes able to occlude the effect.
  14405. */
  14406. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  14407. /**
  14408. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  14409. */
  14410. layerMask: number;
  14411. /**
  14412. * Define the id of the lens flare system in the scene.
  14413. * (equal to name by default)
  14414. */
  14415. id: string;
  14416. private _scene;
  14417. private _emitter;
  14418. private _vertexBuffers;
  14419. private _indexBuffer;
  14420. private _effect;
  14421. private _positionX;
  14422. private _positionY;
  14423. private _isEnabled;
  14424. /**
  14425. * Instantiates a lens flare system.
  14426. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  14427. * It is usually composed of several `BABYLON.lensFlare`.
  14428. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14429. * @param name Define the name of the lens flare system in the scene
  14430. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  14431. * @param scene Define the scene the lens flare system belongs to
  14432. */
  14433. constructor(
  14434. /**
  14435. * Define the name of the lens flare system
  14436. */
  14437. name: string, emitter: any, scene: Scene);
  14438. /**
  14439. * Define if the lens flare system is enabled.
  14440. */
  14441. isEnabled: boolean;
  14442. /**
  14443. * Get the scene the effects belongs to.
  14444. * @returns the scene holding the lens flare system
  14445. */
  14446. getScene(): Scene;
  14447. /**
  14448. * Get the emitter of the lens flare system.
  14449. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  14450. * @returns the emitter of the lens flare system
  14451. */
  14452. getEmitter(): any;
  14453. /**
  14454. * Set the emitter of the lens flare system.
  14455. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  14456. * @param newEmitter Define the new emitter of the system
  14457. */
  14458. setEmitter(newEmitter: any): void;
  14459. /**
  14460. * Get the lens flare system emitter position.
  14461. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  14462. * @returns the position
  14463. */
  14464. getEmitterPosition(): Vector3;
  14465. /**
  14466. * @hidden
  14467. */
  14468. computeEffectivePosition(globalViewport: Viewport): boolean;
  14469. /** @hidden */
  14470. _isVisible(): boolean;
  14471. /**
  14472. * @hidden
  14473. */
  14474. render(): boolean;
  14475. /**
  14476. * Dispose and release the lens flare with its associated resources.
  14477. */
  14478. dispose(): void;
  14479. /**
  14480. * Parse a lens flare system from a JSON repressentation
  14481. * @param parsedLensFlareSystem Define the JSON to parse
  14482. * @param scene Define the scene the parsed system should be instantiated in
  14483. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  14484. * @returns the parsed system
  14485. */
  14486. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  14487. /**
  14488. * Serialize the current Lens Flare System into a JSON representation.
  14489. * @returns the serialized JSON
  14490. */
  14491. serialize(): any;
  14492. }
  14493. }
  14494. declare module BABYLON {
  14495. interface AbstractScene {
  14496. /**
  14497. * The list of lens flare system added to the scene
  14498. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14499. */
  14500. lensFlareSystems: Array<LensFlareSystem>;
  14501. /**
  14502. * Removes the given lens flare system from this scene.
  14503. * @param toRemove The lens flare system to remove
  14504. * @returns The index of the removed lens flare system
  14505. */
  14506. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  14507. /**
  14508. * Adds the given lens flare system to this scene
  14509. * @param newLensFlareSystem The lens flare system to add
  14510. */
  14511. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  14512. /**
  14513. * Gets a lens flare system using its name
  14514. * @param name defines the name to look for
  14515. * @returns the lens flare system or null if not found
  14516. */
  14517. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  14518. /**
  14519. * Gets a lens flare system using its id
  14520. * @param id defines the id to look for
  14521. * @returns the lens flare system or null if not found
  14522. */
  14523. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  14524. }
  14525. /**
  14526. * Defines the lens flare scene component responsible to manage any lens flares
  14527. * in a given scene.
  14528. */
  14529. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  14530. /**
  14531. * The component name helpfull to identify the component in the list of scene components.
  14532. */
  14533. readonly name: string;
  14534. /**
  14535. * The scene the component belongs to.
  14536. */
  14537. scene: Scene;
  14538. /**
  14539. * Creates a new instance of the component for the given scene
  14540. * @param scene Defines the scene to register the component in
  14541. */
  14542. constructor(scene: Scene);
  14543. /**
  14544. * Registers the component in a given scene
  14545. */
  14546. register(): void;
  14547. /**
  14548. * Rebuilds the elements related to this component in case of
  14549. * context lost for instance.
  14550. */
  14551. rebuild(): void;
  14552. /**
  14553. * Adds all the element from the container to the scene
  14554. * @param container the container holding the elements
  14555. */
  14556. addFromContainer(container: AbstractScene): void;
  14557. /**
  14558. * Removes all the elements in the container from the scene
  14559. * @param container contains the elements to remove
  14560. */
  14561. removeFromContainer(container: AbstractScene): void;
  14562. /**
  14563. * Serializes the component data to the specified json object
  14564. * @param serializationObject The object to serialize to
  14565. */
  14566. serialize(serializationObject: any): void;
  14567. /**
  14568. * Disposes the component and the associated ressources.
  14569. */
  14570. dispose(): void;
  14571. private _draw;
  14572. }
  14573. }
  14574. declare module BABYLON {
  14575. /**
  14576. * Effect layer options. This helps customizing the behaviour
  14577. * of the effect layer.
  14578. */
  14579. interface IEffectLayerOptions {
  14580. /**
  14581. * Multiplication factor apply to the canvas size to compute the render target size
  14582. * used to generated the objects (the smaller the faster).
  14583. */
  14584. mainTextureRatio: number;
  14585. /**
  14586. * Enforces a fixed size texture to ensure effect stability across devices.
  14587. */
  14588. mainTextureFixedSize?: number;
  14589. /**
  14590. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14591. */
  14592. alphaBlendingMode: number;
  14593. /**
  14594. * The camera attached to the layer.
  14595. */
  14596. camera: Nullable<Camera>;
  14597. /**
  14598. * The rendering group to draw the layer in.
  14599. */
  14600. renderingGroupId: number;
  14601. }
  14602. /**
  14603. * The effect layer Helps adding post process effect blended with the main pass.
  14604. *
  14605. * This can be for instance use to generate glow or higlight effects on the scene.
  14606. *
  14607. * The effect layer class can not be used directly and is intented to inherited from to be
  14608. * customized per effects.
  14609. */
  14610. abstract class EffectLayer {
  14611. private _vertexBuffers;
  14612. private _indexBuffer;
  14613. private _cachedDefines;
  14614. private _effectLayerMapGenerationEffect;
  14615. private _effectLayerOptions;
  14616. private _mergeEffect;
  14617. protected _scene: Scene;
  14618. protected _engine: Engine;
  14619. protected _maxSize: number;
  14620. protected _mainTextureDesiredSize: ISize;
  14621. protected _mainTexture: RenderTargetTexture;
  14622. protected _shouldRender: boolean;
  14623. protected _postProcesses: PostProcess[];
  14624. protected _textures: BaseTexture[];
  14625. protected _emissiveTextureAndColor: {
  14626. texture: Nullable<BaseTexture>;
  14627. color: Color4;
  14628. };
  14629. /**
  14630. * The name of the layer
  14631. */
  14632. name: string;
  14633. /**
  14634. * The clear color of the texture used to generate the glow map.
  14635. */
  14636. neutralColor: Color4;
  14637. /**
  14638. * Specifies wether the highlight layer is enabled or not.
  14639. */
  14640. isEnabled: boolean;
  14641. /**
  14642. * Gets the camera attached to the layer.
  14643. */
  14644. readonly camera: Nullable<Camera>;
  14645. /**
  14646. * Gets the rendering group id the layer should render in.
  14647. */
  14648. readonly renderingGroupId: number;
  14649. /**
  14650. * An event triggered when the effect layer has been disposed.
  14651. */
  14652. onDisposeObservable: Observable<EffectLayer>;
  14653. /**
  14654. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14655. */
  14656. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14657. /**
  14658. * An event triggered when the generated texture is being merged in the scene.
  14659. */
  14660. onBeforeComposeObservable: Observable<EffectLayer>;
  14661. /**
  14662. * An event triggered when the generated texture has been merged in the scene.
  14663. */
  14664. onAfterComposeObservable: Observable<EffectLayer>;
  14665. /**
  14666. * An event triggered when the efffect layer changes its size.
  14667. */
  14668. onSizeChangedObservable: Observable<EffectLayer>;
  14669. /**
  14670. * Instantiates a new effect Layer and references it in the scene.
  14671. * @param name The name of the layer
  14672. * @param scene The scene to use the layer in
  14673. */
  14674. constructor(
  14675. /** The Friendly of the effect in the scene */
  14676. name: string, scene: Scene);
  14677. /**
  14678. * Get the effect name of the layer.
  14679. * @return The effect name
  14680. */
  14681. abstract getEffectName(): string;
  14682. /**
  14683. * Checks for the readiness of the element composing the layer.
  14684. * @param subMesh the mesh to check for
  14685. * @param useInstances specify wether or not to use instances to render the mesh
  14686. * @return true if ready otherwise, false
  14687. */
  14688. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14689. /**
  14690. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14691. * @returns true if the effect requires stencil during the main canvas render pass.
  14692. */
  14693. abstract needStencil(): boolean;
  14694. /**
  14695. * Create the merge effect. This is the shader use to blit the information back
  14696. * to the main canvas at the end of the scene rendering.
  14697. * @returns The effect containing the shader used to merge the effect on the main canvas
  14698. */
  14699. protected abstract _createMergeEffect(): Effect;
  14700. /**
  14701. * Creates the render target textures and post processes used in the effect layer.
  14702. */
  14703. protected abstract _createTextureAndPostProcesses(): void;
  14704. /**
  14705. * Implementation specific of rendering the generating effect on the main canvas.
  14706. * @param effect The effect used to render through
  14707. */
  14708. protected abstract _internalRender(effect: Effect): void;
  14709. /**
  14710. * Sets the required values for both the emissive texture and and the main color.
  14711. */
  14712. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14713. /**
  14714. * Free any resources and references associated to a mesh.
  14715. * Internal use
  14716. * @param mesh The mesh to free.
  14717. */
  14718. abstract _disposeMesh(mesh: Mesh): void;
  14719. /**
  14720. * Serializes this layer (Glow or Highlight for example)
  14721. * @returns a serialized layer object
  14722. */
  14723. abstract serialize?(): any;
  14724. /**
  14725. * Initializes the effect layer with the required options.
  14726. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14727. */
  14728. protected _init(options: Partial<IEffectLayerOptions>): void;
  14729. /**
  14730. * Generates the index buffer of the full screen quad blending to the main canvas.
  14731. */
  14732. private _generateIndexBuffer;
  14733. /**
  14734. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14735. */
  14736. private _genrateVertexBuffer;
  14737. /**
  14738. * Sets the main texture desired size which is the closest power of two
  14739. * of the engine canvas size.
  14740. */
  14741. private _setMainTextureSize;
  14742. /**
  14743. * Creates the main texture for the effect layer.
  14744. */
  14745. protected _createMainTexture(): void;
  14746. /**
  14747. * Checks for the readiness of the element composing the layer.
  14748. * @param subMesh the mesh to check for
  14749. * @param useInstances specify wether or not to use instances to render the mesh
  14750. * @param emissiveTexture the associated emissive texture used to generate the glow
  14751. * @return true if ready otherwise, false
  14752. */
  14753. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14754. /**
  14755. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14756. */
  14757. render(): void;
  14758. /**
  14759. * Determine if a given mesh will be used in the current effect.
  14760. * @param mesh mesh to test
  14761. * @returns true if the mesh will be used
  14762. */
  14763. hasMesh(mesh: AbstractMesh): boolean;
  14764. /**
  14765. * Returns true if the layer contains information to display, otherwise false.
  14766. * @returns true if the glow layer should be rendered
  14767. */
  14768. shouldRender(): boolean;
  14769. /**
  14770. * Returns true if the mesh should render, otherwise false.
  14771. * @param mesh The mesh to render
  14772. * @returns true if it should render otherwise false
  14773. */
  14774. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14775. /**
  14776. * Returns true if the mesh should render, otherwise false.
  14777. * @param mesh The mesh to render
  14778. * @returns true if it should render otherwise false
  14779. */
  14780. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14781. /**
  14782. * Renders the submesh passed in parameter to the generation map.
  14783. */
  14784. protected _renderSubMesh(subMesh: SubMesh): void;
  14785. /**
  14786. * Rebuild the required buffers.
  14787. * @hidden Internal use only.
  14788. */
  14789. _rebuild(): void;
  14790. /**
  14791. * Dispose only the render target textures and post process.
  14792. */
  14793. private _disposeTextureAndPostProcesses;
  14794. /**
  14795. * Dispose the highlight layer and free resources.
  14796. */
  14797. dispose(): void;
  14798. /**
  14799. * Gets the class name of the effect layer
  14800. * @returns the string with the class name of the effect layer
  14801. */
  14802. getClassName(): string;
  14803. /**
  14804. * Creates an effect layer from parsed effect layer data
  14805. * @param parsedEffectLayer defines effect layer data
  14806. * @param scene defines the current scene
  14807. * @param rootUrl defines the root URL containing the effect layer information
  14808. * @returns a parsed effect Layer
  14809. */
  14810. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14811. }
  14812. }
  14813. declare module BABYLON {
  14814. interface AbstractScene {
  14815. /**
  14816. * The list of effect layers (highlights/glow) added to the scene
  14817. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14818. * @see http://doc.babylonjs.com/how_to/glow_layer
  14819. */
  14820. effectLayers: Array<EffectLayer>;
  14821. /**
  14822. * Removes the given effect layer from this scene.
  14823. * @param toRemove defines the effect layer to remove
  14824. * @returns the index of the removed effect layer
  14825. */
  14826. removeEffectLayer(toRemove: EffectLayer): number;
  14827. /**
  14828. * Adds the given effect layer to this scene
  14829. * @param newEffectLayer defines the effect layer to add
  14830. */
  14831. addEffectLayer(newEffectLayer: EffectLayer): void;
  14832. }
  14833. /**
  14834. * Defines the layer scene component responsible to manage any effect layers
  14835. * in a given scene.
  14836. */
  14837. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14838. /**
  14839. * The component name helpfull to identify the component in the list of scene components.
  14840. */
  14841. readonly name: string;
  14842. /**
  14843. * The scene the component belongs to.
  14844. */
  14845. scene: Scene;
  14846. private _engine;
  14847. private _renderEffects;
  14848. private _needStencil;
  14849. private _previousStencilState;
  14850. /**
  14851. * Creates a new instance of the component for the given scene
  14852. * @param scene Defines the scene to register the component in
  14853. */
  14854. constructor(scene: Scene);
  14855. /**
  14856. * Registers the component in a given scene
  14857. */
  14858. register(): void;
  14859. /**
  14860. * Rebuilds the elements related to this component in case of
  14861. * context lost for instance.
  14862. */
  14863. rebuild(): void;
  14864. /**
  14865. * Serializes the component data to the specified json object
  14866. * @param serializationObject The object to serialize to
  14867. */
  14868. serialize(serializationObject: any): void;
  14869. /**
  14870. * Adds all the element from the container to the scene
  14871. * @param container the container holding the elements
  14872. */
  14873. addFromContainer(container: AbstractScene): void;
  14874. /**
  14875. * Removes all the elements in the container from the scene
  14876. * @param container contains the elements to remove
  14877. */
  14878. removeFromContainer(container: AbstractScene): void;
  14879. /**
  14880. * Disposes the component and the associated ressources.
  14881. */
  14882. dispose(): void;
  14883. private _isReadyForMesh;
  14884. private _renderMainTexture;
  14885. private _setStencil;
  14886. private _setStencilBack;
  14887. private _draw;
  14888. private _drawCamera;
  14889. private _drawRenderingGroup;
  14890. }
  14891. }
  14892. declare module BABYLON {
  14893. interface AbstractScene {
  14894. /**
  14895. * Return a the first highlight layer of the scene with a given name.
  14896. * @param name The name of the highlight layer to look for.
  14897. * @return The highlight layer if found otherwise null.
  14898. */
  14899. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14900. }
  14901. /**
  14902. * Glow layer options. This helps customizing the behaviour
  14903. * of the glow layer.
  14904. */
  14905. interface IGlowLayerOptions {
  14906. /**
  14907. * Multiplication factor apply to the canvas size to compute the render target size
  14908. * used to generated the glowing objects (the smaller the faster).
  14909. */
  14910. mainTextureRatio: number;
  14911. /**
  14912. * Enforces a fixed size texture to ensure resize independant blur.
  14913. */
  14914. mainTextureFixedSize?: number;
  14915. /**
  14916. * How big is the kernel of the blur texture.
  14917. */
  14918. blurKernelSize: number;
  14919. /**
  14920. * The camera attached to the layer.
  14921. */
  14922. camera: Nullable<Camera>;
  14923. /**
  14924. * Enable MSAA by chosing the number of samples.
  14925. */
  14926. mainTextureSamples?: number;
  14927. /**
  14928. * The rendering group to draw the layer in.
  14929. */
  14930. renderingGroupId: number;
  14931. }
  14932. /**
  14933. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14934. *
  14935. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14936. * glowy meshes to your scene.
  14937. *
  14938. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14939. */
  14940. class GlowLayer extends EffectLayer {
  14941. /**
  14942. * Effect Name of the layer.
  14943. */
  14944. static readonly EffectName: string;
  14945. /**
  14946. * The default blur kernel size used for the glow.
  14947. */
  14948. static DefaultBlurKernelSize: number;
  14949. /**
  14950. * The default texture size ratio used for the glow.
  14951. */
  14952. static DefaultTextureRatio: number;
  14953. /**
  14954. * Sets the kernel size of the blur.
  14955. */
  14956. /**
  14957. * Gets the kernel size of the blur.
  14958. */
  14959. blurKernelSize: number;
  14960. /**
  14961. * Sets the glow intensity.
  14962. */
  14963. /**
  14964. * Gets the glow intensity.
  14965. */
  14966. intensity: number;
  14967. private _options;
  14968. private _intensity;
  14969. private _horizontalBlurPostprocess1;
  14970. private _verticalBlurPostprocess1;
  14971. private _horizontalBlurPostprocess2;
  14972. private _verticalBlurPostprocess2;
  14973. private _blurTexture1;
  14974. private _blurTexture2;
  14975. private _postProcesses1;
  14976. private _postProcesses2;
  14977. private _includedOnlyMeshes;
  14978. private _excludedMeshes;
  14979. /**
  14980. * Callback used to let the user override the color selection on a per mesh basis
  14981. */
  14982. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14983. /**
  14984. * Callback used to let the user override the texture selection on a per mesh basis
  14985. */
  14986. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14987. /**
  14988. * Instantiates a new glow Layer and references it to the scene.
  14989. * @param name The name of the layer
  14990. * @param scene The scene to use the layer in
  14991. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14992. */
  14993. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14994. /**
  14995. * Get the effect name of the layer.
  14996. * @return The effect name
  14997. */
  14998. getEffectName(): string;
  14999. /**
  15000. * Create the merge effect. This is the shader use to blit the information back
  15001. * to the main canvas at the end of the scene rendering.
  15002. */
  15003. protected _createMergeEffect(): Effect;
  15004. /**
  15005. * Creates the render target textures and post processes used in the glow layer.
  15006. */
  15007. protected _createTextureAndPostProcesses(): void;
  15008. /**
  15009. * Checks for the readiness of the element composing the layer.
  15010. * @param subMesh the mesh to check for
  15011. * @param useInstances specify wether or not to use instances to render the mesh
  15012. * @param emissiveTexture the associated emissive texture used to generate the glow
  15013. * @return true if ready otherwise, false
  15014. */
  15015. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  15016. /**
  15017. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  15018. */
  15019. needStencil(): boolean;
  15020. /**
  15021. * Implementation specific of rendering the generating effect on the main canvas.
  15022. * @param effect The effect used to render through
  15023. */
  15024. protected _internalRender(effect: Effect): void;
  15025. /**
  15026. * Sets the required values for both the emissive texture and and the main color.
  15027. */
  15028. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  15029. /**
  15030. * Returns true if the mesh should render, otherwise false.
  15031. * @param mesh The mesh to render
  15032. * @returns true if it should render otherwise false
  15033. */
  15034. protected _shouldRenderMesh(mesh: Mesh): boolean;
  15035. /**
  15036. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  15037. * @param mesh The mesh to exclude from the glow layer
  15038. */
  15039. addExcludedMesh(mesh: Mesh): void;
  15040. /**
  15041. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  15042. * @param mesh The mesh to remove
  15043. */
  15044. removeExcludedMesh(mesh: Mesh): void;
  15045. /**
  15046. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  15047. * @param mesh The mesh to include in the glow layer
  15048. */
  15049. addIncludedOnlyMesh(mesh: Mesh): void;
  15050. /**
  15051. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  15052. * @param mesh The mesh to remove
  15053. */
  15054. removeIncludedOnlyMesh(mesh: Mesh): void;
  15055. /**
  15056. * Determine if a given mesh will be used in the glow layer
  15057. * @param mesh The mesh to test
  15058. * @returns true if the mesh will be highlighted by the current glow layer
  15059. */
  15060. hasMesh(mesh: AbstractMesh): boolean;
  15061. /**
  15062. * Free any resources and references associated to a mesh.
  15063. * Internal use
  15064. * @param mesh The mesh to free.
  15065. * @hidden
  15066. */
  15067. _disposeMesh(mesh: Mesh): void;
  15068. /**
  15069. * Gets the class name of the effect layer
  15070. * @returns the string with the class name of the effect layer
  15071. */
  15072. getClassName(): string;
  15073. /**
  15074. * Serializes this glow layer
  15075. * @returns a serialized glow layer object
  15076. */
  15077. serialize(): any;
  15078. /**
  15079. * Creates a Glow Layer from parsed glow layer data
  15080. * @param parsedGlowLayer defines glow layer data
  15081. * @param scene defines the current scene
  15082. * @param rootUrl defines the root URL containing the glow layer information
  15083. * @returns a parsed Glow Layer
  15084. */
  15085. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  15086. }
  15087. }
  15088. declare module BABYLON {
  15089. interface AbstractScene {
  15090. /**
  15091. * Return a the first highlight layer of the scene with a given name.
  15092. * @param name The name of the highlight layer to look for.
  15093. * @return The highlight layer if found otherwise null.
  15094. */
  15095. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  15096. }
  15097. /**
  15098. * Highlight layer options. This helps customizing the behaviour
  15099. * of the highlight layer.
  15100. */
  15101. interface IHighlightLayerOptions {
  15102. /**
  15103. * Multiplication factor apply to the canvas size to compute the render target size
  15104. * used to generated the glowing objects (the smaller the faster).
  15105. */
  15106. mainTextureRatio: number;
  15107. /**
  15108. * Enforces a fixed size texture to ensure resize independant blur.
  15109. */
  15110. mainTextureFixedSize?: number;
  15111. /**
  15112. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  15113. * of the picture to blur (the smaller the faster).
  15114. */
  15115. blurTextureSizeRatio: number;
  15116. /**
  15117. * How big in texel of the blur texture is the vertical blur.
  15118. */
  15119. blurVerticalSize: number;
  15120. /**
  15121. * How big in texel of the blur texture is the horizontal blur.
  15122. */
  15123. blurHorizontalSize: number;
  15124. /**
  15125. * Alpha blending mode used to apply the blur. Default is combine.
  15126. */
  15127. alphaBlendingMode: number;
  15128. /**
  15129. * The camera attached to the layer.
  15130. */
  15131. camera: Nullable<Camera>;
  15132. /**
  15133. * Should we display highlight as a solid stroke?
  15134. */
  15135. isStroke?: boolean;
  15136. /**
  15137. * The rendering group to draw the layer in.
  15138. */
  15139. renderingGroupId: number;
  15140. }
  15141. /**
  15142. * The highlight layer Helps adding a glow effect around a mesh.
  15143. *
  15144. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  15145. * glowy meshes to your scene.
  15146. *
  15147. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  15148. */
  15149. class HighlightLayer extends EffectLayer {
  15150. name: string;
  15151. /**
  15152. * Effect Name of the highlight layer.
  15153. */
  15154. static readonly EffectName: string;
  15155. /**
  15156. * The neutral color used during the preparation of the glow effect.
  15157. * This is black by default as the blend operation is a blend operation.
  15158. */
  15159. static NeutralColor: Color4;
  15160. /**
  15161. * Stencil value used for glowing meshes.
  15162. */
  15163. static GlowingMeshStencilReference: number;
  15164. /**
  15165. * Stencil value used for the other meshes in the scene.
  15166. */
  15167. static NormalMeshStencilReference: number;
  15168. /**
  15169. * Specifies whether or not the inner glow is ACTIVE in the layer.
  15170. */
  15171. innerGlow: boolean;
  15172. /**
  15173. * Specifies whether or not the outer glow is ACTIVE in the layer.
  15174. */
  15175. outerGlow: boolean;
  15176. /**
  15177. * Specifies the horizontal size of the blur.
  15178. */
  15179. /**
  15180. * Gets the horizontal size of the blur.
  15181. */
  15182. blurHorizontalSize: number;
  15183. /**
  15184. * Specifies the vertical size of the blur.
  15185. */
  15186. /**
  15187. * Gets the vertical size of the blur.
  15188. */
  15189. blurVerticalSize: number;
  15190. /**
  15191. * An event triggered when the highlight layer is being blurred.
  15192. */
  15193. onBeforeBlurObservable: Observable<HighlightLayer>;
  15194. /**
  15195. * An event triggered when the highlight layer has been blurred.
  15196. */
  15197. onAfterBlurObservable: Observable<HighlightLayer>;
  15198. private _instanceGlowingMeshStencilReference;
  15199. private _options;
  15200. private _downSamplePostprocess;
  15201. private _horizontalBlurPostprocess;
  15202. private _verticalBlurPostprocess;
  15203. private _blurTexture;
  15204. private _meshes;
  15205. private _excludedMeshes;
  15206. /**
  15207. * Instantiates a new highlight Layer and references it to the scene..
  15208. * @param name The name of the layer
  15209. * @param scene The scene to use the layer in
  15210. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  15211. */
  15212. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  15213. /**
  15214. * Get the effect name of the layer.
  15215. * @return The effect name
  15216. */
  15217. getEffectName(): string;
  15218. /**
  15219. * Create the merge effect. This is the shader use to blit the information back
  15220. * to the main canvas at the end of the scene rendering.
  15221. */
  15222. protected _createMergeEffect(): Effect;
  15223. /**
  15224. * Creates the render target textures and post processes used in the highlight layer.
  15225. */
  15226. protected _createTextureAndPostProcesses(): void;
  15227. /**
  15228. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  15229. */
  15230. needStencil(): boolean;
  15231. /**
  15232. * Checks for the readiness of the element composing the layer.
  15233. * @param subMesh the mesh to check for
  15234. * @param useInstances specify wether or not to use instances to render the mesh
  15235. * @param emissiveTexture the associated emissive texture used to generate the glow
  15236. * @return true if ready otherwise, false
  15237. */
  15238. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  15239. /**
  15240. * Implementation specific of rendering the generating effect on the main canvas.
  15241. * @param effect The effect used to render through
  15242. */
  15243. protected _internalRender(effect: Effect): void;
  15244. /**
  15245. * Returns true if the layer contains information to display, otherwise false.
  15246. */
  15247. shouldRender(): boolean;
  15248. /**
  15249. * Returns true if the mesh should render, otherwise false.
  15250. * @param mesh The mesh to render
  15251. * @returns true if it should render otherwise false
  15252. */
  15253. protected _shouldRenderMesh(mesh: Mesh): boolean;
  15254. /**
  15255. * Sets the required values for both the emissive texture and and the main color.
  15256. */
  15257. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  15258. /**
  15259. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  15260. * @param mesh The mesh to exclude from the highlight layer
  15261. */
  15262. addExcludedMesh(mesh: Mesh): void;
  15263. /**
  15264. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  15265. * @param mesh The mesh to highlight
  15266. */
  15267. removeExcludedMesh(mesh: Mesh): void;
  15268. /**
  15269. * Determine if a given mesh will be highlighted by the current HighlightLayer
  15270. * @param mesh mesh to test
  15271. * @returns true if the mesh will be highlighted by the current HighlightLayer
  15272. */
  15273. hasMesh(mesh: AbstractMesh): boolean;
  15274. /**
  15275. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  15276. * @param mesh The mesh to highlight
  15277. * @param color The color of the highlight
  15278. * @param glowEmissiveOnly Extract the glow from the emissive texture
  15279. */
  15280. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  15281. /**
  15282. * Remove a mesh from the highlight layer in order to make it stop glowing.
  15283. * @param mesh The mesh to highlight
  15284. */
  15285. removeMesh(mesh: Mesh): void;
  15286. /**
  15287. * Force the stencil to the normal expected value for none glowing parts
  15288. */
  15289. private _defaultStencilReference;
  15290. /**
  15291. * Free any resources and references associated to a mesh.
  15292. * Internal use
  15293. * @param mesh The mesh to free.
  15294. * @hidden
  15295. */
  15296. _disposeMesh(mesh: Mesh): void;
  15297. /**
  15298. * Dispose the highlight layer and free resources.
  15299. */
  15300. dispose(): void;
  15301. /**
  15302. * Gets the class name of the effect layer
  15303. * @returns the string with the class name of the effect layer
  15304. */
  15305. getClassName(): string;
  15306. /**
  15307. * Serializes this Highlight layer
  15308. * @returns a serialized Highlight layer object
  15309. */
  15310. serialize(): any;
  15311. /**
  15312. * Creates a Highlight layer from parsed Highlight layer data
  15313. * @param parsedHightlightLayer defines the Highlight layer data
  15314. * @param scene defines the current scene
  15315. * @param rootUrl defines the root URL containing the Highlight layer information
  15316. * @returns a parsed Highlight layer
  15317. */
  15318. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  15319. }
  15320. }
  15321. declare module BABYLON {
  15322. /**
  15323. * This represents a full screen 2d layer.
  15324. * This can be useful to display a picture in the background of your scene for instance.
  15325. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15326. */
  15327. class Layer {
  15328. /**
  15329. * Define the name of the layer.
  15330. */
  15331. name: string;
  15332. /**
  15333. * Define the texture the layer should display.
  15334. */
  15335. texture: Nullable<Texture>;
  15336. /**
  15337. * Is the layer in background or foreground.
  15338. */
  15339. isBackground: boolean;
  15340. /**
  15341. * Define the color of the layer (instead of texture).
  15342. */
  15343. color: Color4;
  15344. /**
  15345. * Define the scale of the layer in order to zoom in out of the texture.
  15346. */
  15347. scale: Vector2;
  15348. /**
  15349. * Define an offset for the layer in order to shift the texture.
  15350. */
  15351. offset: Vector2;
  15352. /**
  15353. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  15354. */
  15355. alphaBlendingMode: number;
  15356. /**
  15357. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  15358. * Alpha test will not mix with the background color in case of transparency.
  15359. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  15360. */
  15361. alphaTest: boolean;
  15362. /**
  15363. * Define a mask to restrict the layer to only some of the scene cameras.
  15364. */
  15365. layerMask: number;
  15366. /**
  15367. * Define the list of render target the layer is visible into.
  15368. */
  15369. renderTargetTextures: RenderTargetTexture[];
  15370. /**
  15371. * Define if the layer is only used in renderTarget or if it also
  15372. * renders in the main frame buffer of the canvas.
  15373. */
  15374. renderOnlyInRenderTargetTextures: boolean;
  15375. private _scene;
  15376. private _vertexBuffers;
  15377. private _indexBuffer;
  15378. private _effect;
  15379. private _alphaTestEffect;
  15380. /**
  15381. * An event triggered when the layer is disposed.
  15382. */
  15383. onDisposeObservable: Observable<Layer>;
  15384. private _onDisposeObserver;
  15385. /**
  15386. * Back compatibility with callback before the onDisposeObservable existed.
  15387. * The set callback will be triggered when the layer has been disposed.
  15388. */
  15389. onDispose: () => void;
  15390. /**
  15391. * An event triggered before rendering the scene
  15392. */
  15393. onBeforeRenderObservable: Observable<Layer>;
  15394. private _onBeforeRenderObserver;
  15395. /**
  15396. * Back compatibility with callback before the onBeforeRenderObservable existed.
  15397. * The set callback will be triggered just before rendering the layer.
  15398. */
  15399. onBeforeRender: () => void;
  15400. /**
  15401. * An event triggered after rendering the scene
  15402. */
  15403. onAfterRenderObservable: Observable<Layer>;
  15404. private _onAfterRenderObserver;
  15405. /**
  15406. * Back compatibility with callback before the onAfterRenderObservable existed.
  15407. * The set callback will be triggered just after rendering the layer.
  15408. */
  15409. onAfterRender: () => void;
  15410. /**
  15411. * Instantiates a new layer.
  15412. * This represents a full screen 2d layer.
  15413. * This can be useful to display a picture in the background of your scene for instance.
  15414. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15415. * @param name Define the name of the layer in the scene
  15416. * @param imgUrl Define the url of the texture to display in the layer
  15417. * @param scene Define the scene the layer belongs to
  15418. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  15419. * @param color Defines a color for the layer
  15420. */
  15421. constructor(
  15422. /**
  15423. * Define the name of the layer.
  15424. */
  15425. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  15426. private _createIndexBuffer;
  15427. /** @hidden */
  15428. _rebuild(): void;
  15429. /**
  15430. * Renders the layer in the scene.
  15431. */
  15432. render(): void;
  15433. /**
  15434. * Disposes and releases the associated ressources.
  15435. */
  15436. dispose(): void;
  15437. }
  15438. }
  15439. declare module BABYLON {
  15440. interface AbstractScene {
  15441. /**
  15442. * The list of layers (background and foreground) of the scene
  15443. */
  15444. layers: Array<Layer>;
  15445. }
  15446. /**
  15447. * Defines the layer scene component responsible to manage any layers
  15448. * in a given scene.
  15449. */
  15450. class LayerSceneComponent implements ISceneComponent {
  15451. /**
  15452. * The component name helpfull to identify the component in the list of scene components.
  15453. */
  15454. readonly name: string;
  15455. /**
  15456. * The scene the component belongs to.
  15457. */
  15458. scene: Scene;
  15459. private _engine;
  15460. /**
  15461. * Creates a new instance of the component for the given scene
  15462. * @param scene Defines the scene to register the component in
  15463. */
  15464. constructor(scene: Scene);
  15465. /**
  15466. * Registers the component in a given scene
  15467. */
  15468. register(): void;
  15469. /**
  15470. * Rebuilds the elements related to this component in case of
  15471. * context lost for instance.
  15472. */
  15473. rebuild(): void;
  15474. /**
  15475. * Disposes the component and the associated ressources.
  15476. */
  15477. dispose(): void;
  15478. private _draw;
  15479. private _drawCameraPredicate;
  15480. private _drawCameraBackground;
  15481. private _drawCameraForeground;
  15482. private _drawRenderTargetPredicate;
  15483. private _drawRenderTargetBackground;
  15484. private _drawRenderTargetForeground;
  15485. }
  15486. }
  15487. declare module BABYLON {
  15488. /**
  15489. * A directional light is defined by a direction (what a surprise!).
  15490. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15491. * 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.
  15492. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15493. */
  15494. class DirectionalLight extends ShadowLight {
  15495. private _shadowFrustumSize;
  15496. /**
  15497. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15498. */
  15499. /**
  15500. * Specifies a fix frustum size for the shadow generation.
  15501. */
  15502. shadowFrustumSize: number;
  15503. private _shadowOrthoScale;
  15504. /**
  15505. * Gets the shadow projection scale against the optimal computed one.
  15506. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15507. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15508. */
  15509. /**
  15510. * Sets the shadow projection scale against the optimal computed one.
  15511. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15512. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15513. */
  15514. shadowOrthoScale: number;
  15515. /**
  15516. * Automatically compute the projection matrix to best fit (including all the casters)
  15517. * on each frame.
  15518. */
  15519. autoUpdateExtends: boolean;
  15520. private _orthoLeft;
  15521. private _orthoRight;
  15522. private _orthoTop;
  15523. private _orthoBottom;
  15524. /**
  15525. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15526. * The directional light is emitted from everywhere in the given direction.
  15527. * It can cast shadows.
  15528. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15529. * @param name The friendly name of the light
  15530. * @param direction The direction of the light
  15531. * @param scene The scene the light belongs to
  15532. */
  15533. constructor(name: string, direction: Vector3, scene: Scene);
  15534. /**
  15535. * Returns the string "DirectionalLight".
  15536. * @return The class name
  15537. */
  15538. getClassName(): string;
  15539. /**
  15540. * Returns the integer 1.
  15541. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15542. */
  15543. getTypeID(): number;
  15544. /**
  15545. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15546. * Returns the DirectionalLight Shadow projection matrix.
  15547. */
  15548. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15549. /**
  15550. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15551. * Returns the DirectionalLight Shadow projection matrix.
  15552. */
  15553. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15554. /**
  15555. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15556. * Returns the DirectionalLight Shadow projection matrix.
  15557. */
  15558. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15559. protected _buildUniformLayout(): void;
  15560. /**
  15561. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15562. * @param effect The effect to update
  15563. * @param lightIndex The index of the light in the effect to update
  15564. * @returns The directional light
  15565. */
  15566. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15567. /**
  15568. * Gets the minZ used for shadow according to both the scene and the light.
  15569. *
  15570. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15571. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15572. * @param activeCamera The camera we are returning the min for
  15573. * @returns the depth min z
  15574. */
  15575. getDepthMinZ(activeCamera: Camera): number;
  15576. /**
  15577. * Gets the maxZ used for shadow according to both the scene and the light.
  15578. *
  15579. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15580. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15581. * @param activeCamera The camera we are returning the max for
  15582. * @returns the depth max z
  15583. */
  15584. getDepthMaxZ(activeCamera: Camera): number;
  15585. /**
  15586. * Prepares the list of defines specific to the light type.
  15587. * @param defines the list of defines
  15588. * @param lightIndex defines the index of the light for the effect
  15589. */
  15590. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15591. }
  15592. }
  15593. declare module BABYLON {
  15594. /**
  15595. * The HemisphericLight simulates the ambient environment light,
  15596. * so the passed direction is the light reflection direction, not the incoming direction.
  15597. */
  15598. class HemisphericLight extends Light {
  15599. /**
  15600. * The groundColor is the light in the opposite direction to the one specified during creation.
  15601. * 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.
  15602. */
  15603. groundColor: Color3;
  15604. /**
  15605. * The light reflection direction, not the incoming direction.
  15606. */
  15607. direction: Vector3;
  15608. /**
  15609. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15610. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15611. * The HemisphericLight can't cast shadows.
  15612. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15613. * @param name The friendly name of the light
  15614. * @param direction The direction of the light reflection
  15615. * @param scene The scene the light belongs to
  15616. */
  15617. constructor(name: string, direction: Vector3, scene: Scene);
  15618. protected _buildUniformLayout(): void;
  15619. /**
  15620. * Returns the string "HemisphericLight".
  15621. * @return The class name
  15622. */
  15623. getClassName(): string;
  15624. /**
  15625. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15626. * Returns the updated direction.
  15627. * @param target The target the direction should point to
  15628. * @return The computed direction
  15629. */
  15630. setDirectionToTarget(target: Vector3): Vector3;
  15631. /**
  15632. * Returns the shadow generator associated to the light.
  15633. * @returns Always null for hemispheric lights because it does not support shadows.
  15634. */
  15635. getShadowGenerator(): Nullable<IShadowGenerator>;
  15636. /**
  15637. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15638. * @param effect The effect to update
  15639. * @param lightIndex The index of the light in the effect to update
  15640. * @returns The hemispheric light
  15641. */
  15642. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15643. /**
  15644. * Computes the world matrix of the node
  15645. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15646. * @param useWasUpdatedFlag defines a reserved property
  15647. * @returns the world matrix
  15648. */
  15649. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15650. /**
  15651. * Returns the integer 3.
  15652. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15653. */
  15654. getTypeID(): number;
  15655. /**
  15656. * Prepares the list of defines specific to the light type.
  15657. * @param defines the list of defines
  15658. * @param lightIndex defines the index of the light for the effect
  15659. */
  15660. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15661. }
  15662. }
  15663. declare module BABYLON {
  15664. /**
  15665. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15666. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15667. * 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.
  15668. */
  15669. abstract class Light extends Node {
  15670. /**
  15671. * Falloff Default: light is falling off following the material specification:
  15672. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15673. */
  15674. static readonly FALLOFF_DEFAULT: number;
  15675. /**
  15676. * Falloff Physical: light is falling off following the inverse squared distance law.
  15677. */
  15678. static readonly FALLOFF_PHYSICAL: number;
  15679. /**
  15680. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15681. * to enhance interoperability with other engines.
  15682. */
  15683. static readonly FALLOFF_GLTF: number;
  15684. /**
  15685. * Falloff Standard: light is falling off like in the standard material
  15686. * to enhance interoperability with other materials.
  15687. */
  15688. static readonly FALLOFF_STANDARD: number;
  15689. /**
  15690. * If every light affecting the material is in this lightmapMode,
  15691. * material.lightmapTexture adds or multiplies
  15692. * (depends on material.useLightmapAsShadowmap)
  15693. * after every other light calculations.
  15694. */
  15695. static readonly LIGHTMAP_DEFAULT: number;
  15696. /**
  15697. * material.lightmapTexture as only diffuse lighting from this light
  15698. * adds only specular lighting from this light
  15699. * adds dynamic shadows
  15700. */
  15701. static readonly LIGHTMAP_SPECULAR: number;
  15702. /**
  15703. * material.lightmapTexture as only lighting
  15704. * no light calculation from this light
  15705. * only adds dynamic shadows from this light
  15706. */
  15707. static readonly LIGHTMAP_SHADOWSONLY: number;
  15708. /**
  15709. * Each light type uses the default quantity according to its type:
  15710. * point/spot lights use luminous intensity
  15711. * directional lights use illuminance
  15712. */
  15713. static readonly INTENSITYMODE_AUTOMATIC: number;
  15714. /**
  15715. * lumen (lm)
  15716. */
  15717. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15718. /**
  15719. * candela (lm/sr)
  15720. */
  15721. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15722. /**
  15723. * lux (lm/m^2)
  15724. */
  15725. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15726. /**
  15727. * nit (cd/m^2)
  15728. */
  15729. static readonly INTENSITYMODE_LUMINANCE: number;
  15730. /**
  15731. * Light type const id of the point light.
  15732. */
  15733. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15734. /**
  15735. * Light type const id of the directional light.
  15736. */
  15737. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15738. /**
  15739. * Light type const id of the spot light.
  15740. */
  15741. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15742. /**
  15743. * Light type const id of the hemispheric light.
  15744. */
  15745. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15746. /**
  15747. * Diffuse gives the basic color to an object.
  15748. */
  15749. diffuse: Color3;
  15750. /**
  15751. * Specular produces a highlight color on an object.
  15752. * Note: This is note affecting PBR materials.
  15753. */
  15754. specular: Color3;
  15755. /**
  15756. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15757. * falling off base on range or angle.
  15758. * This can be set to any values in Light.FALLOFF_x.
  15759. *
  15760. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  15761. * other types of materials.
  15762. */
  15763. falloffType: number;
  15764. /**
  15765. * Strength of the light.
  15766. * Note: By default it is define in the framework own unit.
  15767. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15768. */
  15769. intensity: number;
  15770. private _range;
  15771. protected _inverseSquaredRange: number;
  15772. /**
  15773. * Defines how far from the source the light is impacting in scene units.
  15774. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15775. */
  15776. /**
  15777. * Defines how far from the source the light is impacting in scene units.
  15778. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15779. */
  15780. range: number;
  15781. /**
  15782. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15783. * of light.
  15784. */
  15785. private _photometricScale;
  15786. private _intensityMode;
  15787. /**
  15788. * Gets the photometric scale used to interpret the intensity.
  15789. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15790. */
  15791. /**
  15792. * Sets the photometric scale used to interpret the intensity.
  15793. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15794. */
  15795. intensityMode: number;
  15796. private _radius;
  15797. /**
  15798. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15799. */
  15800. /**
  15801. * sets the light radius used by PBR Materials to simulate soft area lights.
  15802. */
  15803. radius: number;
  15804. private _renderPriority;
  15805. /**
  15806. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15807. * exceeding the number allowed of the materials.
  15808. */
  15809. renderPriority: number;
  15810. private _shadowEnabled;
  15811. /**
  15812. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15813. * the current shadow generator.
  15814. */
  15815. /**
  15816. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15817. * the current shadow generator.
  15818. */
  15819. shadowEnabled: boolean;
  15820. private _includedOnlyMeshes;
  15821. /**
  15822. * Gets the only meshes impacted by this light.
  15823. */
  15824. /**
  15825. * Sets the only meshes impacted by this light.
  15826. */
  15827. includedOnlyMeshes: AbstractMesh[];
  15828. private _excludedMeshes;
  15829. /**
  15830. * Gets the meshes not impacted by this light.
  15831. */
  15832. /**
  15833. * Sets the meshes not impacted by this light.
  15834. */
  15835. excludedMeshes: AbstractMesh[];
  15836. private _excludeWithLayerMask;
  15837. /**
  15838. * Gets the layer id use to find what meshes are not impacted by the light.
  15839. * Inactive if 0
  15840. */
  15841. /**
  15842. * Sets the layer id use to find what meshes are not impacted by the light.
  15843. * Inactive if 0
  15844. */
  15845. excludeWithLayerMask: number;
  15846. private _includeOnlyWithLayerMask;
  15847. /**
  15848. * Gets the layer id use to find what meshes are impacted by the light.
  15849. * Inactive if 0
  15850. */
  15851. /**
  15852. * Sets the layer id use to find what meshes are impacted by the light.
  15853. * Inactive if 0
  15854. */
  15855. includeOnlyWithLayerMask: number;
  15856. private _lightmapMode;
  15857. /**
  15858. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15859. */
  15860. /**
  15861. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15862. */
  15863. lightmapMode: number;
  15864. /**
  15865. * Shadow generator associted to the light.
  15866. * @hidden Internal use only.
  15867. */
  15868. _shadowGenerator: Nullable<IShadowGenerator>;
  15869. /**
  15870. * @hidden Internal use only.
  15871. */
  15872. _excludedMeshesIds: string[];
  15873. /**
  15874. * @hidden Internal use only.
  15875. */
  15876. _includedOnlyMeshesIds: string[];
  15877. /**
  15878. * The current light unifom buffer.
  15879. * @hidden Internal use only.
  15880. */
  15881. _uniformBuffer: UniformBuffer;
  15882. /**
  15883. * Creates a Light object in the scene.
  15884. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15885. * @param name The firendly name of the light
  15886. * @param scene The scene the light belongs too
  15887. */
  15888. constructor(name: string, scene: Scene);
  15889. protected abstract _buildUniformLayout(): void;
  15890. /**
  15891. * Sets the passed Effect "effect" with the Light information.
  15892. * @param effect The effect to update
  15893. * @param lightIndex The index of the light in the effect to update
  15894. * @returns The light
  15895. */
  15896. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15897. /**
  15898. * Returns the string "Light".
  15899. * @returns the class name
  15900. */
  15901. getClassName(): string;
  15902. /**
  15903. * Converts the light information to a readable string for debug purpose.
  15904. * @param fullDetails Supports for multiple levels of logging within scene loading
  15905. * @returns the human readable light info
  15906. */
  15907. toString(fullDetails?: boolean): string;
  15908. /** @hidden */
  15909. protected _syncParentEnabledState(): void;
  15910. /**
  15911. * Set the enabled state of this node.
  15912. * @param value - the new enabled state
  15913. */
  15914. setEnabled(value: boolean): void;
  15915. /**
  15916. * Returns the Light associated shadow generator if any.
  15917. * @return the associated shadow generator.
  15918. */
  15919. getShadowGenerator(): Nullable<IShadowGenerator>;
  15920. /**
  15921. * Returns a Vector3, the absolute light position in the World.
  15922. * @returns the world space position of the light
  15923. */
  15924. getAbsolutePosition(): Vector3;
  15925. /**
  15926. * Specifies if the light will affect the passed mesh.
  15927. * @param mesh The mesh to test against the light
  15928. * @return true the mesh is affected otherwise, false.
  15929. */
  15930. canAffectMesh(mesh: AbstractMesh): boolean;
  15931. /**
  15932. * Sort function to order lights for rendering.
  15933. * @param a First Light object to compare to second.
  15934. * @param b Second Light object to compare first.
  15935. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15936. */
  15937. static CompareLightsPriority(a: Light, b: Light): number;
  15938. /**
  15939. * Releases resources associated with this node.
  15940. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15941. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15942. */
  15943. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15944. /**
  15945. * Returns the light type ID (integer).
  15946. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15947. */
  15948. getTypeID(): number;
  15949. /**
  15950. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  15951. * @returns the scaled intensity in intensity mode unit
  15952. */
  15953. getScaledIntensity(): number;
  15954. /**
  15955. * Returns a new Light object, named "name", from the current one.
  15956. * @param name The name of the cloned light
  15957. * @returns the new created light
  15958. */
  15959. clone(name: string): Nullable<Light>;
  15960. /**
  15961. * Serializes the current light into a Serialization object.
  15962. * @returns the serialized object.
  15963. */
  15964. serialize(): any;
  15965. /**
  15966. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  15967. * This new light is named "name" and added to the passed scene.
  15968. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  15969. * @param name The friendly name of the light
  15970. * @param scene The scene the new light will belong to
  15971. * @returns the constructor function
  15972. */
  15973. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  15974. /**
  15975. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  15976. * @param parsedLight The JSON representation of the light
  15977. * @param scene The scene to create the parsed light in
  15978. * @returns the created light after parsing
  15979. */
  15980. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  15981. private _hookArrayForExcluded;
  15982. private _hookArrayForIncludedOnly;
  15983. private _resyncMeshes;
  15984. /**
  15985. * Forces the meshes to update their light related information in their rendering used effects
  15986. * @hidden Internal Use Only
  15987. */
  15988. _markMeshesAsLightDirty(): void;
  15989. /**
  15990. * Recomputes the cached photometric scale if needed.
  15991. */
  15992. private _computePhotometricScale;
  15993. /**
  15994. * Returns the Photometric Scale according to the light type and intensity mode.
  15995. */
  15996. private _getPhotometricScale;
  15997. /**
  15998. * Reorder the light in the scene according to their defined priority.
  15999. * @hidden Internal Use Only
  16000. */
  16001. _reorderLightsInScene(): void;
  16002. /**
  16003. * Prepares the list of defines specific to the light type.
  16004. * @param defines the list of defines
  16005. * @param lightIndex defines the index of the light for the effect
  16006. */
  16007. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16008. }
  16009. }
  16010. declare module BABYLON {
  16011. /**
  16012. * A point light is a light defined by an unique point in world space.
  16013. * The light is emitted in every direction from this point.
  16014. * A good example of a point light is a standard light bulb.
  16015. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16016. */
  16017. class PointLight extends ShadowLight {
  16018. private _shadowAngle;
  16019. /**
  16020. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16021. * This specifies what angle the shadow will use to be created.
  16022. *
  16023. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  16024. */
  16025. /**
  16026. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16027. * This specifies what angle the shadow will use to be created.
  16028. *
  16029. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  16030. */
  16031. shadowAngle: number;
  16032. /**
  16033. * Gets the direction if it has been set.
  16034. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16035. */
  16036. /**
  16037. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16038. */
  16039. direction: Vector3;
  16040. /**
  16041. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  16042. * A PointLight emits the light in every direction.
  16043. * It can cast shadows.
  16044. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  16045. * ```javascript
  16046. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  16047. * ```
  16048. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16049. * @param name The light friendly name
  16050. * @param position The position of the point light in the scene
  16051. * @param scene The scene the lights belongs to
  16052. */
  16053. constructor(name: string, position: Vector3, scene: Scene);
  16054. /**
  16055. * Returns the string "PointLight"
  16056. * @returns the class name
  16057. */
  16058. getClassName(): string;
  16059. /**
  16060. * Returns the integer 0.
  16061. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16062. */
  16063. getTypeID(): number;
  16064. /**
  16065. * Specifies wether or not the shadowmap should be a cube texture.
  16066. * @returns true if the shadowmap needs to be a cube texture.
  16067. */
  16068. needCube(): boolean;
  16069. /**
  16070. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  16071. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16072. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16073. */
  16074. getShadowDirection(faceIndex?: number): Vector3;
  16075. /**
  16076. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  16077. * - fov = PI / 2
  16078. * - aspect ratio : 1.0
  16079. * - z-near and far equal to the active camera minZ and maxZ.
  16080. * Returns the PointLight.
  16081. */
  16082. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16083. protected _buildUniformLayout(): void;
  16084. /**
  16085. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  16086. * @param effect The effect to update
  16087. * @param lightIndex The index of the light in the effect to update
  16088. * @returns The point light
  16089. */
  16090. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  16091. /**
  16092. * Prepares the list of defines specific to the light type.
  16093. * @param defines the list of defines
  16094. * @param lightIndex defines the index of the light for the effect
  16095. */
  16096. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16097. }
  16098. }
  16099. declare module BABYLON {
  16100. /**
  16101. * Interface describing all the common properties and methods a shadow light needs to implement.
  16102. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  16103. * as well as binding the different shadow properties to the effects.
  16104. */
  16105. interface IShadowLight extends Light {
  16106. /**
  16107. * The light id in the scene (used in scene.findLighById for instance)
  16108. */
  16109. id: string;
  16110. /**
  16111. * The position the shdow will be casted from.
  16112. */
  16113. position: Vector3;
  16114. /**
  16115. * In 2d mode (needCube being false), the direction used to cast the shadow.
  16116. */
  16117. direction: Vector3;
  16118. /**
  16119. * The transformed position. Position of the light in world space taking parenting in account.
  16120. */
  16121. transformedPosition: Vector3;
  16122. /**
  16123. * The transformed direction. Direction of the light in world space taking parenting in account.
  16124. */
  16125. transformedDirection: Vector3;
  16126. /**
  16127. * The friendly name of the light in the scene.
  16128. */
  16129. name: string;
  16130. /**
  16131. * Defines the shadow projection clipping minimum z value.
  16132. */
  16133. shadowMinZ: number;
  16134. /**
  16135. * Defines the shadow projection clipping maximum z value.
  16136. */
  16137. shadowMaxZ: number;
  16138. /**
  16139. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16140. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16141. */
  16142. computeTransformedInformation(): boolean;
  16143. /**
  16144. * Gets the scene the light belongs to.
  16145. * @returns The scene
  16146. */
  16147. getScene(): Scene;
  16148. /**
  16149. * Callback defining a custom Projection Matrix Builder.
  16150. * This can be used to override the default projection matrix computation.
  16151. */
  16152. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16153. /**
  16154. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16155. * @param matrix The materix to updated with the projection information
  16156. * @param viewMatrix The transform matrix of the light
  16157. * @param renderList The list of mesh to render in the map
  16158. * @returns The current light
  16159. */
  16160. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16161. /**
  16162. * Gets the current depth scale used in ESM.
  16163. * @returns The scale
  16164. */
  16165. getDepthScale(): number;
  16166. /**
  16167. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16168. * @returns true if a cube texture needs to be use
  16169. */
  16170. needCube(): boolean;
  16171. /**
  16172. * Detects if the projection matrix requires to be recomputed this frame.
  16173. * @returns true if it requires to be recomputed otherwise, false.
  16174. */
  16175. needProjectionMatrixCompute(): boolean;
  16176. /**
  16177. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16178. */
  16179. forceProjectionMatrixCompute(): void;
  16180. /**
  16181. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16182. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16183. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16184. */
  16185. getShadowDirection(faceIndex?: number): Vector3;
  16186. /**
  16187. * Gets the minZ used for shadow according to both the scene and the light.
  16188. * @param activeCamera The camera we are returning the min for
  16189. * @returns the depth min z
  16190. */
  16191. getDepthMinZ(activeCamera: Camera): number;
  16192. /**
  16193. * Gets the maxZ used for shadow according to both the scene and the light.
  16194. * @param activeCamera The camera we are returning the max for
  16195. * @returns the depth max z
  16196. */
  16197. getDepthMaxZ(activeCamera: Camera): number;
  16198. }
  16199. /**
  16200. * Base implementation IShadowLight
  16201. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  16202. */
  16203. abstract class ShadowLight extends Light implements IShadowLight {
  16204. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16205. protected _position: Vector3;
  16206. protected _setPosition(value: Vector3): void;
  16207. /**
  16208. * Sets the position the shadow will be casted from. Also use as the light position for both
  16209. * point and spot lights.
  16210. */
  16211. /**
  16212. * Sets the position the shadow will be casted from. Also use as the light position for both
  16213. * point and spot lights.
  16214. */
  16215. position: Vector3;
  16216. protected _direction: Vector3;
  16217. protected _setDirection(value: Vector3): void;
  16218. /**
  16219. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  16220. * Also use as the light direction on spot and directional lights.
  16221. */
  16222. /**
  16223. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  16224. * Also use as the light direction on spot and directional lights.
  16225. */
  16226. direction: Vector3;
  16227. private _shadowMinZ;
  16228. /**
  16229. * Gets the shadow projection clipping minimum z value.
  16230. */
  16231. /**
  16232. * Sets the shadow projection clipping minimum z value.
  16233. */
  16234. shadowMinZ: number;
  16235. private _shadowMaxZ;
  16236. /**
  16237. * Sets the shadow projection clipping maximum z value.
  16238. */
  16239. /**
  16240. * Gets the shadow projection clipping maximum z value.
  16241. */
  16242. shadowMaxZ: number;
  16243. /**
  16244. * Callback defining a custom Projection Matrix Builder.
  16245. * This can be used to override the default projection matrix computation.
  16246. */
  16247. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16248. /**
  16249. * The transformed position. Position of the light in world space taking parenting in account.
  16250. */
  16251. transformedPosition: Vector3;
  16252. /**
  16253. * The transformed direction. Direction of the light in world space taking parenting in account.
  16254. */
  16255. transformedDirection: Vector3;
  16256. private _needProjectionMatrixCompute;
  16257. /**
  16258. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16259. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16260. */
  16261. computeTransformedInformation(): boolean;
  16262. /**
  16263. * Return the depth scale used for the shadow map.
  16264. * @returns the depth scale.
  16265. */
  16266. getDepthScale(): number;
  16267. /**
  16268. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16269. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16270. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16271. */
  16272. getShadowDirection(faceIndex?: number): Vector3;
  16273. /**
  16274. * Returns the ShadowLight absolute position in the World.
  16275. * @returns the position vector in world space
  16276. */
  16277. getAbsolutePosition(): Vector3;
  16278. /**
  16279. * Sets the ShadowLight direction toward the passed target.
  16280. * @param target The point tot target in local space
  16281. * @returns the updated ShadowLight direction
  16282. */
  16283. setDirectionToTarget(target: Vector3): Vector3;
  16284. /**
  16285. * Returns the light rotation in euler definition.
  16286. * @returns the x y z rotation in local space.
  16287. */
  16288. getRotation(): Vector3;
  16289. /**
  16290. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16291. * @returns true if a cube texture needs to be use
  16292. */
  16293. needCube(): boolean;
  16294. /**
  16295. * Detects if the projection matrix requires to be recomputed this frame.
  16296. * @returns true if it requires to be recomputed otherwise, false.
  16297. */
  16298. needProjectionMatrixCompute(): boolean;
  16299. /**
  16300. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16301. */
  16302. forceProjectionMatrixCompute(): void;
  16303. /** @hidden */
  16304. _initCache(): void;
  16305. /** @hidden */
  16306. _isSynchronized(): boolean;
  16307. /**
  16308. * Computes the world matrix of the node
  16309. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  16310. * @returns the world matrix
  16311. */
  16312. computeWorldMatrix(force?: boolean): Matrix;
  16313. /**
  16314. * Gets the minZ used for shadow according to both the scene and the light.
  16315. * @param activeCamera The camera we are returning the min for
  16316. * @returns the depth min z
  16317. */
  16318. getDepthMinZ(activeCamera: Camera): number;
  16319. /**
  16320. * Gets the maxZ used for shadow according to both the scene and the light.
  16321. * @param activeCamera The camera we are returning the max for
  16322. * @returns the depth max z
  16323. */
  16324. getDepthMaxZ(activeCamera: Camera): number;
  16325. /**
  16326. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16327. * @param matrix The materix to updated with the projection information
  16328. * @param viewMatrix The transform matrix of the light
  16329. * @param renderList The list of mesh to render in the map
  16330. * @returns The current light
  16331. */
  16332. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16333. }
  16334. }
  16335. declare module BABYLON {
  16336. /**
  16337. * A spot light is defined by a position, a direction, an angle, and an exponent.
  16338. * These values define a cone of light starting from the position, emitting toward the direction.
  16339. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  16340. * and the exponent defines the speed of the decay of the light with distance (reach).
  16341. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16342. */
  16343. class SpotLight extends ShadowLight {
  16344. private _angle;
  16345. private _innerAngle;
  16346. private _cosHalfAngle;
  16347. private _lightAngleScale;
  16348. private _lightAngleOffset;
  16349. /**
  16350. * Gets the cone angle of the spot light in Radians.
  16351. */
  16352. /**
  16353. * Sets the cone angle of the spot light in Radians.
  16354. */
  16355. angle: number;
  16356. /**
  16357. * Only used in gltf falloff mode, this defines the angle where
  16358. * the directional falloff will start before cutting at angle which could be seen
  16359. * as outer angle.
  16360. */
  16361. /**
  16362. * Only used in gltf falloff mode, this defines the angle where
  16363. * the directional falloff will start before cutting at angle which could be seen
  16364. * as outer angle.
  16365. */
  16366. innerAngle: number;
  16367. private _shadowAngleScale;
  16368. /**
  16369. * Allows scaling the angle of the light for shadow generation only.
  16370. */
  16371. /**
  16372. * Allows scaling the angle of the light for shadow generation only.
  16373. */
  16374. shadowAngleScale: number;
  16375. /**
  16376. * The light decay speed with the distance from the emission spot.
  16377. */
  16378. exponent: number;
  16379. private _projectionTextureMatrix;
  16380. /**
  16381. * Allows reading the projecton texture
  16382. */
  16383. readonly projectionTextureMatrix: Matrix;
  16384. protected _projectionTextureLightNear: number;
  16385. /**
  16386. * Gets the near clip of the Spotlight for texture projection.
  16387. */
  16388. /**
  16389. * Sets the near clip of the Spotlight for texture projection.
  16390. */
  16391. projectionTextureLightNear: number;
  16392. protected _projectionTextureLightFar: number;
  16393. /**
  16394. * Gets the far clip of the Spotlight for texture projection.
  16395. */
  16396. /**
  16397. * Sets the far clip of the Spotlight for texture projection.
  16398. */
  16399. projectionTextureLightFar: number;
  16400. protected _projectionTextureUpDirection: Vector3;
  16401. /**
  16402. * Gets the Up vector of the Spotlight for texture projection.
  16403. */
  16404. /**
  16405. * Sets the Up vector of the Spotlight for texture projection.
  16406. */
  16407. projectionTextureUpDirection: Vector3;
  16408. private _projectionTexture;
  16409. /**
  16410. * Gets the projection texture of the light.
  16411. */
  16412. /**
  16413. * Sets the projection texture of the light.
  16414. */
  16415. projectionTexture: Nullable<BaseTexture>;
  16416. private _projectionTextureViewLightDirty;
  16417. private _projectionTextureProjectionLightDirty;
  16418. private _projectionTextureDirty;
  16419. private _projectionTextureViewTargetVector;
  16420. private _projectionTextureViewLightMatrix;
  16421. private _projectionTextureProjectionLightMatrix;
  16422. private _projectionTextureScalingMatrix;
  16423. /**
  16424. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  16425. * It can cast shadows.
  16426. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16427. * @param name The light friendly name
  16428. * @param position The position of the spot light in the scene
  16429. * @param direction The direction of the light in the scene
  16430. * @param angle The cone angle of the light in Radians
  16431. * @param exponent The light decay speed with the distance from the emission spot
  16432. * @param scene The scene the lights belongs to
  16433. */
  16434. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  16435. /**
  16436. * Returns the string "SpotLight".
  16437. * @returns the class name
  16438. */
  16439. getClassName(): string;
  16440. /**
  16441. * Returns the integer 2.
  16442. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16443. */
  16444. getTypeID(): number;
  16445. /**
  16446. * Overrides the direction setter to recompute the projection texture view light Matrix.
  16447. */
  16448. protected _setDirection(value: Vector3): void;
  16449. /**
  16450. * Overrides the position setter to recompute the projection texture view light Matrix.
  16451. */
  16452. protected _setPosition(value: Vector3): void;
  16453. /**
  16454. * 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.
  16455. * Returns the SpotLight.
  16456. */
  16457. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16458. protected _computeProjectionTextureViewLightMatrix(): void;
  16459. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16460. /**
  16461. * Main function for light texture projection matrix computing.
  16462. */
  16463. protected _computeProjectionTextureMatrix(): void;
  16464. protected _buildUniformLayout(): void;
  16465. private _computeAngleValues;
  16466. /**
  16467. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16468. * @param effect The effect to update
  16469. * @param lightIndex The index of the light in the effect to update
  16470. * @returns The spot light
  16471. */
  16472. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16473. /**
  16474. * Disposes the light and the associated resources.
  16475. */
  16476. dispose(): void;
  16477. /**
  16478. * Prepares the list of defines specific to the light type.
  16479. * @param defines the list of defines
  16480. * @param lightIndex defines the index of the light for the effect
  16481. */
  16482. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16483. }
  16484. }
  16485. declare module BABYLON {
  16486. /**
  16487. * Interface used to present a loading screen while loading a scene
  16488. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16489. */
  16490. interface ILoadingScreen {
  16491. /**
  16492. * Function called to display the loading screen
  16493. */
  16494. displayLoadingUI: () => void;
  16495. /**
  16496. * Function called to hide the loading screen
  16497. */
  16498. hideLoadingUI: () => void;
  16499. /**
  16500. * Gets or sets the color to use for the background
  16501. */
  16502. loadingUIBackgroundColor: string;
  16503. /**
  16504. * Gets or sets the text to display while loading
  16505. */
  16506. loadingUIText: string;
  16507. }
  16508. /**
  16509. * Class used for the default loading screen
  16510. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16511. */
  16512. class DefaultLoadingScreen implements ILoadingScreen {
  16513. private _renderingCanvas;
  16514. private _loadingText;
  16515. private _loadingDivBackgroundColor;
  16516. private _loadingDiv;
  16517. private _loadingTextDiv;
  16518. /**
  16519. * Creates a new default loading screen
  16520. * @param _renderingCanvas defines the canvas used to render the scene
  16521. * @param _loadingText defines the default text to display
  16522. * @param _loadingDivBackgroundColor defines the default background color
  16523. */
  16524. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  16525. /**
  16526. * Function called to display the loading screen
  16527. */
  16528. displayLoadingUI(): void;
  16529. /**
  16530. * Function called to hide the loading screen
  16531. */
  16532. hideLoadingUI(): void;
  16533. /**
  16534. * Gets or sets the text to display while loading
  16535. */
  16536. loadingUIText: string;
  16537. /**
  16538. * Gets or sets the color to use for the background
  16539. */
  16540. loadingUIBackgroundColor: string;
  16541. private _resizeLoadingUI;
  16542. }
  16543. }
  16544. declare module BABYLON {
  16545. /**
  16546. * Class used to represent data loading progression
  16547. */
  16548. class SceneLoaderProgressEvent {
  16549. /** defines if data length to load can be evaluated */
  16550. readonly lengthComputable: boolean;
  16551. /** defines the loaded data length */
  16552. readonly loaded: number;
  16553. /** defines the data length to load */
  16554. readonly total: number;
  16555. /**
  16556. * Create a new progress event
  16557. * @param lengthComputable defines if data length to load can be evaluated
  16558. * @param loaded defines the loaded data length
  16559. * @param total defines the data length to load
  16560. */
  16561. constructor(
  16562. /** defines if data length to load can be evaluated */
  16563. lengthComputable: boolean,
  16564. /** defines the loaded data length */
  16565. loaded: number,
  16566. /** defines the data length to load */
  16567. total: number);
  16568. /**
  16569. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16570. * @param event defines the source event
  16571. * @returns a new SceneLoaderProgressEvent
  16572. */
  16573. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16574. }
  16575. /**
  16576. * Interface used by SceneLoader plugins to define supported file extensions
  16577. */
  16578. interface ISceneLoaderPluginExtensions {
  16579. /**
  16580. * Defines the list of supported extensions
  16581. */
  16582. [extension: string]: {
  16583. isBinary: boolean;
  16584. };
  16585. }
  16586. /**
  16587. * Interface used by SceneLoader plugin factory
  16588. */
  16589. interface ISceneLoaderPluginFactory {
  16590. /**
  16591. * Defines the name of the factory
  16592. */
  16593. name: string;
  16594. /**
  16595. * Function called to create a new plugin
  16596. * @return the new plugin
  16597. */
  16598. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16599. /**
  16600. * Boolean indicating if the plugin can direct load specific data
  16601. */
  16602. canDirectLoad?: (data: string) => boolean;
  16603. }
  16604. /**
  16605. * Interface used to define a SceneLoader plugin
  16606. */
  16607. interface ISceneLoaderPlugin {
  16608. /**
  16609. * The friendly name of this plugin.
  16610. */
  16611. name: string;
  16612. /**
  16613. * The file extensions supported by this plugin.
  16614. */
  16615. extensions: string | ISceneLoaderPluginExtensions;
  16616. /**
  16617. * Import meshes into a scene.
  16618. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16619. * @param scene The scene to import into
  16620. * @param data The data to import
  16621. * @param rootUrl The root url for scene and resources
  16622. * @param meshes The meshes array to import into
  16623. * @param particleSystems The particle systems array to import into
  16624. * @param skeletons The skeletons array to import into
  16625. * @param onError The callback when import fails
  16626. * @returns True if successful or false otherwise
  16627. */
  16628. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16629. /**
  16630. * Load into a scene.
  16631. * @param scene The scene to load into
  16632. * @param data The data to import
  16633. * @param rootUrl The root url for scene and resources
  16634. * @param onError The callback when import fails
  16635. * @returns true if successful or false otherwise
  16636. */
  16637. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16638. /**
  16639. * The callback that returns true if the data can be directly loaded.
  16640. */
  16641. canDirectLoad?: (data: string) => boolean;
  16642. /**
  16643. * The callback that allows custom handling of the root url based on the response url.
  16644. */
  16645. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16646. /**
  16647. * Load into an asset container.
  16648. * @param scene The scene to load into
  16649. * @param data The data to import
  16650. * @param rootUrl The root url for scene and resources
  16651. * @param onError The callback when import fails
  16652. * @returns The loaded asset container
  16653. */
  16654. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16655. }
  16656. /**
  16657. * Interface used to define an async SceneLoader plugin
  16658. */
  16659. interface ISceneLoaderPluginAsync {
  16660. /**
  16661. * The friendly name of this plugin.
  16662. */
  16663. name: string;
  16664. /**
  16665. * The file extensions supported by this plugin.
  16666. */
  16667. extensions: string | ISceneLoaderPluginExtensions;
  16668. /**
  16669. * Import meshes into a scene.
  16670. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16671. * @param scene The scene to import into
  16672. * @param data The data to import
  16673. * @param rootUrl The root url for scene and resources
  16674. * @param onProgress The callback when the load progresses
  16675. * @param fileName Defines the name of the file to load
  16676. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16677. */
  16678. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16679. meshes: AbstractMesh[];
  16680. particleSystems: IParticleSystem[];
  16681. skeletons: Skeleton[];
  16682. animationGroups: AnimationGroup[];
  16683. }>;
  16684. /**
  16685. * Load into a scene.
  16686. * @param scene The scene to load into
  16687. * @param data The data to import
  16688. * @param rootUrl The root url for scene and resources
  16689. * @param onProgress The callback when the load progresses
  16690. * @param fileName Defines the name of the file to load
  16691. * @returns Nothing
  16692. */
  16693. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16694. /**
  16695. * The callback that returns true if the data can be directly loaded.
  16696. */
  16697. canDirectLoad?: (data: string) => boolean;
  16698. /**
  16699. * The callback that allows custom handling of the root url based on the response url.
  16700. */
  16701. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16702. /**
  16703. * Load into an asset container.
  16704. * @param scene The scene to load into
  16705. * @param data The data to import
  16706. * @param rootUrl The root url for scene and resources
  16707. * @param onProgress The callback when the load progresses
  16708. * @param fileName Defines the name of the file to load
  16709. * @returns The loaded asset container
  16710. */
  16711. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16712. }
  16713. /**
  16714. * Class used to load scene from various file formats using registered plugins
  16715. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16716. */
  16717. class SceneLoader {
  16718. private static _ForceFullSceneLoadingForIncremental;
  16719. private static _ShowLoadingScreen;
  16720. private static _CleanBoneMatrixWeights;
  16721. /**
  16722. * No logging while loading
  16723. */
  16724. static readonly NO_LOGGING: number;
  16725. /**
  16726. * Minimal logging while loading
  16727. */
  16728. static readonly MINIMAL_LOGGING: number;
  16729. /**
  16730. * Summary logging while loading
  16731. */
  16732. static readonly SUMMARY_LOGGING: number;
  16733. /**
  16734. * Detailled logging while loading
  16735. */
  16736. static readonly DETAILED_LOGGING: number;
  16737. private static _loggingLevel;
  16738. /**
  16739. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16740. */
  16741. static ForceFullSceneLoadingForIncremental: boolean;
  16742. /**
  16743. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16744. */
  16745. static ShowLoadingScreen: boolean;
  16746. /**
  16747. * Defines the current logging level (while loading the scene)
  16748. * @ignorenaming
  16749. */
  16750. static loggingLevel: number;
  16751. /**
  16752. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16753. */
  16754. static CleanBoneMatrixWeights: boolean;
  16755. /**
  16756. * Event raised when a plugin is used to load a scene
  16757. */
  16758. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16759. private static _registeredPlugins;
  16760. private static _getDefaultPlugin;
  16761. private static _getPluginForExtension;
  16762. private static _getPluginForDirectLoad;
  16763. private static _getPluginForFilename;
  16764. private static _getDirectLoad;
  16765. private static _loadData;
  16766. private static _getFileInfo;
  16767. /**
  16768. * Gets a plugin that can load the given extension
  16769. * @param extension defines the extension to load
  16770. * @returns a plugin or null if none works
  16771. */
  16772. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16773. /**
  16774. * Gets a boolean indicating that the given extension can be loaded
  16775. * @param extension defines the extension to load
  16776. * @returns true if the extension is supported
  16777. */
  16778. static IsPluginForExtensionAvailable(extension: string): boolean;
  16779. /**
  16780. * Adds a new plugin to the list of registered plugins
  16781. * @param plugin defines the plugin to add
  16782. */
  16783. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16784. /**
  16785. * Import meshes into a scene
  16786. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  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 or a File object (default: empty string)
  16789. * @param scene the instance of BABYLON.Scene to append to
  16790. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons 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 ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16797. /**
  16798. * Import meshes into a scene
  16799. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16800. * @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)
  16801. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16802. * @param scene the instance of BABYLON.Scene to append to
  16803. * @param onProgress a callback with a progress event for each file being loaded
  16804. * @param pluginExtension the extension used to determine the plugin
  16805. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16806. */
  16807. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16808. meshes: AbstractMesh[];
  16809. particleSystems: IParticleSystem[];
  16810. skeletons: Skeleton[];
  16811. animationGroups: AnimationGroup[];
  16812. }>;
  16813. /**
  16814. * Load a scene
  16815. * @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)
  16816. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16817. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16818. * @param onSuccess a callback with the scene when import succeeds
  16819. * @param onProgress a callback with a progress event for each file being loaded
  16820. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16821. * @param pluginExtension the extension used to determine the plugin
  16822. * @returns The loaded plugin
  16823. */
  16824. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16825. /**
  16826. * Load a scene
  16827. * @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)
  16828. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16829. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16830. * @param onProgress a callback with a progress event for each file being loaded
  16831. * @param pluginExtension the extension used to determine the plugin
  16832. * @returns The loaded scene
  16833. */
  16834. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16835. /**
  16836. * Append a scene
  16837. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  16838. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16839. * @param scene is the instance of BABYLON.Scene to append to
  16840. * @param onSuccess a callback with the scene when import succeeds
  16841. * @param onProgress a callback with a progress event for each file being loaded
  16842. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16843. * @param pluginExtension the extension used to determine the plugin
  16844. * @returns The loaded plugin
  16845. */
  16846. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16847. /**
  16848. * Append a scene
  16849. * @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)
  16850. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16851. * @param scene is the instance of BABYLON.Scene to append to
  16852. * @param onProgress a callback with a progress event for each file being loaded
  16853. * @param pluginExtension the extension used to determine the plugin
  16854. * @returns The given scene
  16855. */
  16856. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16857. /**
  16858. * Load a scene into an asset container
  16859. * @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)
  16860. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16861. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16862. * @param onSuccess a callback with the scene when import succeeds
  16863. * @param onProgress a callback with a progress event for each file being loaded
  16864. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16865. * @param pluginExtension the extension used to determine the plugin
  16866. * @returns The loaded plugin
  16867. */
  16868. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16869. /**
  16870. * Load a scene into an asset container
  16871. * @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)
  16872. * @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)
  16873. * @param scene is the instance of BABYLON.Scene to append to
  16874. * @param onProgress a callback with a progress event for each file being loaded
  16875. * @param pluginExtension the extension used to determine the plugin
  16876. * @returns The loaded asset container
  16877. */
  16878. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16879. }
  16880. }
  16881. declare module BABYLON {
  16882. /**
  16883. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  16884. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  16885. * 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;
  16886. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  16887. */
  16888. class ColorCurves {
  16889. private _dirty;
  16890. private _tempColor;
  16891. private _globalCurve;
  16892. private _highlightsCurve;
  16893. private _midtonesCurve;
  16894. private _shadowsCurve;
  16895. private _positiveCurve;
  16896. private _negativeCurve;
  16897. private _globalHue;
  16898. private _globalDensity;
  16899. private _globalSaturation;
  16900. private _globalExposure;
  16901. /**
  16902. * Gets the global Hue value.
  16903. * 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).
  16904. */
  16905. /**
  16906. * Sets the global Hue value.
  16907. * 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).
  16908. */
  16909. globalHue: number;
  16910. /**
  16911. * Gets the global Density value.
  16912. * 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.
  16913. * Values less than zero provide a filter of opposite hue.
  16914. */
  16915. /**
  16916. * Sets the global Density value.
  16917. * 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.
  16918. * Values less than zero provide a filter of opposite hue.
  16919. */
  16920. globalDensity: number;
  16921. /**
  16922. * Gets the global Saturation value.
  16923. * 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.
  16924. */
  16925. /**
  16926. * Sets the global Saturation value.
  16927. * 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.
  16928. */
  16929. globalSaturation: number;
  16930. /**
  16931. * Gets the global Exposure value.
  16932. * 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.
  16933. */
  16934. /**
  16935. * Sets the global Exposure value.
  16936. * 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.
  16937. */
  16938. globalExposure: number;
  16939. private _highlightsHue;
  16940. private _highlightsDensity;
  16941. private _highlightsSaturation;
  16942. private _highlightsExposure;
  16943. /**
  16944. * Gets the highlights Hue value.
  16945. * 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).
  16946. */
  16947. /**
  16948. * Sets the highlights Hue value.
  16949. * 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).
  16950. */
  16951. highlightsHue: number;
  16952. /**
  16953. * Gets the highlights Density value.
  16954. * 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.
  16955. * Values less than zero provide a filter of opposite hue.
  16956. */
  16957. /**
  16958. * Sets the highlights Density value.
  16959. * 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.
  16960. * Values less than zero provide a filter of opposite hue.
  16961. */
  16962. highlightsDensity: number;
  16963. /**
  16964. * Gets the highlights Saturation value.
  16965. * 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.
  16966. */
  16967. /**
  16968. * Sets the highlights Saturation value.
  16969. * 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.
  16970. */
  16971. highlightsSaturation: number;
  16972. /**
  16973. * Gets the highlights Exposure value.
  16974. * 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.
  16975. */
  16976. /**
  16977. * Sets the highlights Exposure value.
  16978. * 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.
  16979. */
  16980. highlightsExposure: number;
  16981. private _midtonesHue;
  16982. private _midtonesDensity;
  16983. private _midtonesSaturation;
  16984. private _midtonesExposure;
  16985. /**
  16986. * Gets the midtones Hue value.
  16987. * 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).
  16988. */
  16989. /**
  16990. * Sets the midtones Hue value.
  16991. * 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).
  16992. */
  16993. midtonesHue: number;
  16994. /**
  16995. * Gets the midtones Density value.
  16996. * 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.
  16997. * Values less than zero provide a filter of opposite hue.
  16998. */
  16999. /**
  17000. * Sets the midtones Density value.
  17001. * 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.
  17002. * Values less than zero provide a filter of opposite hue.
  17003. */
  17004. midtonesDensity: number;
  17005. /**
  17006. * Gets the midtones Saturation value.
  17007. * 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.
  17008. */
  17009. /**
  17010. * Sets the midtones Saturation value.
  17011. * 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.
  17012. */
  17013. midtonesSaturation: number;
  17014. /**
  17015. * Gets the midtones Exposure value.
  17016. * 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.
  17017. */
  17018. /**
  17019. * Sets the midtones Exposure value.
  17020. * 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.
  17021. */
  17022. midtonesExposure: number;
  17023. private _shadowsHue;
  17024. private _shadowsDensity;
  17025. private _shadowsSaturation;
  17026. private _shadowsExposure;
  17027. /**
  17028. * Gets the shadows Hue value.
  17029. * 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).
  17030. */
  17031. /**
  17032. * Sets the shadows Hue value.
  17033. * 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).
  17034. */
  17035. shadowsHue: number;
  17036. /**
  17037. * Gets the shadows Density value.
  17038. * 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.
  17039. * Values less than zero provide a filter of opposite hue.
  17040. */
  17041. /**
  17042. * Sets the shadows Density value.
  17043. * 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.
  17044. * Values less than zero provide a filter of opposite hue.
  17045. */
  17046. shadowsDensity: number;
  17047. /**
  17048. * Gets the shadows Saturation value.
  17049. * 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.
  17050. */
  17051. /**
  17052. * Sets the shadows Saturation value.
  17053. * 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.
  17054. */
  17055. shadowsSaturation: number;
  17056. /**
  17057. * Gets the shadows Exposure value.
  17058. * 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.
  17059. */
  17060. /**
  17061. * Sets the shadows Exposure value.
  17062. * 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.
  17063. */
  17064. shadowsExposure: number;
  17065. /**
  17066. * Returns the class name
  17067. * @returns The class name
  17068. */
  17069. getClassName(): string;
  17070. /**
  17071. * Binds the color curves to the shader.
  17072. * @param colorCurves The color curve to bind
  17073. * @param effect The effect to bind to
  17074. * @param positiveUniform The positive uniform shader parameter
  17075. * @param neutralUniform The neutral uniform shader parameter
  17076. * @param negativeUniform The negative uniform shader parameter
  17077. */
  17078. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  17079. /**
  17080. * Prepare the list of uniforms associated with the ColorCurves effects.
  17081. * @param uniformsList The list of uniforms used in the effect
  17082. */
  17083. static PrepareUniforms(uniformsList: string[]): void;
  17084. /**
  17085. * Returns color grading data based on a hue, density, saturation and exposure value.
  17086. * @param filterHue The hue of the color filter.
  17087. * @param filterDensity The density of the color filter.
  17088. * @param saturation The saturation.
  17089. * @param exposure The exposure.
  17090. * @param result The result data container.
  17091. */
  17092. private getColorGradingDataToRef;
  17093. /**
  17094. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  17095. * @param value The input slider value in range [-100,100].
  17096. * @returns Adjusted value.
  17097. */
  17098. private static applyColorGradingSliderNonlinear;
  17099. /**
  17100. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  17101. * @param hue The hue (H) input.
  17102. * @param saturation The saturation (S) input.
  17103. * @param brightness The brightness (B) input.
  17104. * @result An RGBA color represented as Vector4.
  17105. */
  17106. private static fromHSBToRef;
  17107. /**
  17108. * Returns a value clamped between min and max
  17109. * @param value The value to clamp
  17110. * @param min The minimum of value
  17111. * @param max The maximum of value
  17112. * @returns The clamped value.
  17113. */
  17114. private static clamp;
  17115. /**
  17116. * Clones the current color curve instance.
  17117. * @return The cloned curves
  17118. */
  17119. clone(): ColorCurves;
  17120. /**
  17121. * Serializes the current color curve instance to a json representation.
  17122. * @return a JSON representation
  17123. */
  17124. serialize(): any;
  17125. /**
  17126. * Parses the color curve from a json representation.
  17127. * @param source the JSON source to parse
  17128. * @return The parsed curves
  17129. */
  17130. static Parse(source: any): ColorCurves;
  17131. }
  17132. }
  17133. declare module BABYLON {
  17134. /**
  17135. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  17136. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  17137. */
  17138. class EffectFallbacks {
  17139. private _defines;
  17140. private _currentRank;
  17141. private _maxRank;
  17142. private _mesh;
  17143. /**
  17144. * Removes the fallback from the bound mesh.
  17145. */
  17146. unBindMesh(): void;
  17147. /**
  17148. * Adds a fallback on the specified property.
  17149. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17150. * @param define The name of the define in the shader
  17151. */
  17152. addFallback(rank: number, define: string): void;
  17153. /**
  17154. * Sets the mesh to use CPU skinning when needing to fallback.
  17155. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17156. * @param mesh The mesh to use the fallbacks.
  17157. */
  17158. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  17159. /**
  17160. * Checks to see if more fallbacks are still availible.
  17161. */
  17162. readonly isMoreFallbacks: boolean;
  17163. /**
  17164. * Removes the defines that shoould be removed when falling back.
  17165. * @param currentDefines defines the current define statements for the shader.
  17166. * @param effect defines the current effect we try to compile
  17167. * @returns The resulting defines with defines of the current rank removed.
  17168. */
  17169. reduce(currentDefines: string, effect: Effect): string;
  17170. }
  17171. /**
  17172. * Options to be used when creating an effect.
  17173. */
  17174. class EffectCreationOptions {
  17175. /**
  17176. * Atrributes that will be used in the shader.
  17177. */
  17178. attributes: string[];
  17179. /**
  17180. * Uniform varible names that will be set in the shader.
  17181. */
  17182. uniformsNames: string[];
  17183. /**
  17184. * Uniform buffer varible names that will be set in the shader.
  17185. */
  17186. uniformBuffersNames: string[];
  17187. /**
  17188. * Sampler texture variable names that will be set in the shader.
  17189. */
  17190. samplers: string[];
  17191. /**
  17192. * Define statements that will be set in the shader.
  17193. */
  17194. defines: any;
  17195. /**
  17196. * Possible fallbacks for this effect to improve performance when needed.
  17197. */
  17198. fallbacks: Nullable<EffectFallbacks>;
  17199. /**
  17200. * Callback that will be called when the shader is compiled.
  17201. */
  17202. onCompiled: Nullable<(effect: Effect) => void>;
  17203. /**
  17204. * Callback that will be called if an error occurs during shader compilation.
  17205. */
  17206. onError: Nullable<(effect: Effect, errors: string) => void>;
  17207. /**
  17208. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17209. */
  17210. indexParameters: any;
  17211. /**
  17212. * Max number of lights that can be used in the shader.
  17213. */
  17214. maxSimultaneousLights: number;
  17215. /**
  17216. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  17217. */
  17218. transformFeedbackVaryings: Nullable<string[]>;
  17219. }
  17220. /**
  17221. * Effect containing vertex and fragment shader that can be executed on an object.
  17222. */
  17223. class Effect {
  17224. /**
  17225. * Name of the effect.
  17226. */
  17227. name: any;
  17228. /**
  17229. * String container all the define statements that should be set on the shader.
  17230. */
  17231. defines: string;
  17232. /**
  17233. * Callback that will be called when the shader is compiled.
  17234. */
  17235. onCompiled: Nullable<(effect: Effect) => void>;
  17236. /**
  17237. * Callback that will be called if an error occurs during shader compilation.
  17238. */
  17239. onError: Nullable<(effect: Effect, errors: string) => void>;
  17240. /**
  17241. * Callback that will be called when effect is bound.
  17242. */
  17243. onBind: Nullable<(effect: Effect) => void>;
  17244. /**
  17245. * Unique ID of the effect.
  17246. */
  17247. uniqueId: number;
  17248. /**
  17249. * Observable that will be called when the shader is compiled.
  17250. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  17251. */
  17252. onCompileObservable: Observable<Effect>;
  17253. /**
  17254. * Observable that will be called if an error occurs during shader compilation.
  17255. */
  17256. onErrorObservable: Observable<Effect>;
  17257. /** @hidden */
  17258. _onBindObservable: Nullable<Observable<Effect>>;
  17259. /**
  17260. * Observable that will be called when effect is bound.
  17261. */
  17262. readonly onBindObservable: Observable<Effect>;
  17263. /** @hidden */
  17264. _bonesComputationForcedToCPU: boolean;
  17265. private static _uniqueIdSeed;
  17266. private _engine;
  17267. private _uniformBuffersNames;
  17268. private _uniformsNames;
  17269. private _samplers;
  17270. private _isReady;
  17271. private _compilationError;
  17272. private _attributesNames;
  17273. private _attributes;
  17274. private _uniforms;
  17275. /**
  17276. * Key for the effect.
  17277. * @hidden
  17278. */
  17279. _key: string;
  17280. private _indexParameters;
  17281. private _fallbacks;
  17282. private _vertexSourceCode;
  17283. private _fragmentSourceCode;
  17284. private _vertexSourceCodeOverride;
  17285. private _fragmentSourceCodeOverride;
  17286. private _transformFeedbackVaryings;
  17287. /**
  17288. * Compiled shader to webGL program.
  17289. * @hidden
  17290. */
  17291. _program: WebGLProgram;
  17292. private _valueCache;
  17293. private static _baseCache;
  17294. /**
  17295. * Instantiates an effect.
  17296. * An effect can be used to create/manage/execute vertex and fragment shaders.
  17297. * @param baseName Name of the effect.
  17298. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  17299. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  17300. * @param samplers List of sampler variables that will be passed to the shader.
  17301. * @param engine Engine to be used to render the effect
  17302. * @param defines Define statements to be added to the shader.
  17303. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  17304. * @param onCompiled Callback that will be called when the shader is compiled.
  17305. * @param onError Callback that will be called if an error occurs during shader compilation.
  17306. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17307. */
  17308. 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);
  17309. /**
  17310. * Unique key for this effect
  17311. */
  17312. readonly key: string;
  17313. /**
  17314. * If the effect has been compiled and prepared.
  17315. * @returns if the effect is compiled and prepared.
  17316. */
  17317. isReady(): boolean;
  17318. /**
  17319. * The engine the effect was initialized with.
  17320. * @returns the engine.
  17321. */
  17322. getEngine(): Engine;
  17323. /**
  17324. * The compiled webGL program for the effect
  17325. * @returns the webGL program.
  17326. */
  17327. getProgram(): WebGLProgram;
  17328. /**
  17329. * The set of names of attribute variables for the shader.
  17330. * @returns An array of attribute names.
  17331. */
  17332. getAttributesNames(): string[];
  17333. /**
  17334. * Returns the attribute at the given index.
  17335. * @param index The index of the attribute.
  17336. * @returns The location of the attribute.
  17337. */
  17338. getAttributeLocation(index: number): number;
  17339. /**
  17340. * Returns the attribute based on the name of the variable.
  17341. * @param name of the attribute to look up.
  17342. * @returns the attribute location.
  17343. */
  17344. getAttributeLocationByName(name: string): number;
  17345. /**
  17346. * The number of attributes.
  17347. * @returns the numnber of attributes.
  17348. */
  17349. getAttributesCount(): number;
  17350. /**
  17351. * Gets the index of a uniform variable.
  17352. * @param uniformName of the uniform to look up.
  17353. * @returns the index.
  17354. */
  17355. getUniformIndex(uniformName: string): number;
  17356. /**
  17357. * Returns the attribute based on the name of the variable.
  17358. * @param uniformName of the uniform to look up.
  17359. * @returns the location of the uniform.
  17360. */
  17361. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  17362. /**
  17363. * Returns an array of sampler variable names
  17364. * @returns The array of sampler variable neames.
  17365. */
  17366. getSamplers(): string[];
  17367. /**
  17368. * The error from the last compilation.
  17369. * @returns the error string.
  17370. */
  17371. getCompilationError(): string;
  17372. /**
  17373. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  17374. * @param func The callback to be used.
  17375. */
  17376. executeWhenCompiled(func: (effect: Effect) => void): void;
  17377. private _checkIsReady;
  17378. /** @hidden */
  17379. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  17380. /** @hidden */
  17381. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  17382. /** @hidden */
  17383. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  17384. private _processShaderConversion;
  17385. private _processIncludes;
  17386. private _processPrecision;
  17387. /**
  17388. * Recompiles the webGL program
  17389. * @param vertexSourceCode The source code for the vertex shader.
  17390. * @param fragmentSourceCode The source code for the fragment shader.
  17391. * @param onCompiled Callback called when completed.
  17392. * @param onError Callback called on error.
  17393. * @hidden
  17394. */
  17395. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  17396. /**
  17397. * Gets the uniform locations of the the specified variable names
  17398. * @param names THe names of the variables to lookup.
  17399. * @returns Array of locations in the same order as variable names.
  17400. */
  17401. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  17402. /**
  17403. * Prepares the effect
  17404. * @hidden
  17405. */
  17406. _prepareEffect(): void;
  17407. /**
  17408. * Checks if the effect is supported. (Must be called after compilation)
  17409. */
  17410. readonly isSupported: boolean;
  17411. /**
  17412. * Binds a texture to the engine to be used as output of the shader.
  17413. * @param channel Name of the output variable.
  17414. * @param texture Texture to bind.
  17415. * @hidden
  17416. */
  17417. _bindTexture(channel: string, texture: InternalTexture): void;
  17418. /**
  17419. * Sets a texture on the engine to be used in the shader.
  17420. * @param channel Name of the sampler variable.
  17421. * @param texture Texture to set.
  17422. */
  17423. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  17424. /**
  17425. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  17426. * @param channel Name of the sampler variable.
  17427. * @param texture Texture to set.
  17428. */
  17429. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  17430. /**
  17431. * Sets an array of textures on the engine to be used in the shader.
  17432. * @param channel Name of the variable.
  17433. * @param textures Textures to set.
  17434. */
  17435. setTextureArray(channel: string, textures: BaseTexture[]): void;
  17436. /**
  17437. * 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)
  17438. * @param channel Name of the sampler variable.
  17439. * @param postProcess Post process to get the input texture from.
  17440. */
  17441. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  17442. /**
  17443. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  17444. * 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)
  17445. * @param channel Name of the sampler variable.
  17446. * @param postProcess Post process to get the output texture from.
  17447. */
  17448. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  17449. /** @hidden */
  17450. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  17451. /** @hidden */
  17452. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  17453. /** @hidden */
  17454. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  17455. /** @hidden */
  17456. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  17457. /**
  17458. * Binds a buffer to a uniform.
  17459. * @param buffer Buffer to bind.
  17460. * @param name Name of the uniform variable to bind to.
  17461. */
  17462. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  17463. /**
  17464. * Binds block to a uniform.
  17465. * @param blockName Name of the block to bind.
  17466. * @param index Index to bind.
  17467. */
  17468. bindUniformBlock(blockName: string, index: number): void;
  17469. /**
  17470. * Sets an interger value on a uniform variable.
  17471. * @param uniformName Name of the variable.
  17472. * @param value Value to be set.
  17473. * @returns this effect.
  17474. */
  17475. setInt(uniformName: string, value: number): Effect;
  17476. /**
  17477. * Sets an int array on a uniform variable.
  17478. * @param uniformName Name of the variable.
  17479. * @param array array to be set.
  17480. * @returns this effect.
  17481. */
  17482. setIntArray(uniformName: string, array: Int32Array): Effect;
  17483. /**
  17484. * 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)
  17485. * @param uniformName Name of the variable.
  17486. * @param array array to be set.
  17487. * @returns this effect.
  17488. */
  17489. setIntArray2(uniformName: string, array: Int32Array): Effect;
  17490. /**
  17491. * 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)
  17492. * @param uniformName Name of the variable.
  17493. * @param array array to be set.
  17494. * @returns this effect.
  17495. */
  17496. setIntArray3(uniformName: string, array: Int32Array): Effect;
  17497. /**
  17498. * 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)
  17499. * @param uniformName Name of the variable.
  17500. * @param array array to be set.
  17501. * @returns this effect.
  17502. */
  17503. setIntArray4(uniformName: string, array: Int32Array): Effect;
  17504. /**
  17505. * Sets an float array on a uniform variable.
  17506. * @param uniformName Name of the variable.
  17507. * @param array array to be set.
  17508. * @returns this effect.
  17509. */
  17510. setFloatArray(uniformName: string, array: Float32Array): Effect;
  17511. /**
  17512. * 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)
  17513. * @param uniformName Name of the variable.
  17514. * @param array array to be set.
  17515. * @returns this effect.
  17516. */
  17517. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  17518. /**
  17519. * 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)
  17520. * @param uniformName Name of the variable.
  17521. * @param array array to be set.
  17522. * @returns this effect.
  17523. */
  17524. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  17525. /**
  17526. * 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)
  17527. * @param uniformName Name of the variable.
  17528. * @param array array to be set.
  17529. * @returns this effect.
  17530. */
  17531. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  17532. /**
  17533. * Sets an array on a uniform variable.
  17534. * @param uniformName Name of the variable.
  17535. * @param array array to be set.
  17536. * @returns this effect.
  17537. */
  17538. setArray(uniformName: string, array: number[]): Effect;
  17539. /**
  17540. * 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)
  17541. * @param uniformName Name of the variable.
  17542. * @param array array to be set.
  17543. * @returns this effect.
  17544. */
  17545. setArray2(uniformName: string, array: number[]): Effect;
  17546. /**
  17547. * 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)
  17548. * @param uniformName Name of the variable.
  17549. * @param array array to be set.
  17550. * @returns this effect.
  17551. */
  17552. setArray3(uniformName: string, array: number[]): Effect;
  17553. /**
  17554. * 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)
  17555. * @param uniformName Name of the variable.
  17556. * @param array array to be set.
  17557. * @returns this effect.
  17558. */
  17559. setArray4(uniformName: string, array: number[]): Effect;
  17560. /**
  17561. * Sets matrices on a uniform variable.
  17562. * @param uniformName Name of the variable.
  17563. * @param matrices matrices to be set.
  17564. * @returns this effect.
  17565. */
  17566. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  17567. /**
  17568. * Sets matrix on a uniform variable.
  17569. * @param uniformName Name of the variable.
  17570. * @param matrix matrix to be set.
  17571. * @returns this effect.
  17572. */
  17573. setMatrix(uniformName: string, matrix: Matrix): Effect;
  17574. /**
  17575. * 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)
  17576. * @param uniformName Name of the variable.
  17577. * @param matrix matrix to be set.
  17578. * @returns this effect.
  17579. */
  17580. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  17581. /**
  17582. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  17583. * @param uniformName Name of the variable.
  17584. * @param matrix matrix to be set.
  17585. * @returns this effect.
  17586. */
  17587. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  17588. /**
  17589. * Sets a float on a uniform variable.
  17590. * @param uniformName Name of the variable.
  17591. * @param value value to be set.
  17592. * @returns this effect.
  17593. */
  17594. setFloat(uniformName: string, value: number): Effect;
  17595. /**
  17596. * Sets a boolean on a uniform variable.
  17597. * @param uniformName Name of the variable.
  17598. * @param bool value to be set.
  17599. * @returns this effect.
  17600. */
  17601. setBool(uniformName: string, bool: boolean): Effect;
  17602. /**
  17603. * Sets a Vector2 on a uniform variable.
  17604. * @param uniformName Name of the variable.
  17605. * @param vector2 vector2 to be set.
  17606. * @returns this effect.
  17607. */
  17608. setVector2(uniformName: string, vector2: Vector2): Effect;
  17609. /**
  17610. * Sets a float2 on a uniform variable.
  17611. * @param uniformName Name of the variable.
  17612. * @param x First float in float2.
  17613. * @param y Second float in float2.
  17614. * @returns this effect.
  17615. */
  17616. setFloat2(uniformName: string, x: number, y: number): Effect;
  17617. /**
  17618. * Sets a Vector3 on a uniform variable.
  17619. * @param uniformName Name of the variable.
  17620. * @param vector3 Value to be set.
  17621. * @returns this effect.
  17622. */
  17623. setVector3(uniformName: string, vector3: Vector3): Effect;
  17624. /**
  17625. * Sets a float3 on a uniform variable.
  17626. * @param uniformName Name of the variable.
  17627. * @param x First float in float3.
  17628. * @param y Second float in float3.
  17629. * @param z Third float in float3.
  17630. * @returns this effect.
  17631. */
  17632. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  17633. /**
  17634. * Sets a Vector4 on a uniform variable.
  17635. * @param uniformName Name of the variable.
  17636. * @param vector4 Value to be set.
  17637. * @returns this effect.
  17638. */
  17639. setVector4(uniformName: string, vector4: Vector4): Effect;
  17640. /**
  17641. * Sets a float4 on a uniform variable.
  17642. * @param uniformName Name of the variable.
  17643. * @param x First float in float4.
  17644. * @param y Second float in float4.
  17645. * @param z Third float in float4.
  17646. * @param w Fourth float in float4.
  17647. * @returns this effect.
  17648. */
  17649. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  17650. /**
  17651. * Sets a Color3 on a uniform variable.
  17652. * @param uniformName Name of the variable.
  17653. * @param color3 Value to be set.
  17654. * @returns this effect.
  17655. */
  17656. setColor3(uniformName: string, color3: Color3): Effect;
  17657. /**
  17658. * Sets a Color4 on a uniform variable.
  17659. * @param uniformName Name of the variable.
  17660. * @param color3 Value to be set.
  17661. * @param alpha Alpha value to be set.
  17662. * @returns this effect.
  17663. */
  17664. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  17665. /**
  17666. * Sets a Color4 on a uniform variable
  17667. * @param uniformName defines the name of the variable
  17668. * @param color4 defines the value to be set
  17669. * @returns this effect.
  17670. */
  17671. setDirectColor4(uniformName: string, color4: Color4): Effect;
  17672. /**
  17673. * This function will add a new shader to the shader store
  17674. * @param name the name of the shader
  17675. * @param pixelShader optional pixel shader content
  17676. * @param vertexShader optional vertex shader content
  17677. */
  17678. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  17679. /**
  17680. * Store of each shader (The can be looked up using effect.key)
  17681. */
  17682. static ShadersStore: {
  17683. [key: string]: string;
  17684. };
  17685. /**
  17686. * Store of each included file for a shader (The can be looked up using effect.key)
  17687. */
  17688. static IncludesShadersStore: {
  17689. [key: string]: string;
  17690. };
  17691. /**
  17692. * Resets the cache of effects.
  17693. */
  17694. static ResetCache(): void;
  17695. }
  17696. }
  17697. declare module BABYLON {
  17698. /**
  17699. * This represents all the required information to add a fresnel effect on a material:
  17700. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  17701. */
  17702. class FresnelParameters {
  17703. private _isEnabled;
  17704. /**
  17705. * Define if the fresnel effect is enable or not.
  17706. */
  17707. isEnabled: boolean;
  17708. /**
  17709. * Define the color used on edges (grazing angle)
  17710. */
  17711. leftColor: Color3;
  17712. /**
  17713. * Define the color used on center
  17714. */
  17715. rightColor: Color3;
  17716. /**
  17717. * Define bias applied to computed fresnel term
  17718. */
  17719. bias: number;
  17720. /**
  17721. * Defined the power exponent applied to fresnel term
  17722. */
  17723. power: number;
  17724. /**
  17725. * Clones the current fresnel and its valuues
  17726. * @returns a clone fresnel configuration
  17727. */
  17728. clone(): FresnelParameters;
  17729. /**
  17730. * Serializes the current fresnel parameters to a JSON representation.
  17731. * @return the JSON serialization
  17732. */
  17733. serialize(): any;
  17734. /**
  17735. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  17736. * @param parsedFresnelParameters Define the JSON representation
  17737. * @returns the parsed parameters
  17738. */
  17739. static Parse(parsedFresnelParameters: any): FresnelParameters;
  17740. }
  17741. }
  17742. declare module BABYLON {
  17743. /**
  17744. * Interface to follow in your material defines to integrate easily the
  17745. * Image proccessing functions.
  17746. * @hidden
  17747. */
  17748. interface IImageProcessingConfigurationDefines {
  17749. IMAGEPROCESSING: boolean;
  17750. VIGNETTE: boolean;
  17751. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17752. VIGNETTEBLENDMODEOPAQUE: boolean;
  17753. TONEMAPPING: boolean;
  17754. TONEMAPPING_ACES: boolean;
  17755. CONTRAST: boolean;
  17756. EXPOSURE: boolean;
  17757. COLORCURVES: boolean;
  17758. COLORGRADING: boolean;
  17759. COLORGRADING3D: boolean;
  17760. SAMPLER3DGREENDEPTH: boolean;
  17761. SAMPLER3DBGRMAP: boolean;
  17762. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17763. }
  17764. /**
  17765. * @hidden
  17766. */
  17767. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17768. IMAGEPROCESSING: boolean;
  17769. VIGNETTE: boolean;
  17770. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17771. VIGNETTEBLENDMODEOPAQUE: boolean;
  17772. TONEMAPPING: boolean;
  17773. TONEMAPPING_ACES: boolean;
  17774. CONTRAST: boolean;
  17775. COLORCURVES: boolean;
  17776. COLORGRADING: boolean;
  17777. COLORGRADING3D: boolean;
  17778. SAMPLER3DGREENDEPTH: boolean;
  17779. SAMPLER3DBGRMAP: boolean;
  17780. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17781. EXPOSURE: boolean;
  17782. constructor();
  17783. }
  17784. /**
  17785. * This groups together the common properties used for image processing either in direct forward pass
  17786. * or through post processing effect depending on the use of the image processing pipeline in your scene
  17787. * or not.
  17788. */
  17789. class ImageProcessingConfiguration {
  17790. /**
  17791. * Default tone mapping applied in BabylonJS.
  17792. */
  17793. static readonly TONEMAPPING_STANDARD: number;
  17794. /**
  17795. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  17796. * to other engines rendering to increase portability.
  17797. */
  17798. static readonly TONEMAPPING_ACES: number;
  17799. /**
  17800. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  17801. */
  17802. colorCurves: Nullable<ColorCurves>;
  17803. private _colorCurvesEnabled;
  17804. /**
  17805. * Gets wether the color curves effect is enabled.
  17806. */
  17807. /**
  17808. * Sets wether the color curves effect is enabled.
  17809. */
  17810. colorCurvesEnabled: boolean;
  17811. private _colorGradingTexture;
  17812. /**
  17813. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17814. */
  17815. /**
  17816. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17817. */
  17818. colorGradingTexture: Nullable<BaseTexture>;
  17819. private _colorGradingEnabled;
  17820. /**
  17821. * Gets wether the color grading effect is enabled.
  17822. */
  17823. /**
  17824. * Sets wether the color grading effect is enabled.
  17825. */
  17826. colorGradingEnabled: boolean;
  17827. private _colorGradingWithGreenDepth;
  17828. /**
  17829. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  17830. */
  17831. /**
  17832. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  17833. */
  17834. colorGradingWithGreenDepth: boolean;
  17835. private _colorGradingBGR;
  17836. /**
  17837. * Gets wether the color grading texture contains BGR values.
  17838. */
  17839. /**
  17840. * Sets wether the color grading texture contains BGR values.
  17841. */
  17842. colorGradingBGR: boolean;
  17843. /** @hidden */
  17844. _exposure: number;
  17845. /**
  17846. * Gets the Exposure used in the effect.
  17847. */
  17848. /**
  17849. * Sets the Exposure used in the effect.
  17850. */
  17851. exposure: number;
  17852. private _toneMappingEnabled;
  17853. /**
  17854. * Gets wether the tone mapping effect is enabled.
  17855. */
  17856. /**
  17857. * Sets wether the tone mapping effect is enabled.
  17858. */
  17859. toneMappingEnabled: boolean;
  17860. private _toneMappingType;
  17861. /**
  17862. * Gets the type of tone mapping effect.
  17863. */
  17864. /**
  17865. * Sets the type of tone mapping effect used in BabylonJS.
  17866. */
  17867. toneMappingType: number;
  17868. protected _contrast: number;
  17869. /**
  17870. * Gets the contrast used in the effect.
  17871. */
  17872. /**
  17873. * Sets the contrast used in the effect.
  17874. */
  17875. contrast: number;
  17876. /**
  17877. * Vignette stretch size.
  17878. */
  17879. vignetteStretch: number;
  17880. /**
  17881. * Vignette centre X Offset.
  17882. */
  17883. vignetteCentreX: number;
  17884. /**
  17885. * Vignette centre Y Offset.
  17886. */
  17887. vignetteCentreY: number;
  17888. /**
  17889. * Vignette weight or intensity of the vignette effect.
  17890. */
  17891. vignetteWeight: number;
  17892. /**
  17893. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17894. * if vignetteEnabled is set to true.
  17895. */
  17896. vignetteColor: Color4;
  17897. /**
  17898. * Camera field of view used by the Vignette effect.
  17899. */
  17900. vignetteCameraFov: number;
  17901. private _vignetteBlendMode;
  17902. /**
  17903. * Gets the vignette blend mode allowing different kind of effect.
  17904. */
  17905. /**
  17906. * Sets the vignette blend mode allowing different kind of effect.
  17907. */
  17908. vignetteBlendMode: number;
  17909. private _vignetteEnabled;
  17910. /**
  17911. * Gets wether the vignette effect is enabled.
  17912. */
  17913. /**
  17914. * Sets wether the vignette effect is enabled.
  17915. */
  17916. vignetteEnabled: boolean;
  17917. private _applyByPostProcess;
  17918. /**
  17919. * Gets wether the image processing is applied through a post process or not.
  17920. */
  17921. /**
  17922. * Sets wether the image processing is applied through a post process or not.
  17923. */
  17924. applyByPostProcess: boolean;
  17925. private _isEnabled;
  17926. /**
  17927. * Gets wether the image processing is enabled or not.
  17928. */
  17929. /**
  17930. * Sets wether the image processing is enabled or not.
  17931. */
  17932. isEnabled: boolean;
  17933. /**
  17934. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  17935. */
  17936. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  17937. /**
  17938. * Method called each time the image processing information changes requires to recompile the effect.
  17939. */
  17940. protected _updateParameters(): void;
  17941. /**
  17942. * Gets the current class name.
  17943. * @return "ImageProcessingConfiguration"
  17944. */
  17945. getClassName(): string;
  17946. /**
  17947. * Prepare the list of uniforms associated with the Image Processing effects.
  17948. * @param uniforms The list of uniforms used in the effect
  17949. * @param defines the list of defines currently in use
  17950. */
  17951. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  17952. /**
  17953. * Prepare the list of samplers associated with the Image Processing effects.
  17954. * @param samplersList The list of uniforms used in the effect
  17955. * @param defines the list of defines currently in use
  17956. */
  17957. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  17958. /**
  17959. * Prepare the list of defines associated to the shader.
  17960. * @param defines the list of defines to complete
  17961. * @param forPostProcess Define if we are currently in post process mode or not
  17962. */
  17963. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  17964. /**
  17965. * Returns true if all the image processing information are ready.
  17966. * @returns True if ready, otherwise, false
  17967. */
  17968. isReady(): boolean;
  17969. /**
  17970. * Binds the image processing to the shader.
  17971. * @param effect The effect to bind to
  17972. * @param aspectRatio Define the current aspect ratio of the effect
  17973. */
  17974. bind(effect: Effect, aspectRatio?: number): void;
  17975. /**
  17976. * Clones the current image processing instance.
  17977. * @return The cloned image processing
  17978. */
  17979. clone(): ImageProcessingConfiguration;
  17980. /**
  17981. * Serializes the current image processing instance to a json representation.
  17982. * @return a JSON representation
  17983. */
  17984. serialize(): any;
  17985. /**
  17986. * Parses the image processing from a json representation.
  17987. * @param source the JSON source to parse
  17988. * @return The parsed image processing
  17989. */
  17990. static Parse(source: any): ImageProcessingConfiguration;
  17991. private static _VIGNETTEMODE_MULTIPLY;
  17992. private static _VIGNETTEMODE_OPAQUE;
  17993. /**
  17994. * Used to apply the vignette as a mix with the pixel color.
  17995. */
  17996. static readonly VIGNETTEMODE_MULTIPLY: number;
  17997. /**
  17998. * Used to apply the vignette as a replacement of the pixel color.
  17999. */
  18000. static readonly VIGNETTEMODE_OPAQUE: number;
  18001. }
  18002. }
  18003. declare module BABYLON {
  18004. /**
  18005. * Manages the defines for the Material
  18006. */
  18007. class MaterialDefines {
  18008. private _keys;
  18009. private _isDirty;
  18010. /** @hidden */
  18011. _renderId: number;
  18012. /** @hidden */
  18013. _areLightsDirty: boolean;
  18014. /** @hidden */
  18015. _areAttributesDirty: boolean;
  18016. /** @hidden */
  18017. _areTexturesDirty: boolean;
  18018. /** @hidden */
  18019. _areFresnelDirty: boolean;
  18020. /** @hidden */
  18021. _areMiscDirty: boolean;
  18022. /** @hidden */
  18023. _areImageProcessingDirty: boolean;
  18024. /** @hidden */
  18025. _normals: boolean;
  18026. /** @hidden */
  18027. _uvs: boolean;
  18028. /** @hidden */
  18029. _needNormals: boolean;
  18030. /** @hidden */
  18031. _needUVs: boolean;
  18032. /**
  18033. * Specifies if the material needs to be re-calculated
  18034. */
  18035. readonly isDirty: boolean;
  18036. /**
  18037. * Marks the material to indicate that it has been re-calculated
  18038. */
  18039. markAsProcessed(): void;
  18040. /**
  18041. * Marks the material to indicate that it needs to be re-calculated
  18042. */
  18043. markAsUnprocessed(): void;
  18044. /**
  18045. * Marks the material to indicate all of its defines need to be re-calculated
  18046. */
  18047. markAllAsDirty(): void;
  18048. /**
  18049. * Marks the material to indicate that image processing needs to be re-calculated
  18050. */
  18051. markAsImageProcessingDirty(): void;
  18052. /**
  18053. * Marks the material to indicate the lights need to be re-calculated
  18054. */
  18055. markAsLightDirty(): void;
  18056. /**
  18057. * Marks the attribute state as changed
  18058. */
  18059. markAsAttributesDirty(): void;
  18060. /**
  18061. * Marks the texture state as changed
  18062. */
  18063. markAsTexturesDirty(): void;
  18064. /**
  18065. * Marks the fresnel state as changed
  18066. */
  18067. markAsFresnelDirty(): void;
  18068. /**
  18069. * Marks the misc state as changed
  18070. */
  18071. markAsMiscDirty(): void;
  18072. /**
  18073. * Rebuilds the material defines
  18074. */
  18075. rebuild(): void;
  18076. /**
  18077. * Specifies if two material defines are equal
  18078. * @param other - A material define instance to compare to
  18079. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  18080. */
  18081. isEqual(other: MaterialDefines): boolean;
  18082. /**
  18083. * Clones this instance's defines to another instance
  18084. * @param other - material defines to clone values to
  18085. */
  18086. cloneTo(other: MaterialDefines): void;
  18087. /**
  18088. * Resets the material define values
  18089. */
  18090. reset(): void;
  18091. /**
  18092. * Converts the material define values to a string
  18093. * @returns - String of material define information
  18094. */
  18095. toString(): string;
  18096. }
  18097. /**
  18098. * Base class for the main features of a material in Babylon.js
  18099. */
  18100. class Material implements IAnimatable {
  18101. private static _TriangleFillMode;
  18102. private static _WireFrameFillMode;
  18103. private static _PointFillMode;
  18104. private static _PointListDrawMode;
  18105. private static _LineListDrawMode;
  18106. private static _LineLoopDrawMode;
  18107. private static _LineStripDrawMode;
  18108. private static _TriangleStripDrawMode;
  18109. private static _TriangleFanDrawMode;
  18110. /**
  18111. * Returns the triangle fill mode
  18112. */
  18113. static readonly TriangleFillMode: number;
  18114. /**
  18115. * Returns the wireframe mode
  18116. */
  18117. static readonly WireFrameFillMode: number;
  18118. /**
  18119. * Returns the point fill mode
  18120. */
  18121. static readonly PointFillMode: number;
  18122. /**
  18123. * Returns the point list draw mode
  18124. */
  18125. static readonly PointListDrawMode: number;
  18126. /**
  18127. * Returns the line list draw mode
  18128. */
  18129. static readonly LineListDrawMode: number;
  18130. /**
  18131. * Returns the line loop draw mode
  18132. */
  18133. static readonly LineLoopDrawMode: number;
  18134. /**
  18135. * Returns the line strip draw mode
  18136. */
  18137. static readonly LineStripDrawMode: number;
  18138. /**
  18139. * Returns the triangle strip draw mode
  18140. */
  18141. static readonly TriangleStripDrawMode: number;
  18142. /**
  18143. * Returns the triangle fan draw mode
  18144. */
  18145. static readonly TriangleFanDrawMode: number;
  18146. /**
  18147. * Stores the clock-wise side orientation
  18148. */
  18149. private static _ClockWiseSideOrientation;
  18150. /**
  18151. * Stores the counter clock-wise side orientation
  18152. */
  18153. private static _CounterClockWiseSideOrientation;
  18154. /**
  18155. * Returns the clock-wise side orientation
  18156. */
  18157. static readonly ClockWiseSideOrientation: number;
  18158. /**
  18159. * Returns the counter clock-wise side orientation
  18160. */
  18161. static readonly CounterClockWiseSideOrientation: number;
  18162. /**
  18163. * The dirty texture flag value
  18164. */
  18165. static readonly TextureDirtyFlag: number;
  18166. /**
  18167. * The dirty light flag value
  18168. */
  18169. static readonly LightDirtyFlag: number;
  18170. /**
  18171. * The dirty fresnel flag value
  18172. */
  18173. static readonly FresnelDirtyFlag: number;
  18174. /**
  18175. * The dirty attribute flag value
  18176. */
  18177. static readonly AttributesDirtyFlag: number;
  18178. /**
  18179. * The dirty misc flag value
  18180. */
  18181. static readonly MiscDirtyFlag: number;
  18182. /**
  18183. * The all dirty flag value
  18184. */
  18185. static readonly AllDirtyFlag: number;
  18186. /**
  18187. * The ID of the material
  18188. */
  18189. id: string;
  18190. /**
  18191. * Gets or sets the unique id of the material
  18192. */
  18193. uniqueId: number;
  18194. /**
  18195. * The name of the material
  18196. */
  18197. name: string;
  18198. /**
  18199. * Gets or sets user defined metadata
  18200. */
  18201. metadata: any;
  18202. /**
  18203. * For internal use only. Please do not use.
  18204. */
  18205. reservedDataStore: any;
  18206. /**
  18207. * Specifies if the ready state should be checked on each call
  18208. */
  18209. checkReadyOnEveryCall: boolean;
  18210. /**
  18211. * Specifies if the ready state should be checked once
  18212. */
  18213. checkReadyOnlyOnce: boolean;
  18214. /**
  18215. * The state of the material
  18216. */
  18217. state: string;
  18218. /**
  18219. * The alpha value of the material
  18220. */
  18221. protected _alpha: number;
  18222. /**
  18223. * Sets the alpha value of the material
  18224. */
  18225. /**
  18226. * Gets the alpha value of the material
  18227. */
  18228. alpha: number;
  18229. /**
  18230. * Specifies if back face culling is enabled
  18231. */
  18232. protected _backFaceCulling: boolean;
  18233. /**
  18234. * Sets the back-face culling state
  18235. */
  18236. /**
  18237. * Gets the back-face culling state
  18238. */
  18239. backFaceCulling: boolean;
  18240. /**
  18241. * Stores the value for side orientation
  18242. */
  18243. sideOrientation: number;
  18244. /**
  18245. * Callback triggered when the material is compiled
  18246. */
  18247. onCompiled: (effect: Effect) => void;
  18248. /**
  18249. * Callback triggered when an error occurs
  18250. */
  18251. onError: (effect: Effect, errors: string) => void;
  18252. /**
  18253. * Callback triggered to get the render target textures
  18254. */
  18255. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  18256. /**
  18257. * Gets a boolean indicating that current material needs to register RTT
  18258. */
  18259. readonly hasRenderTargetTextures: boolean;
  18260. /**
  18261. * Specifies if the material should be serialized
  18262. */
  18263. doNotSerialize: boolean;
  18264. /**
  18265. * @hidden
  18266. */
  18267. _storeEffectOnSubMeshes: boolean;
  18268. /**
  18269. * Stores the animations for the material
  18270. */
  18271. animations: Array<Animation>;
  18272. /**
  18273. * An event triggered when the material is disposed
  18274. */
  18275. onDisposeObservable: Observable<Material>;
  18276. /**
  18277. * An observer which watches for dispose events
  18278. */
  18279. private _onDisposeObserver;
  18280. private _onUnBindObservable;
  18281. /**
  18282. * Called during a dispose event
  18283. */
  18284. onDispose: () => void;
  18285. private _onBindObservable;
  18286. /**
  18287. * An event triggered when the material is bound
  18288. */
  18289. readonly onBindObservable: Observable<AbstractMesh>;
  18290. /**
  18291. * An observer which watches for bind events
  18292. */
  18293. private _onBindObserver;
  18294. /**
  18295. * Called during a bind event
  18296. */
  18297. onBind: (Mesh: AbstractMesh) => void;
  18298. /**
  18299. * An event triggered when the material is unbound
  18300. */
  18301. readonly onUnBindObservable: Observable<Material>;
  18302. /**
  18303. * Stores the value of the alpha mode
  18304. */
  18305. private _alphaMode;
  18306. /**
  18307. * Sets the value of the alpha mode.
  18308. *
  18309. * | Value | Type | Description |
  18310. * | --- | --- | --- |
  18311. * | 0 | ALPHA_DISABLE | |
  18312. * | 1 | ALPHA_ADD | |
  18313. * | 2 | ALPHA_COMBINE | |
  18314. * | 3 | ALPHA_SUBTRACT | |
  18315. * | 4 | ALPHA_MULTIPLY | |
  18316. * | 5 | ALPHA_MAXIMIZED | |
  18317. * | 6 | ALPHA_ONEONE | |
  18318. * | 7 | ALPHA_PREMULTIPLIED | |
  18319. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  18320. * | 9 | ALPHA_INTERPOLATE | |
  18321. * | 10 | ALPHA_SCREENMODE | |
  18322. *
  18323. */
  18324. /**
  18325. * Gets the value of the alpha mode
  18326. */
  18327. alphaMode: number;
  18328. /**
  18329. * Stores the state of the need depth pre-pass value
  18330. */
  18331. private _needDepthPrePass;
  18332. /**
  18333. * Sets the need depth pre-pass value
  18334. */
  18335. /**
  18336. * Gets the depth pre-pass value
  18337. */
  18338. needDepthPrePass: boolean;
  18339. /**
  18340. * Specifies if depth writing should be disabled
  18341. */
  18342. disableDepthWrite: boolean;
  18343. /**
  18344. * Specifies if depth writing should be forced
  18345. */
  18346. forceDepthWrite: boolean;
  18347. /**
  18348. * Specifies if there should be a separate pass for culling
  18349. */
  18350. separateCullingPass: boolean;
  18351. /**
  18352. * Stores the state specifing if fog should be enabled
  18353. */
  18354. private _fogEnabled;
  18355. /**
  18356. * Sets the state for enabling fog
  18357. */
  18358. /**
  18359. * Gets the value of the fog enabled state
  18360. */
  18361. fogEnabled: boolean;
  18362. /**
  18363. * Stores the size of points
  18364. */
  18365. pointSize: number;
  18366. /**
  18367. * Stores the z offset value
  18368. */
  18369. zOffset: number;
  18370. /**
  18371. * Gets a value specifying if wireframe mode is enabled
  18372. */
  18373. /**
  18374. * Sets the state of wireframe mode
  18375. */
  18376. wireframe: boolean;
  18377. /**
  18378. * Gets the value specifying if point clouds are enabled
  18379. */
  18380. /**
  18381. * Sets the state of point cloud mode
  18382. */
  18383. pointsCloud: boolean;
  18384. /**
  18385. * Gets the material fill mode
  18386. */
  18387. /**
  18388. * Sets the material fill mode
  18389. */
  18390. fillMode: number;
  18391. /**
  18392. * @hidden
  18393. * Stores the effects for the material
  18394. */
  18395. _effect: Nullable<Effect>;
  18396. /**
  18397. * @hidden
  18398. * Specifies if the material was previously ready
  18399. */
  18400. _wasPreviouslyReady: boolean;
  18401. /**
  18402. * Specifies if uniform buffers should be used
  18403. */
  18404. private _useUBO;
  18405. /**
  18406. * Stores a reference to the scene
  18407. */
  18408. private _scene;
  18409. /**
  18410. * Stores the fill mode state
  18411. */
  18412. private _fillMode;
  18413. /**
  18414. * Specifies if the depth write state should be cached
  18415. */
  18416. private _cachedDepthWriteState;
  18417. /**
  18418. * Stores the uniform buffer
  18419. */
  18420. protected _uniformBuffer: UniformBuffer;
  18421. /** @hidden */
  18422. _indexInSceneMaterialArray: number;
  18423. /** @hidden */
  18424. meshMap: Nullable<{
  18425. [id: string]: AbstractMesh | undefined;
  18426. }>;
  18427. /**
  18428. * Creates a material instance
  18429. * @param name defines the name of the material
  18430. * @param scene defines the scene to reference
  18431. * @param doNotAdd specifies if the material should be added to the scene
  18432. */
  18433. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  18434. /**
  18435. * Returns a string representation of the current material
  18436. * @param fullDetails defines a boolean indicating which levels of logging is desired
  18437. * @returns a string with material information
  18438. */
  18439. toString(fullDetails?: boolean): string;
  18440. /**
  18441. * Gets the class name of the material
  18442. * @returns a string with the class name of the material
  18443. */
  18444. getClassName(): string;
  18445. /**
  18446. * Specifies if updates for the material been locked
  18447. */
  18448. readonly isFrozen: boolean;
  18449. /**
  18450. * Locks updates for the material
  18451. */
  18452. freeze(): void;
  18453. /**
  18454. * Unlocks updates for the material
  18455. */
  18456. unfreeze(): void;
  18457. /**
  18458. * Specifies if the material is ready to be used
  18459. * @param mesh defines the mesh to check
  18460. * @param useInstances specifies if instances should be used
  18461. * @returns a boolean indicating if the material is ready to be used
  18462. */
  18463. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18464. /**
  18465. * Specifies that the submesh is ready to be used
  18466. * @param mesh defines the mesh to check
  18467. * @param subMesh defines which submesh to check
  18468. * @param useInstances specifies that instances should be used
  18469. * @returns a boolean indicating that the submesh is ready or not
  18470. */
  18471. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18472. /**
  18473. * Returns the material effect
  18474. * @returns the effect associated with the material
  18475. */
  18476. getEffect(): Nullable<Effect>;
  18477. /**
  18478. * Returns the current scene
  18479. * @returns a Scene
  18480. */
  18481. getScene(): Scene;
  18482. /**
  18483. * Specifies if the material will require alpha blending
  18484. * @returns a boolean specifying if alpha blending is needed
  18485. */
  18486. needAlphaBlending(): boolean;
  18487. /**
  18488. * Specifies if the mesh will require alpha blending
  18489. * @param mesh defines the mesh to check
  18490. * @returns a boolean specifying if alpha blending is needed for the mesh
  18491. */
  18492. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  18493. /**
  18494. * Specifies if this material should be rendered in alpha test mode
  18495. * @returns a boolean specifying if an alpha test is needed.
  18496. */
  18497. needAlphaTesting(): boolean;
  18498. /**
  18499. * Gets the texture used for the alpha test
  18500. * @returns the texture to use for alpha testing
  18501. */
  18502. getAlphaTestTexture(): Nullable<BaseTexture>;
  18503. /**
  18504. * Marks the material to indicate that it needs to be re-calculated
  18505. */
  18506. markDirty(): void;
  18507. /** @hidden */
  18508. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  18509. /**
  18510. * Binds the material to the mesh
  18511. * @param world defines the world transformation matrix
  18512. * @param mesh defines the mesh to bind the material to
  18513. */
  18514. bind(world: Matrix, mesh?: Mesh): void;
  18515. /**
  18516. * Binds the submesh to the material
  18517. * @param world defines the world transformation matrix
  18518. * @param mesh defines the mesh containing the submesh
  18519. * @param subMesh defines the submesh to bind the material to
  18520. */
  18521. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18522. /**
  18523. * Binds the world matrix to the material
  18524. * @param world defines the world transformation matrix
  18525. */
  18526. bindOnlyWorldMatrix(world: Matrix): void;
  18527. /**
  18528. * Binds the scene's uniform buffer to the effect.
  18529. * @param effect defines the effect to bind to the scene uniform buffer
  18530. * @param sceneUbo defines the uniform buffer storing scene data
  18531. */
  18532. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  18533. /**
  18534. * Binds the view matrix to the effect
  18535. * @param effect defines the effect to bind the view matrix to
  18536. */
  18537. bindView(effect: Effect): void;
  18538. /**
  18539. * Binds the view projection matrix to the effect
  18540. * @param effect defines the effect to bind the view projection matrix to
  18541. */
  18542. bindViewProjection(effect: Effect): void;
  18543. /**
  18544. * Specifies if material alpha testing should be turned on for the mesh
  18545. * @param mesh defines the mesh to check
  18546. */
  18547. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  18548. /**
  18549. * Processes to execute after binding the material to a mesh
  18550. * @param mesh defines the rendered mesh
  18551. */
  18552. protected _afterBind(mesh?: Mesh): void;
  18553. /**
  18554. * Unbinds the material from the mesh
  18555. */
  18556. unbind(): void;
  18557. /**
  18558. * Gets the active textures from the material
  18559. * @returns an array of textures
  18560. */
  18561. getActiveTextures(): BaseTexture[];
  18562. /**
  18563. * Specifies if the material uses a texture
  18564. * @param texture defines the texture to check against the material
  18565. * @returns a boolean specifying if the material uses the texture
  18566. */
  18567. hasTexture(texture: BaseTexture): boolean;
  18568. /**
  18569. * Makes a duplicate of the material, and gives it a new name
  18570. * @param name defines the new name for the duplicated material
  18571. * @returns the cloned material
  18572. */
  18573. clone(name: string): Nullable<Material>;
  18574. /**
  18575. * Gets the meshes bound to the material
  18576. * @returns an array of meshes bound to the material
  18577. */
  18578. getBindedMeshes(): AbstractMesh[];
  18579. /**
  18580. * Force shader compilation
  18581. * @param mesh defines the mesh associated with this material
  18582. * @param onCompiled defines a function to execute once the material is compiled
  18583. * @param options defines the options to configure the compilation
  18584. */
  18585. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18586. clipPlane: boolean;
  18587. }>): void;
  18588. /**
  18589. * Force shader compilation
  18590. * @param mesh defines the mesh that will use this material
  18591. * @param options defines additional options for compiling the shaders
  18592. * @returns a promise that resolves when the compilation completes
  18593. */
  18594. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18595. clipPlane: boolean;
  18596. }>): Promise<void>;
  18597. private static readonly _ImageProcessingDirtyCallBack;
  18598. private static readonly _TextureDirtyCallBack;
  18599. private static readonly _FresnelDirtyCallBack;
  18600. private static readonly _MiscDirtyCallBack;
  18601. private static readonly _LightsDirtyCallBack;
  18602. private static readonly _AttributeDirtyCallBack;
  18603. private static _FresnelAndMiscDirtyCallBack;
  18604. private static _TextureAndMiscDirtyCallBack;
  18605. private static readonly _DirtyCallbackArray;
  18606. private static readonly _RunDirtyCallBacks;
  18607. /**
  18608. * Marks a define in the material to indicate that it needs to be re-computed
  18609. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18610. */
  18611. markAsDirty(flag: number): void;
  18612. /**
  18613. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18614. * @param func defines a function which checks material defines against the submeshes
  18615. */
  18616. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18617. /**
  18618. * Indicates that image processing needs to be re-calculated for all submeshes
  18619. */
  18620. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18621. /**
  18622. * Indicates that textures need to be re-calculated for all submeshes
  18623. */
  18624. protected _markAllSubMeshesAsTexturesDirty(): void;
  18625. /**
  18626. * Indicates that fresnel needs to be re-calculated for all submeshes
  18627. */
  18628. protected _markAllSubMeshesAsFresnelDirty(): void;
  18629. /**
  18630. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18631. */
  18632. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18633. /**
  18634. * Indicates that lights need to be re-calculated for all submeshes
  18635. */
  18636. protected _markAllSubMeshesAsLightsDirty(): void;
  18637. /**
  18638. * Indicates that attributes need to be re-calculated for all submeshes
  18639. */
  18640. protected _markAllSubMeshesAsAttributesDirty(): void;
  18641. /**
  18642. * Indicates that misc needs to be re-calculated for all submeshes
  18643. */
  18644. protected _markAllSubMeshesAsMiscDirty(): void;
  18645. /**
  18646. * Indicates that textures and misc need to be re-calculated for all submeshes
  18647. */
  18648. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18649. /**
  18650. * Disposes the material
  18651. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18652. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18653. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18654. */
  18655. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18656. /** @hidden */
  18657. private releaseVertexArrayObject;
  18658. /**
  18659. * Serializes this material
  18660. * @returns the serialized material object
  18661. */
  18662. serialize(): any;
  18663. /**
  18664. * Creates a MultiMaterial from parsed MultiMaterial data.
  18665. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  18666. * @param scene defines the hosting scene
  18667. * @returns a new MultiMaterial
  18668. */
  18669. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  18670. /**
  18671. * Creates a material from parsed material data
  18672. * @param parsedMaterial defines parsed material data
  18673. * @param scene defines the hosting scene
  18674. * @param rootUrl defines the root URL to use to load textures
  18675. * @returns a new material
  18676. */
  18677. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18678. }
  18679. }
  18680. declare module BABYLON {
  18681. /**
  18682. * "Static Class" containing the most commonly used helper while dealing with material for
  18683. * rendering purpose.
  18684. *
  18685. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  18686. *
  18687. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  18688. */
  18689. class MaterialHelper {
  18690. /**
  18691. * Bind the current view position to an effect.
  18692. * @param effect The effect to be bound
  18693. * @param scene The scene the eyes position is used from
  18694. */
  18695. static BindEyePosition(effect: Effect, scene: Scene): void;
  18696. /**
  18697. * Helps preparing the defines values about the UVs in used in the effect.
  18698. * UVs are shared as much as we can accross channels in the shaders.
  18699. * @param texture The texture we are preparing the UVs for
  18700. * @param defines The defines to update
  18701. * @param key The channel key "diffuse", "specular"... used in the shader
  18702. */
  18703. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  18704. /**
  18705. * Binds a texture matrix value to its corrsponding uniform
  18706. * @param texture The texture to bind the matrix for
  18707. * @param uniformBuffer The uniform buffer receivin the data
  18708. * @param key The channel key "diffuse", "specular"... used in the shader
  18709. */
  18710. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  18711. /**
  18712. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  18713. * @param mesh defines the current mesh
  18714. * @param scene defines the current scene
  18715. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  18716. * @param pointsCloud defines if point cloud rendering has to be turned on
  18717. * @param fogEnabled defines if fog has to be turned on
  18718. * @param alphaTest defines if alpha testing has to be turned on
  18719. * @param defines defines the current list of defines
  18720. */
  18721. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  18722. /**
  18723. * Helper used to prepare the list of defines associated with frame values for shader compilation
  18724. * @param scene defines the current scene
  18725. * @param engine defines the current engine
  18726. * @param defines specifies the list of active defines
  18727. * @param useInstances defines if instances have to be turned on
  18728. * @param useClipPlane defines if clip plane have to be turned on
  18729. */
  18730. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  18731. /**
  18732. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  18733. * @param mesh The mesh containing the geometry data we will draw
  18734. * @param defines The defines to update
  18735. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  18736. * @param useBones Precise whether bones should be used or not (override mesh info)
  18737. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  18738. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  18739. * @returns false if defines are considered not dirty and have not been checked
  18740. */
  18741. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  18742. /**
  18743. * Prepares the defines related to the light information passed in parameter
  18744. * @param scene The scene we are intending to draw
  18745. * @param mesh The mesh the effect is compiling for
  18746. * @param defines The defines to update
  18747. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  18748. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  18749. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  18750. * @returns true if normals will be required for the rest of the effect
  18751. */
  18752. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  18753. /**
  18754. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  18755. * that won t be acctive due to defines being turned off.
  18756. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  18757. * @param samplersList The samplers list
  18758. * @param defines The defines helping in the list generation
  18759. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  18760. */
  18761. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  18762. /**
  18763. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  18764. * @param defines The defines to update while falling back
  18765. * @param fallbacks The authorized effect fallbacks
  18766. * @param maxSimultaneousLights The maximum number of lights allowed
  18767. * @param rank the current rank of the Effect
  18768. * @returns The newly affected rank
  18769. */
  18770. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  18771. /**
  18772. * Prepares the list of attributes required for morph targets according to the effect defines.
  18773. * @param attribs The current list of supported attribs
  18774. * @param mesh The mesh to prepare the morph targets attributes for
  18775. * @param defines The current Defines of the effect
  18776. */
  18777. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  18778. /**
  18779. * Prepares the list of attributes required for bones according to the effect defines.
  18780. * @param attribs The current list of supported attribs
  18781. * @param mesh The mesh to prepare the bones attributes for
  18782. * @param defines The current Defines of the effect
  18783. * @param fallbacks The current efffect fallback strategy
  18784. */
  18785. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  18786. /**
  18787. * Prepares the list of attributes required for instances according to the effect defines.
  18788. * @param attribs The current list of supported attribs
  18789. * @param defines The current Defines of the effect
  18790. */
  18791. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  18792. /**
  18793. * Binds the light shadow information to the effect for the given mesh.
  18794. * @param light The light containing the generator
  18795. * @param scene The scene the lights belongs to
  18796. * @param mesh The mesh we are binding the information to render
  18797. * @param lightIndex The light index in the effect used to render the mesh
  18798. * @param effect The effect we are binding the data to
  18799. */
  18800. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  18801. /**
  18802. * Binds the light information to the effect.
  18803. * @param light The light containing the generator
  18804. * @param effect The effect we are binding the data to
  18805. * @param lightIndex The light index in the effect used to render
  18806. */
  18807. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  18808. /**
  18809. * Binds the lights information from the scene to the effect for the given mesh.
  18810. * @param scene The scene the lights belongs to
  18811. * @param mesh The mesh we are binding the information to render
  18812. * @param effect The effect we are binding the data to
  18813. * @param defines The generated defines for the effect
  18814. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  18815. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  18816. */
  18817. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  18818. private static _tempFogColor;
  18819. /**
  18820. * Binds the fog information from the scene to the effect for the given mesh.
  18821. * @param scene The scene the lights belongs to
  18822. * @param mesh The mesh we are binding the information to render
  18823. * @param effect The effect we are binding the data to
  18824. * @param linearSpace Defines if the fog effect is applied in linear space
  18825. */
  18826. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  18827. /**
  18828. * Binds the bones information from the mesh to the effect.
  18829. * @param mesh The mesh we are binding the information to render
  18830. * @param effect The effect we are binding the data to
  18831. */
  18832. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  18833. /**
  18834. * Binds the morph targets information from the mesh to the effect.
  18835. * @param abstractMesh The mesh we are binding the information to render
  18836. * @param effect The effect we are binding the data to
  18837. */
  18838. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  18839. /**
  18840. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  18841. * @param defines The generated defines used in the effect
  18842. * @param effect The effect we are binding the data to
  18843. * @param scene The scene we are willing to render with logarithmic scale for
  18844. */
  18845. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  18846. /**
  18847. * Binds the clip plane information from the scene to the effect.
  18848. * @param scene The scene the clip plane information are extracted from
  18849. * @param effect The effect we are binding the data to
  18850. */
  18851. static BindClipPlane(effect: Effect, scene: Scene): void;
  18852. }
  18853. }
  18854. declare module BABYLON {
  18855. /**
  18856. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18857. * separate meshes. This can be use to improve performances.
  18858. * @see http://doc.babylonjs.com/how_to/multi_materials
  18859. */
  18860. class MultiMaterial extends Material {
  18861. private _subMaterials;
  18862. /**
  18863. * Gets or Sets the list of Materials used within the multi material.
  18864. * They need to be ordered according to the submeshes order in the associated mesh
  18865. */
  18866. subMaterials: Nullable<Material>[];
  18867. /**
  18868. * Function used to align with Node.getChildren()
  18869. * @returns the list of Materials used within the multi material
  18870. */
  18871. getChildren(): Nullable<Material>[];
  18872. /**
  18873. * Instantiates a new Multi Material
  18874. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18875. * separate meshes. This can be use to improve performances.
  18876. * @see http://doc.babylonjs.com/how_to/multi_materials
  18877. * @param name Define the name in the scene
  18878. * @param scene Define the scene the material belongs to
  18879. */
  18880. constructor(name: string, scene: Scene);
  18881. private _hookArray;
  18882. /**
  18883. * Get one of the submaterial by its index in the submaterials array
  18884. * @param index The index to look the sub material at
  18885. * @returns The Material if the index has been defined
  18886. */
  18887. getSubMaterial(index: number): Nullable<Material>;
  18888. /**
  18889. * Get the list of active textures for the whole sub materials list.
  18890. * @returns All the textures that will be used during the rendering
  18891. */
  18892. getActiveTextures(): BaseTexture[];
  18893. /**
  18894. * Gets the current class name of the material e.g. "MultiMaterial"
  18895. * Mainly use in serialization.
  18896. * @returns the class name
  18897. */
  18898. getClassName(): string;
  18899. /**
  18900. * Checks if the material is ready to render the requested sub mesh
  18901. * @param mesh Define the mesh the submesh belongs to
  18902. * @param subMesh Define the sub mesh to look readyness for
  18903. * @param useInstances Define whether or not the material is used with instances
  18904. * @returns true if ready, otherwise false
  18905. */
  18906. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18907. /**
  18908. * Clones the current material and its related sub materials
  18909. * @param name Define the name of the newly cloned material
  18910. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  18911. * @returns the cloned material
  18912. */
  18913. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  18914. /**
  18915. * Serializes the materials into a JSON representation.
  18916. * @returns the JSON representation
  18917. */
  18918. serialize(): any;
  18919. /**
  18920. * Dispose the material and release its associated resources
  18921. * @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)
  18922. * @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)
  18923. */
  18924. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18925. }
  18926. }
  18927. declare module BABYLON {
  18928. /**
  18929. * Base class of materials working in push mode in babylon JS
  18930. * @hidden
  18931. */
  18932. class PushMaterial extends Material {
  18933. protected _activeEffect: Effect;
  18934. protected _normalMatrix: Matrix;
  18935. /**
  18936. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  18937. * This means that the material can keep using a previous shader while a new one is being compiled.
  18938. * This is mostly used when shader parallel compilation is supported (true by default)
  18939. */
  18940. allowShaderHotSwapping: boolean;
  18941. constructor(name: string, scene: Scene);
  18942. getEffect(): Effect;
  18943. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18944. /**
  18945. * Binds the given world matrix to the active effect
  18946. *
  18947. * @param world the matrix to bind
  18948. */
  18949. bindOnlyWorldMatrix(world: Matrix): void;
  18950. /**
  18951. * Binds the given normal matrix to the active effect
  18952. *
  18953. * @param normalMatrix the matrix to bind
  18954. */
  18955. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  18956. bind(world: Matrix, mesh?: Mesh): void;
  18957. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  18958. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  18959. }
  18960. }
  18961. declare module BABYLON {
  18962. /**
  18963. * Defines the options associated with the creation of a shader material.
  18964. */
  18965. interface IShaderMaterialOptions {
  18966. /**
  18967. * Does the material work in alpha blend mode
  18968. */
  18969. needAlphaBlending: boolean;
  18970. /**
  18971. * Does the material work in alpha test mode
  18972. */
  18973. needAlphaTesting: boolean;
  18974. /**
  18975. * The list of attribute names used in the shader
  18976. */
  18977. attributes: string[];
  18978. /**
  18979. * The list of unifrom names used in the shader
  18980. */
  18981. uniforms: string[];
  18982. /**
  18983. * The list of UBO names used in the shader
  18984. */
  18985. uniformBuffers: string[];
  18986. /**
  18987. * The list of sampler names used in the shader
  18988. */
  18989. samplers: string[];
  18990. /**
  18991. * The list of defines used in the shader
  18992. */
  18993. defines: string[];
  18994. }
  18995. /**
  18996. * 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.
  18997. *
  18998. * This returned material effects how the mesh will look based on the code in the shaders.
  18999. *
  19000. * @see http://doc.babylonjs.com/how_to/shader_material
  19001. */
  19002. class ShaderMaterial extends Material {
  19003. private _shaderPath;
  19004. private _options;
  19005. private _textures;
  19006. private _textureArrays;
  19007. private _floats;
  19008. private _ints;
  19009. private _floatsArrays;
  19010. private _colors3;
  19011. private _colors3Arrays;
  19012. private _colors4;
  19013. private _vectors2;
  19014. private _vectors3;
  19015. private _vectors4;
  19016. private _matrices;
  19017. private _matrices3x3;
  19018. private _matrices2x2;
  19019. private _vectors2Arrays;
  19020. private _vectors3Arrays;
  19021. private _cachedWorldViewMatrix;
  19022. private _renderId;
  19023. /**
  19024. * Instantiate a new shader material.
  19025. * 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.
  19026. * This returned material effects how the mesh will look based on the code in the shaders.
  19027. * @see http://doc.babylonjs.com/how_to/shader_material
  19028. * @param name Define the name of the material in the scene
  19029. * @param scene Define the scene the material belongs to
  19030. * @param shaderPath Defines the route to the shader code in one of three ways:
  19031. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  19032. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19033. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19034. * @param options Define the options used to create the shader
  19035. */
  19036. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19037. /**
  19038. * Gets the current class name of the material e.g. "ShaderMaterial"
  19039. * Mainly use in serialization.
  19040. * @returns the class name
  19041. */
  19042. getClassName(): string;
  19043. /**
  19044. * Specifies if the material will require alpha blending
  19045. * @returns a boolean specifying if alpha blending is needed
  19046. */
  19047. needAlphaBlending(): boolean;
  19048. /**
  19049. * Specifies if this material should be rendered in alpha test mode
  19050. * @returns a boolean specifying if an alpha test is needed.
  19051. */
  19052. needAlphaTesting(): boolean;
  19053. private _checkUniform;
  19054. /**
  19055. * Set a texture in the shader.
  19056. * @param name Define the name of the uniform samplers as defined in the shader
  19057. * @param texture Define the texture to bind to this sampler
  19058. * @return the material itself allowing "fluent" like uniform updates
  19059. */
  19060. setTexture(name: string, texture: Texture): ShaderMaterial;
  19061. /**
  19062. * Set a texture array in the shader.
  19063. * @param name Define the name of the uniform sampler array as defined in the shader
  19064. * @param textures Define the list of textures to bind to this sampler
  19065. * @return the material itself allowing "fluent" like uniform updates
  19066. */
  19067. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19068. /**
  19069. * Set a float in the shader.
  19070. * @param name Define the name of the uniform as defined in the shader
  19071. * @param value Define the value to give to the uniform
  19072. * @return the material itself allowing "fluent" like uniform updates
  19073. */
  19074. setFloat(name: string, value: number): ShaderMaterial;
  19075. /**
  19076. * Set a int in the shader.
  19077. * @param name Define the name of the uniform as defined in the shader
  19078. * @param value Define the value to give to the uniform
  19079. * @return the material itself allowing "fluent" like uniform updates
  19080. */
  19081. setInt(name: string, value: number): ShaderMaterial;
  19082. /**
  19083. * Set an array of floats in the shader.
  19084. * @param name Define the name of the uniform as defined in the shader
  19085. * @param value Define the value to give to the uniform
  19086. * @return the material itself allowing "fluent" like uniform updates
  19087. */
  19088. setFloats(name: string, value: number[]): ShaderMaterial;
  19089. /**
  19090. * Set a vec3 in the shader from a Color3.
  19091. * @param name Define the name of the uniform as defined in the shader
  19092. * @param value Define the value to give to the uniform
  19093. * @return the material itself allowing "fluent" like uniform updates
  19094. */
  19095. setColor3(name: string, value: Color3): ShaderMaterial;
  19096. /**
  19097. * Set a vec3 array in the shader from a Color3 array.
  19098. * @param name Define the name of the uniform as defined in the shader
  19099. * @param value Define the value to give to the uniform
  19100. * @return the material itself allowing "fluent" like uniform updates
  19101. */
  19102. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19103. /**
  19104. * Set a vec4 in the shader from a Color4.
  19105. * @param name Define the name of the uniform as defined in the shader
  19106. * @param value Define the value to give to the uniform
  19107. * @return the material itself allowing "fluent" like uniform updates
  19108. */
  19109. setColor4(name: string, value: Color4): ShaderMaterial;
  19110. /**
  19111. * Set a vec2 in the shader from a Vector2.
  19112. * @param name Define the name of the uniform as defined in the shader
  19113. * @param value Define the value to give to the uniform
  19114. * @return the material itself allowing "fluent" like uniform updates
  19115. */
  19116. setVector2(name: string, value: Vector2): ShaderMaterial;
  19117. /**
  19118. * Set a vec3 in the shader from a Vector3.
  19119. * @param name Define the name of the uniform as defined in the shader
  19120. * @param value Define the value to give to the uniform
  19121. * @return the material itself allowing "fluent" like uniform updates
  19122. */
  19123. setVector3(name: string, value: Vector3): ShaderMaterial;
  19124. /**
  19125. * Set a vec4 in the shader from a Vector4.
  19126. * @param name Define the name of the uniform as defined in the shader
  19127. * @param value Define the value to give to the uniform
  19128. * @return the material itself allowing "fluent" like uniform updates
  19129. */
  19130. setVector4(name: string, value: Vector4): ShaderMaterial;
  19131. /**
  19132. * Set a mat4 in the shader from a Matrix.
  19133. * @param name Define the name of the uniform as defined in the shader
  19134. * @param value Define the value to give to the uniform
  19135. * @return the material itself allowing "fluent" like uniform updates
  19136. */
  19137. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19138. /**
  19139. * Set a mat3 in the shader from a Float32Array.
  19140. * @param name Define the name of the uniform as defined in the shader
  19141. * @param value Define the value to give to the uniform
  19142. * @return the material itself allowing "fluent" like uniform updates
  19143. */
  19144. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19145. /**
  19146. * Set a mat2 in the shader from a Float32Array.
  19147. * @param name Define the name of the uniform as defined in the shader
  19148. * @param value Define the value to give to the uniform
  19149. * @return the material itself allowing "fluent" like uniform updates
  19150. */
  19151. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19152. /**
  19153. * Set a vec2 array in the shader from a number array.
  19154. * @param name Define the name of the uniform as defined in the shader
  19155. * @param value Define the value to give to the uniform
  19156. * @return the material itself allowing "fluent" like uniform updates
  19157. */
  19158. setArray2(name: string, value: number[]): ShaderMaterial;
  19159. /**
  19160. * Set a vec3 array in the shader from a number array.
  19161. * @param name Define the name of the uniform as defined in the shader
  19162. * @param value Define the value to give to the uniform
  19163. * @return the material itself allowing "fluent" like uniform updates
  19164. */
  19165. setArray3(name: string, value: number[]): ShaderMaterial;
  19166. private _checkCache;
  19167. /**
  19168. * Checks if the material is ready to render the requested mesh
  19169. * @param mesh Define the mesh to render
  19170. * @param useInstances Define whether or not the material is used with instances
  19171. * @returns true if ready, otherwise false
  19172. */
  19173. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19174. /**
  19175. * Binds the world matrix to the material
  19176. * @param world defines the world transformation matrix
  19177. */
  19178. bindOnlyWorldMatrix(world: Matrix): void;
  19179. /**
  19180. * Binds the material to the mesh
  19181. * @param world defines the world transformation matrix
  19182. * @param mesh defines the mesh to bind the material to
  19183. */
  19184. bind(world: Matrix, mesh?: Mesh): void;
  19185. /**
  19186. * Gets the active textures from the material
  19187. * @returns an array of textures
  19188. */
  19189. getActiveTextures(): BaseTexture[];
  19190. /**
  19191. * Specifies if the material uses a texture
  19192. * @param texture defines the texture to check against the material
  19193. * @returns a boolean specifying if the material uses the texture
  19194. */
  19195. hasTexture(texture: BaseTexture): boolean;
  19196. /**
  19197. * Makes a duplicate of the material, and gives it a new name
  19198. * @param name defines the new name for the duplicated material
  19199. * @returns the cloned material
  19200. */
  19201. clone(name: string): ShaderMaterial;
  19202. /**
  19203. * Disposes the material
  19204. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19205. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19206. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19207. */
  19208. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19209. /**
  19210. * Serializes this material in a JSON representation
  19211. * @returns the serialized material object
  19212. */
  19213. serialize(): any;
  19214. /**
  19215. * Creates a shader material from parsed shader material data
  19216. * @param source defines the JSON represnetation of the material
  19217. * @param scene defines the hosting scene
  19218. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19219. * @returns a new material
  19220. */
  19221. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19222. }
  19223. }
  19224. declare module BABYLON {
  19225. /** @hidden */
  19226. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  19227. MAINUV1: boolean;
  19228. MAINUV2: boolean;
  19229. DIFFUSE: boolean;
  19230. DIFFUSEDIRECTUV: number;
  19231. AMBIENT: boolean;
  19232. AMBIENTDIRECTUV: number;
  19233. OPACITY: boolean;
  19234. OPACITYDIRECTUV: number;
  19235. OPACITYRGB: boolean;
  19236. REFLECTION: boolean;
  19237. EMISSIVE: boolean;
  19238. EMISSIVEDIRECTUV: number;
  19239. SPECULAR: boolean;
  19240. SPECULARDIRECTUV: number;
  19241. BUMP: boolean;
  19242. BUMPDIRECTUV: number;
  19243. PARALLAX: boolean;
  19244. PARALLAXOCCLUSION: boolean;
  19245. SPECULAROVERALPHA: boolean;
  19246. CLIPPLANE: boolean;
  19247. CLIPPLANE2: boolean;
  19248. CLIPPLANE3: boolean;
  19249. CLIPPLANE4: boolean;
  19250. ALPHATEST: boolean;
  19251. DEPTHPREPASS: boolean;
  19252. ALPHAFROMDIFFUSE: boolean;
  19253. POINTSIZE: boolean;
  19254. FOG: boolean;
  19255. SPECULARTERM: boolean;
  19256. DIFFUSEFRESNEL: boolean;
  19257. OPACITYFRESNEL: boolean;
  19258. REFLECTIONFRESNEL: boolean;
  19259. REFRACTIONFRESNEL: boolean;
  19260. EMISSIVEFRESNEL: boolean;
  19261. FRESNEL: boolean;
  19262. NORMAL: boolean;
  19263. UV1: boolean;
  19264. UV2: boolean;
  19265. VERTEXCOLOR: boolean;
  19266. VERTEXALPHA: boolean;
  19267. NUM_BONE_INFLUENCERS: number;
  19268. BonesPerMesh: number;
  19269. BONETEXTURE: boolean;
  19270. INSTANCES: boolean;
  19271. GLOSSINESS: boolean;
  19272. ROUGHNESS: boolean;
  19273. EMISSIVEASILLUMINATION: boolean;
  19274. LINKEMISSIVEWITHDIFFUSE: boolean;
  19275. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19276. LIGHTMAP: boolean;
  19277. LIGHTMAPDIRECTUV: number;
  19278. OBJECTSPACE_NORMALMAP: boolean;
  19279. USELIGHTMAPASSHADOWMAP: boolean;
  19280. REFLECTIONMAP_3D: boolean;
  19281. REFLECTIONMAP_SPHERICAL: boolean;
  19282. REFLECTIONMAP_PLANAR: boolean;
  19283. REFLECTIONMAP_CUBIC: boolean;
  19284. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19285. REFLECTIONMAP_PROJECTION: boolean;
  19286. REFLECTIONMAP_SKYBOX: boolean;
  19287. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  19288. REFLECTIONMAP_EXPLICIT: boolean;
  19289. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19290. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19291. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19292. INVERTCUBICMAP: boolean;
  19293. LOGARITHMICDEPTH: boolean;
  19294. REFRACTION: boolean;
  19295. REFRACTIONMAP_3D: boolean;
  19296. REFLECTIONOVERALPHA: boolean;
  19297. TWOSIDEDLIGHTING: boolean;
  19298. SHADOWFLOAT: boolean;
  19299. MORPHTARGETS: boolean;
  19300. MORPHTARGETS_NORMAL: boolean;
  19301. MORPHTARGETS_TANGENT: boolean;
  19302. NUM_MORPH_INFLUENCERS: number;
  19303. NONUNIFORMSCALING: boolean;
  19304. PREMULTIPLYALPHA: boolean;
  19305. IMAGEPROCESSING: boolean;
  19306. VIGNETTE: boolean;
  19307. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19308. VIGNETTEBLENDMODEOPAQUE: boolean;
  19309. TONEMAPPING: boolean;
  19310. TONEMAPPING_ACES: boolean;
  19311. CONTRAST: boolean;
  19312. COLORCURVES: boolean;
  19313. COLORGRADING: boolean;
  19314. COLORGRADING3D: boolean;
  19315. SAMPLER3DGREENDEPTH: boolean;
  19316. SAMPLER3DBGRMAP: boolean;
  19317. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19318. /**
  19319. * If the reflection texture on this material is in linear color space
  19320. * @hidden
  19321. */
  19322. IS_REFLECTION_LINEAR: boolean;
  19323. /**
  19324. * If the refraction texture on this material is in linear color space
  19325. * @hidden
  19326. */
  19327. IS_REFRACTION_LINEAR: boolean;
  19328. EXPOSURE: boolean;
  19329. constructor();
  19330. setReflectionMode(modeToEnable: string): void;
  19331. }
  19332. /**
  19333. * This is the default material used in Babylon. It is the best trade off between quality
  19334. * and performances.
  19335. * @see http://doc.babylonjs.com/babylon101/materials
  19336. */
  19337. class StandardMaterial extends PushMaterial {
  19338. private _diffuseTexture;
  19339. /**
  19340. * The basic texture of the material as viewed under a light.
  19341. */
  19342. diffuseTexture: Nullable<BaseTexture>;
  19343. private _ambientTexture;
  19344. /**
  19345. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19346. */
  19347. ambientTexture: Nullable<BaseTexture>;
  19348. private _opacityTexture;
  19349. /**
  19350. * Define the transparency of the material from a texture.
  19351. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19352. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19353. */
  19354. opacityTexture: Nullable<BaseTexture>;
  19355. private _reflectionTexture;
  19356. /**
  19357. * Define the texture used to display the reflection.
  19358. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19359. */
  19360. reflectionTexture: Nullable<BaseTexture>;
  19361. private _emissiveTexture;
  19362. /**
  19363. * Define texture of the material as if self lit.
  19364. * This will be mixed in the final result even in the absence of light.
  19365. */
  19366. emissiveTexture: Nullable<BaseTexture>;
  19367. private _specularTexture;
  19368. /**
  19369. * Define how the color and intensity of the highlight given by the light in the material.
  19370. */
  19371. specularTexture: Nullable<BaseTexture>;
  19372. private _bumpTexture;
  19373. /**
  19374. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19375. * 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.
  19376. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  19377. */
  19378. bumpTexture: Nullable<BaseTexture>;
  19379. private _lightmapTexture;
  19380. /**
  19381. * Complex lighting can be computationally expensive to compute at runtime.
  19382. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19383. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  19384. */
  19385. lightmapTexture: Nullable<BaseTexture>;
  19386. private _refractionTexture;
  19387. /**
  19388. * Define the texture used to display the refraction.
  19389. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19390. */
  19391. refractionTexture: Nullable<BaseTexture>;
  19392. /**
  19393. * The color of the material lit by the environmental background lighting.
  19394. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19395. */
  19396. ambientColor: Color3;
  19397. /**
  19398. * The basic color of the material as viewed under a light.
  19399. */
  19400. diffuseColor: Color3;
  19401. /**
  19402. * Define how the color and intensity of the highlight given by the light in the material.
  19403. */
  19404. specularColor: Color3;
  19405. /**
  19406. * Define the color of the material as if self lit.
  19407. * This will be mixed in the final result even in the absence of light.
  19408. */
  19409. emissiveColor: Color3;
  19410. /**
  19411. * Defines how sharp are the highlights in the material.
  19412. * The bigger the value the sharper giving a more glossy feeling to the result.
  19413. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19414. */
  19415. specularPower: number;
  19416. private _useAlphaFromDiffuseTexture;
  19417. /**
  19418. * Does the transparency come from the diffuse texture alpha channel.
  19419. */
  19420. useAlphaFromDiffuseTexture: boolean;
  19421. private _useEmissiveAsIllumination;
  19422. /**
  19423. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19424. */
  19425. useEmissiveAsIllumination: boolean;
  19426. private _linkEmissiveWithDiffuse;
  19427. /**
  19428. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19429. * the emissive level when the final color is close to one.
  19430. */
  19431. linkEmissiveWithDiffuse: boolean;
  19432. private _useSpecularOverAlpha;
  19433. /**
  19434. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19435. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19436. */
  19437. useSpecularOverAlpha: boolean;
  19438. private _useReflectionOverAlpha;
  19439. /**
  19440. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19441. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19442. */
  19443. useReflectionOverAlpha: boolean;
  19444. private _disableLighting;
  19445. /**
  19446. * Does lights from the scene impacts this material.
  19447. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19448. */
  19449. disableLighting: boolean;
  19450. private _useObjectSpaceNormalMap;
  19451. /**
  19452. * Allows using an object space normal map (instead of tangent space).
  19453. */
  19454. useObjectSpaceNormalMap: boolean;
  19455. private _useParallax;
  19456. /**
  19457. * Is parallax enabled or not.
  19458. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19459. */
  19460. useParallax: boolean;
  19461. private _useParallaxOcclusion;
  19462. /**
  19463. * Is parallax occlusion enabled or not.
  19464. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19465. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19466. */
  19467. useParallaxOcclusion: boolean;
  19468. /**
  19469. * 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.
  19470. */
  19471. parallaxScaleBias: number;
  19472. private _roughness;
  19473. /**
  19474. * Helps to define how blurry the reflections should appears in the material.
  19475. */
  19476. roughness: number;
  19477. /**
  19478. * In case of refraction, define the value of the indice of refraction.
  19479. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19480. */
  19481. indexOfRefraction: number;
  19482. /**
  19483. * Invert the refraction texture alongside the y axis.
  19484. * It can be useful with procedural textures or probe for instance.
  19485. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19486. */
  19487. invertRefractionY: boolean;
  19488. /**
  19489. * Defines the alpha limits in alpha test mode.
  19490. */
  19491. alphaCutOff: number;
  19492. private _useLightmapAsShadowmap;
  19493. /**
  19494. * In case of light mapping, define whether the map contains light or shadow informations.
  19495. */
  19496. useLightmapAsShadowmap: boolean;
  19497. private _diffuseFresnelParameters;
  19498. /**
  19499. * Define the diffuse fresnel parameters of the material.
  19500. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19501. */
  19502. diffuseFresnelParameters: FresnelParameters;
  19503. private _opacityFresnelParameters;
  19504. /**
  19505. * Define the opacity fresnel parameters of the material.
  19506. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19507. */
  19508. opacityFresnelParameters: FresnelParameters;
  19509. private _reflectionFresnelParameters;
  19510. /**
  19511. * Define the reflection fresnel parameters of the material.
  19512. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19513. */
  19514. reflectionFresnelParameters: FresnelParameters;
  19515. private _refractionFresnelParameters;
  19516. /**
  19517. * Define the refraction fresnel parameters of the material.
  19518. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19519. */
  19520. refractionFresnelParameters: FresnelParameters;
  19521. private _emissiveFresnelParameters;
  19522. /**
  19523. * Define the emissive fresnel parameters of the material.
  19524. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19525. */
  19526. emissiveFresnelParameters: FresnelParameters;
  19527. private _useReflectionFresnelFromSpecular;
  19528. /**
  19529. * If true automatically deducts the fresnels values from the material specularity.
  19530. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19531. */
  19532. useReflectionFresnelFromSpecular: boolean;
  19533. private _useGlossinessFromSpecularMapAlpha;
  19534. /**
  19535. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19536. */
  19537. useGlossinessFromSpecularMapAlpha: boolean;
  19538. private _maxSimultaneousLights;
  19539. /**
  19540. * Defines the maximum number of lights that can be used in the material
  19541. */
  19542. maxSimultaneousLights: number;
  19543. private _invertNormalMapX;
  19544. /**
  19545. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19546. */
  19547. invertNormalMapX: boolean;
  19548. private _invertNormalMapY;
  19549. /**
  19550. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19551. */
  19552. invertNormalMapY: boolean;
  19553. private _twoSidedLighting;
  19554. /**
  19555. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19556. */
  19557. twoSidedLighting: boolean;
  19558. /**
  19559. * Default configuration related to image processing available in the standard Material.
  19560. */
  19561. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19562. /**
  19563. * Gets the image processing configuration used either in this material.
  19564. */
  19565. /**
  19566. * Sets the Default image processing configuration used either in the this material.
  19567. *
  19568. * If sets to null, the scene one is in use.
  19569. */
  19570. imageProcessingConfiguration: ImageProcessingConfiguration;
  19571. /**
  19572. * Keep track of the image processing observer to allow dispose and replace.
  19573. */
  19574. private _imageProcessingObserver;
  19575. /**
  19576. * Attaches a new image processing configuration to the Standard Material.
  19577. * @param configuration
  19578. */
  19579. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19580. /**
  19581. * Gets wether the color curves effect is enabled.
  19582. */
  19583. /**
  19584. * Sets wether the color curves effect is enabled.
  19585. */
  19586. cameraColorCurvesEnabled: boolean;
  19587. /**
  19588. * Gets wether the color grading effect is enabled.
  19589. */
  19590. /**
  19591. * Gets wether the color grading effect is enabled.
  19592. */
  19593. cameraColorGradingEnabled: boolean;
  19594. /**
  19595. * Gets wether tonemapping is enabled or not.
  19596. */
  19597. /**
  19598. * Sets wether tonemapping is enabled or not
  19599. */
  19600. cameraToneMappingEnabled: boolean;
  19601. /**
  19602. * The camera exposure used on this material.
  19603. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19604. * This corresponds to a photographic exposure.
  19605. */
  19606. /**
  19607. * The camera exposure used on this material.
  19608. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19609. * This corresponds to a photographic exposure.
  19610. */
  19611. cameraExposure: number;
  19612. /**
  19613. * Gets The camera contrast used on this material.
  19614. */
  19615. /**
  19616. * Sets The camera contrast used on this material.
  19617. */
  19618. cameraContrast: number;
  19619. /**
  19620. * Gets the Color Grading 2D Lookup Texture.
  19621. */
  19622. /**
  19623. * Sets the Color Grading 2D Lookup Texture.
  19624. */
  19625. cameraColorGradingTexture: Nullable<BaseTexture>;
  19626. /**
  19627. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19628. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19629. * 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;
  19630. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19631. */
  19632. /**
  19633. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19634. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19635. * 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;
  19636. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19637. */
  19638. cameraColorCurves: Nullable<ColorCurves>;
  19639. /**
  19640. * Custom callback helping to override the default shader used in the material.
  19641. */
  19642. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  19643. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19644. protected _worldViewProjectionMatrix: Matrix;
  19645. protected _globalAmbientColor: Color3;
  19646. protected _useLogarithmicDepth: boolean;
  19647. /**
  19648. * Instantiates a new standard material.
  19649. * This is the default material used in Babylon. It is the best trade off between quality
  19650. * and performances.
  19651. * @see http://doc.babylonjs.com/babylon101/materials
  19652. * @param name Define the name of the material in the scene
  19653. * @param scene Define the scene the material belong to
  19654. */
  19655. constructor(name: string, scene: Scene);
  19656. /**
  19657. * Gets a boolean indicating that current material needs to register RTT
  19658. */
  19659. readonly hasRenderTargetTextures: boolean;
  19660. /**
  19661. * Gets the current class name of the material e.g. "StandardMaterial"
  19662. * Mainly use in serialization.
  19663. * @returns the class name
  19664. */
  19665. getClassName(): string;
  19666. /**
  19667. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19668. * You can try switching to logarithmic depth.
  19669. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19670. */
  19671. useLogarithmicDepth: boolean;
  19672. /**
  19673. * Specifies if the material will require alpha blending
  19674. * @returns a boolean specifying if alpha blending is needed
  19675. */
  19676. needAlphaBlending(): boolean;
  19677. /**
  19678. * Specifies if this material should be rendered in alpha test mode
  19679. * @returns a boolean specifying if an alpha test is needed.
  19680. */
  19681. needAlphaTesting(): boolean;
  19682. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19683. /**
  19684. * Get the texture used for alpha test purpose.
  19685. * @returns the diffuse texture in case of the standard material.
  19686. */
  19687. getAlphaTestTexture(): Nullable<BaseTexture>;
  19688. /**
  19689. * Get if the submesh is ready to be used and all its information available.
  19690. * Child classes can use it to update shaders
  19691. * @param mesh defines the mesh to check
  19692. * @param subMesh defines which submesh to check
  19693. * @param useInstances specifies that instances should be used
  19694. * @returns a boolean indicating that the submesh is ready or not
  19695. */
  19696. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19697. /**
  19698. * Builds the material UBO layouts.
  19699. * Used internally during the effect preparation.
  19700. */
  19701. buildUniformLayout(): void;
  19702. /**
  19703. * Unbinds the material from the mesh
  19704. */
  19705. unbind(): void;
  19706. /**
  19707. * Binds the submesh to this material by preparing the effect and shader to draw
  19708. * @param world defines the world transformation matrix
  19709. * @param mesh defines the mesh containing the submesh
  19710. * @param subMesh defines the submesh to bind the material to
  19711. */
  19712. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19713. /**
  19714. * Get the list of animatables in the material.
  19715. * @returns the list of animatables object used in the material
  19716. */
  19717. getAnimatables(): IAnimatable[];
  19718. /**
  19719. * Gets the active textures from the material
  19720. * @returns an array of textures
  19721. */
  19722. getActiveTextures(): BaseTexture[];
  19723. /**
  19724. * Specifies if the material uses a texture
  19725. * @param texture defines the texture to check against the material
  19726. * @returns a boolean specifying if the material uses the texture
  19727. */
  19728. hasTexture(texture: BaseTexture): boolean;
  19729. /**
  19730. * Disposes the material
  19731. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19732. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19733. */
  19734. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19735. /**
  19736. * Makes a duplicate of the material, and gives it a new name
  19737. * @param name defines the new name for the duplicated material
  19738. * @returns the cloned material
  19739. */
  19740. clone(name: string): StandardMaterial;
  19741. /**
  19742. * Serializes this material in a JSON representation
  19743. * @returns the serialized material object
  19744. */
  19745. serialize(): any;
  19746. /**
  19747. * Creates a standard material from parsed material data
  19748. * @param source defines the JSON represnetation of the material
  19749. * @param scene defines the hosting scene
  19750. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19751. * @returns a new material
  19752. */
  19753. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19754. private static _DiffuseTextureEnabled;
  19755. /**
  19756. * Are diffuse textures enabled in the application.
  19757. */
  19758. static DiffuseTextureEnabled: boolean;
  19759. private static _AmbientTextureEnabled;
  19760. /**
  19761. * Are ambient textures enabled in the application.
  19762. */
  19763. static AmbientTextureEnabled: boolean;
  19764. private static _OpacityTextureEnabled;
  19765. /**
  19766. * Are opacity textures enabled in the application.
  19767. */
  19768. static OpacityTextureEnabled: boolean;
  19769. private static _ReflectionTextureEnabled;
  19770. /**
  19771. * Are reflection textures enabled in the application.
  19772. */
  19773. static ReflectionTextureEnabled: boolean;
  19774. private static _EmissiveTextureEnabled;
  19775. /**
  19776. * Are emissive textures enabled in the application.
  19777. */
  19778. static EmissiveTextureEnabled: boolean;
  19779. private static _SpecularTextureEnabled;
  19780. /**
  19781. * Are specular textures enabled in the application.
  19782. */
  19783. static SpecularTextureEnabled: boolean;
  19784. private static _BumpTextureEnabled;
  19785. /**
  19786. * Are bump textures enabled in the application.
  19787. */
  19788. static BumpTextureEnabled: boolean;
  19789. private static _LightmapTextureEnabled;
  19790. /**
  19791. * Are lightmap textures enabled in the application.
  19792. */
  19793. static LightmapTextureEnabled: boolean;
  19794. private static _RefractionTextureEnabled;
  19795. /**
  19796. * Are refraction textures enabled in the application.
  19797. */
  19798. static RefractionTextureEnabled: boolean;
  19799. private static _ColorGradingTextureEnabled;
  19800. /**
  19801. * Are color grading textures enabled in the application.
  19802. */
  19803. static ColorGradingTextureEnabled: boolean;
  19804. private static _FresnelEnabled;
  19805. /**
  19806. * Are fresnels enabled in the application.
  19807. */
  19808. static FresnelEnabled: boolean;
  19809. }
  19810. }
  19811. declare module BABYLON {
  19812. /**
  19813. * Uniform buffer objects.
  19814. *
  19815. * Handles blocks of uniform on the GPU.
  19816. *
  19817. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19818. *
  19819. * For more information, please refer to :
  19820. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19821. */
  19822. class UniformBuffer {
  19823. private _engine;
  19824. private _buffer;
  19825. private _data;
  19826. private _bufferData;
  19827. private _dynamic?;
  19828. private _uniformLocations;
  19829. private _uniformSizes;
  19830. private _uniformLocationPointer;
  19831. private _needSync;
  19832. private _noUBO;
  19833. private _currentEffect;
  19834. private static _MAX_UNIFORM_SIZE;
  19835. private static _tempBuffer;
  19836. /**
  19837. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  19838. * This is dynamic to allow compat with webgl 1 and 2.
  19839. * You will need to pass the name of the uniform as well as the value.
  19840. */
  19841. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  19842. /**
  19843. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  19844. * This is dynamic to allow compat with webgl 1 and 2.
  19845. * You will need to pass the name of the uniform as well as the value.
  19846. */
  19847. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  19848. /**
  19849. * Lambda to Update a single float in a uniform buffer.
  19850. * This is dynamic to allow compat with webgl 1 and 2.
  19851. * You will need to pass the name of the uniform as well as the value.
  19852. */
  19853. updateFloat: (name: string, x: number) => void;
  19854. /**
  19855. * Lambda to Update a vec2 of float in a uniform buffer.
  19856. * This is dynamic to allow compat with webgl 1 and 2.
  19857. * You will need to pass the name of the uniform as well as the value.
  19858. */
  19859. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  19860. /**
  19861. * Lambda to Update a vec3 of float in a uniform buffer.
  19862. * This is dynamic to allow compat with webgl 1 and 2.
  19863. * You will need to pass the name of the uniform as well as the value.
  19864. */
  19865. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  19866. /**
  19867. * Lambda to Update a vec4 of float in a uniform buffer.
  19868. * This is dynamic to allow compat with webgl 1 and 2.
  19869. * You will need to pass the name of the uniform as well as the value.
  19870. */
  19871. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  19872. /**
  19873. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  19874. * This is dynamic to allow compat with webgl 1 and 2.
  19875. * You will need to pass the name of the uniform as well as the value.
  19876. */
  19877. updateMatrix: (name: string, mat: Matrix) => void;
  19878. /**
  19879. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  19880. * This is dynamic to allow compat with webgl 1 and 2.
  19881. * You will need to pass the name of the uniform as well as the value.
  19882. */
  19883. updateVector3: (name: string, vector: Vector3) => void;
  19884. /**
  19885. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  19886. * This is dynamic to allow compat with webgl 1 and 2.
  19887. * You will need to pass the name of the uniform as well as the value.
  19888. */
  19889. updateVector4: (name: string, vector: Vector4) => void;
  19890. /**
  19891. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  19892. * This is dynamic to allow compat with webgl 1 and 2.
  19893. * You will need to pass the name of the uniform as well as the value.
  19894. */
  19895. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  19896. /**
  19897. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  19898. * This is dynamic to allow compat with webgl 1 and 2.
  19899. * You will need to pass the name of the uniform as well as the value.
  19900. */
  19901. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  19902. /**
  19903. * Instantiates a new Uniform buffer objects.
  19904. *
  19905. * Handles blocks of uniform on the GPU.
  19906. *
  19907. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19908. *
  19909. * For more information, please refer to :
  19910. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19911. * @param engine Define the engine the buffer is associated with
  19912. * @param data Define the data contained in the buffer
  19913. * @param dynamic Define if the buffer is updatable
  19914. */
  19915. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  19916. /**
  19917. * Indicates if the buffer is using the WebGL2 UBO implementation,
  19918. * or just falling back on setUniformXXX calls.
  19919. */
  19920. readonly useUbo: boolean;
  19921. /**
  19922. * Indicates if the WebGL underlying uniform buffer is in sync
  19923. * with the javascript cache data.
  19924. */
  19925. readonly isSync: boolean;
  19926. /**
  19927. * Indicates if the WebGL underlying uniform buffer is dynamic.
  19928. * Also, a dynamic UniformBuffer will disable cache verification and always
  19929. * update the underlying WebGL uniform buffer to the GPU.
  19930. * @returns if Dynamic, otherwise false
  19931. */
  19932. isDynamic(): boolean;
  19933. /**
  19934. * The data cache on JS side.
  19935. * @returns the underlying data as a float array
  19936. */
  19937. getData(): Float32Array;
  19938. /**
  19939. * The underlying WebGL Uniform buffer.
  19940. * @returns the webgl buffer
  19941. */
  19942. getBuffer(): Nullable<WebGLBuffer>;
  19943. /**
  19944. * std140 layout specifies how to align data within an UBO structure.
  19945. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  19946. * for specs.
  19947. */
  19948. private _fillAlignment;
  19949. /**
  19950. * Adds an uniform in the buffer.
  19951. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  19952. * for the layout to be correct !
  19953. * @param name Name of the uniform, as used in the uniform block in the shader.
  19954. * @param size Data size, or data directly.
  19955. */
  19956. addUniform(name: string, size: number | number[]): void;
  19957. /**
  19958. * Adds a Matrix 4x4 to the uniform buffer.
  19959. * @param name Name of the uniform, as used in the uniform block in the shader.
  19960. * @param mat A 4x4 matrix.
  19961. */
  19962. addMatrix(name: string, mat: Matrix): void;
  19963. /**
  19964. * Adds a vec2 to the uniform buffer.
  19965. * @param name Name of the uniform, as used in the uniform block in the shader.
  19966. * @param x Define the x component value of the vec2
  19967. * @param y Define the y component value of the vec2
  19968. */
  19969. addFloat2(name: string, x: number, y: number): void;
  19970. /**
  19971. * Adds a vec3 to the uniform buffer.
  19972. * @param name Name of the uniform, as used in the uniform block in the shader.
  19973. * @param x Define the x component value of the vec3
  19974. * @param y Define the y component value of the vec3
  19975. * @param z Define the z component value of the vec3
  19976. */
  19977. addFloat3(name: string, x: number, y: number, z: number): void;
  19978. /**
  19979. * Adds a vec3 to the uniform buffer.
  19980. * @param name Name of the uniform, as used in the uniform block in the shader.
  19981. * @param color Define the vec3 from a Color
  19982. */
  19983. addColor3(name: string, color: Color3): void;
  19984. /**
  19985. * Adds a vec4 to the uniform buffer.
  19986. * @param name Name of the uniform, as used in the uniform block in the shader.
  19987. * @param color Define the rgb components from a Color
  19988. * @param alpha Define the a component of the vec4
  19989. */
  19990. addColor4(name: string, color: Color3, alpha: number): void;
  19991. /**
  19992. * Adds a vec3 to the uniform buffer.
  19993. * @param name Name of the uniform, as used in the uniform block in the shader.
  19994. * @param vector Define the vec3 components from a Vector
  19995. */
  19996. addVector3(name: string, vector: Vector3): void;
  19997. /**
  19998. * Adds a Matrix 3x3 to the uniform buffer.
  19999. * @param name Name of the uniform, as used in the uniform block in the shader.
  20000. */
  20001. addMatrix3x3(name: string): void;
  20002. /**
  20003. * Adds a Matrix 2x2 to the uniform buffer.
  20004. * @param name Name of the uniform, as used in the uniform block in the shader.
  20005. */
  20006. addMatrix2x2(name: string): void;
  20007. /**
  20008. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  20009. */
  20010. create(): void;
  20011. /** @hidden */
  20012. _rebuild(): void;
  20013. /**
  20014. * Updates the WebGL Uniform Buffer on the GPU.
  20015. * If the `dynamic` flag is set to true, no cache comparison is done.
  20016. * Otherwise, the buffer will be updated only if the cache differs.
  20017. */
  20018. update(): void;
  20019. /**
  20020. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  20021. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  20022. * @param data Define the flattened data
  20023. * @param size Define the size of the data.
  20024. */
  20025. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  20026. private _updateMatrix3x3ForUniform;
  20027. private _updateMatrix3x3ForEffect;
  20028. private _updateMatrix2x2ForEffect;
  20029. private _updateMatrix2x2ForUniform;
  20030. private _updateFloatForEffect;
  20031. private _updateFloatForUniform;
  20032. private _updateFloat2ForEffect;
  20033. private _updateFloat2ForUniform;
  20034. private _updateFloat3ForEffect;
  20035. private _updateFloat3ForUniform;
  20036. private _updateFloat4ForEffect;
  20037. private _updateFloat4ForUniform;
  20038. private _updateMatrixForEffect;
  20039. private _updateMatrixForUniform;
  20040. private _updateVector3ForEffect;
  20041. private _updateVector3ForUniform;
  20042. private _updateVector4ForEffect;
  20043. private _updateVector4ForUniform;
  20044. private _updateColor3ForEffect;
  20045. private _updateColor3ForUniform;
  20046. private _updateColor4ForEffect;
  20047. private _updateColor4ForUniform;
  20048. /**
  20049. * Sets a sampler uniform on the effect.
  20050. * @param name Define the name of the sampler.
  20051. * @param texture Define the texture to set in the sampler
  20052. */
  20053. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  20054. /**
  20055. * Directly updates the value of the uniform in the cache AND on the GPU.
  20056. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  20057. * @param data Define the flattened data
  20058. */
  20059. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  20060. /**
  20061. * Binds this uniform buffer to an effect.
  20062. * @param effect Define the effect to bind the buffer to
  20063. * @param name Name of the uniform block in the shader.
  20064. */
  20065. bindToEffect(effect: Effect, name: string): void;
  20066. /**
  20067. * Disposes the uniform buffer.
  20068. */
  20069. dispose(): void;
  20070. }
  20071. }
  20072. declare module BABYLON {
  20073. /**
  20074. * Scalar computation library
  20075. */
  20076. class Scalar {
  20077. /**
  20078. * Two pi constants convenient for computation.
  20079. */
  20080. static TwoPi: number;
  20081. /**
  20082. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  20083. * @param a number
  20084. * @param b number
  20085. * @param epsilon (default = 1.401298E-45)
  20086. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  20087. */
  20088. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  20089. /**
  20090. * Returns a string : the upper case translation of the number i to hexadecimal.
  20091. * @param i number
  20092. * @returns the upper case translation of the number i to hexadecimal.
  20093. */
  20094. static ToHex(i: number): string;
  20095. /**
  20096. * Returns -1 if value is negative and +1 is value is positive.
  20097. * @param value the value
  20098. * @returns the value itself if it's equal to zero.
  20099. */
  20100. static Sign(value: number): number;
  20101. /**
  20102. * Returns the value itself if it's between min and max.
  20103. * Returns min if the value is lower than min.
  20104. * Returns max if the value is greater than max.
  20105. * @param value the value to clmap
  20106. * @param min the min value to clamp to (default: 0)
  20107. * @param max the max value to clamp to (default: 1)
  20108. * @returns the clamped value
  20109. */
  20110. static Clamp(value: number, min?: number, max?: number): number;
  20111. /**
  20112. * the log2 of value.
  20113. * @param value the value to compute log2 of
  20114. * @returns the log2 of value.
  20115. */
  20116. static Log2(value: number): number;
  20117. /**
  20118. * Loops the value, so that it is never larger than length and never smaller than 0.
  20119. *
  20120. * This is similar to the modulo operator but it works with floating point numbers.
  20121. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  20122. * With t = 5 and length = 2.5, the result would be 0.0.
  20123. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  20124. * @param value the value
  20125. * @param length the length
  20126. * @returns the looped value
  20127. */
  20128. static Repeat(value: number, length: number): number;
  20129. /**
  20130. * Normalize the value between 0.0 and 1.0 using min and max values
  20131. * @param value value to normalize
  20132. * @param min max to normalize between
  20133. * @param max min to normalize between
  20134. * @returns the normalized value
  20135. */
  20136. static Normalize(value: number, min: number, max: number): number;
  20137. /**
  20138. * Denormalize the value from 0.0 and 1.0 using min and max values
  20139. * @param normalized value to denormalize
  20140. * @param min max to denormalize between
  20141. * @param max min to denormalize between
  20142. * @returns the denormalized value
  20143. */
  20144. static Denormalize(normalized: number, min: number, max: number): number;
  20145. /**
  20146. * Calculates the shortest difference between two given angles given in degrees.
  20147. * @param current current angle in degrees
  20148. * @param target target angle in degrees
  20149. * @returns the delta
  20150. */
  20151. static DeltaAngle(current: number, target: number): number;
  20152. /**
  20153. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  20154. * @param tx value
  20155. * @param length length
  20156. * @returns The returned value will move back and forth between 0 and length
  20157. */
  20158. static PingPong(tx: number, length: number): number;
  20159. /**
  20160. * Interpolates between min and max with smoothing at the limits.
  20161. *
  20162. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  20163. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  20164. * @param from from
  20165. * @param to to
  20166. * @param tx value
  20167. * @returns the smooth stepped value
  20168. */
  20169. static SmoothStep(from: number, to: number, tx: number): number;
  20170. /**
  20171. * Moves a value current towards target.
  20172. *
  20173. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  20174. * Negative values of maxDelta pushes the value away from target.
  20175. * @param current current value
  20176. * @param target target value
  20177. * @param maxDelta max distance to move
  20178. * @returns resulting value
  20179. */
  20180. static MoveTowards(current: number, target: number, maxDelta: number): number;
  20181. /**
  20182. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  20183. *
  20184. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  20185. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  20186. * @param current current value
  20187. * @param target target value
  20188. * @param maxDelta max distance to move
  20189. * @returns resulting angle
  20190. */
  20191. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  20192. /**
  20193. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  20194. * @param start start value
  20195. * @param end target value
  20196. * @param amount amount to lerp between
  20197. * @returns the lerped value
  20198. */
  20199. static Lerp(start: number, end: number, amount: number): number;
  20200. /**
  20201. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  20202. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  20203. * @param start start value
  20204. * @param end target value
  20205. * @param amount amount to lerp between
  20206. * @returns the lerped value
  20207. */
  20208. static LerpAngle(start: number, end: number, amount: number): number;
  20209. /**
  20210. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  20211. * @param a start value
  20212. * @param b target value
  20213. * @param value value between a and b
  20214. * @returns the inverseLerp value
  20215. */
  20216. static InverseLerp(a: number, b: number, value: number): number;
  20217. /**
  20218. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  20219. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  20220. * @param value1 spline value
  20221. * @param tangent1 spline value
  20222. * @param value2 spline value
  20223. * @param tangent2 spline value
  20224. * @param amount input value
  20225. * @returns hermite result
  20226. */
  20227. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  20228. /**
  20229. * Returns a random float number between and min and max values
  20230. * @param min min value of random
  20231. * @param max max value of random
  20232. * @returns random value
  20233. */
  20234. static RandomRange(min: number, max: number): number;
  20235. /**
  20236. * This function returns percentage of a number in a given range.
  20237. *
  20238. * RangeToPercent(40,20,60) will return 0.5 (50%)
  20239. * RangeToPercent(34,0,100) will return 0.34 (34%)
  20240. * @param number to convert to percentage
  20241. * @param min min range
  20242. * @param max max range
  20243. * @returns the percentage
  20244. */
  20245. static RangeToPercent(number: number, min: number, max: number): number;
  20246. /**
  20247. * This function returns number that corresponds to the percentage in a given range.
  20248. *
  20249. * PercentToRange(0.34,0,100) will return 34.
  20250. * @param percent to convert to number
  20251. * @param min min range
  20252. * @param max max range
  20253. * @returns the number
  20254. */
  20255. static PercentToRange(percent: number, min: number, max: number): number;
  20256. /**
  20257. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  20258. * @param angle The angle to normalize in radian.
  20259. * @return The converted angle.
  20260. */
  20261. static NormalizeRadians(angle: number): number;
  20262. }
  20263. }
  20264. declare module BABYLON {
  20265. /**
  20266. * Constant used to convert a value to gamma space
  20267. * @ignorenaming
  20268. */
  20269. const ToGammaSpace: number;
  20270. /**
  20271. * Constant used to convert a value to linear space
  20272. * @ignorenaming
  20273. */
  20274. const ToLinearSpace = 2.2;
  20275. /**
  20276. * Constant used to define the minimal number value in Babylon.js
  20277. * @ignorenaming
  20278. */
  20279. const Epsilon = 0.001;
  20280. /**
  20281. * Class used to hold a RBG color
  20282. */
  20283. class Color3 {
  20284. /**
  20285. * Defines the red component (between 0 and 1, default is 0)
  20286. */
  20287. r: number;
  20288. /**
  20289. * Defines the green component (between 0 and 1, default is 0)
  20290. */
  20291. g: number;
  20292. /**
  20293. * Defines the blue component (between 0 and 1, default is 0)
  20294. */
  20295. b: number;
  20296. /**
  20297. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  20298. * @param r defines the red component (between 0 and 1, default is 0)
  20299. * @param g defines the green component (between 0 and 1, default is 0)
  20300. * @param b defines the blue component (between 0 and 1, default is 0)
  20301. */
  20302. constructor(
  20303. /**
  20304. * Defines the red component (between 0 and 1, default is 0)
  20305. */
  20306. r?: number,
  20307. /**
  20308. * Defines the green component (between 0 and 1, default is 0)
  20309. */
  20310. g?: number,
  20311. /**
  20312. * Defines the blue component (between 0 and 1, default is 0)
  20313. */
  20314. b?: number);
  20315. /**
  20316. * Creates a string with the Color3 current values
  20317. * @returns the string representation of the Color3 object
  20318. */
  20319. toString(): string;
  20320. /**
  20321. * Returns the string "Color3"
  20322. * @returns "Color3"
  20323. */
  20324. getClassName(): string;
  20325. /**
  20326. * Compute the Color3 hash code
  20327. * @returns an unique number that can be used to hash Color3 objects
  20328. */
  20329. getHashCode(): number;
  20330. /**
  20331. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  20332. * @param array defines the array where to store the r,g,b components
  20333. * @param index defines an optional index in the target array to define where to start storing values
  20334. * @returns the current Color3 object
  20335. */
  20336. toArray(array: FloatArray, index?: number): Color3;
  20337. /**
  20338. * Returns a new Color4 object from the current Color3 and the given alpha
  20339. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  20340. * @returns a new Color4 object
  20341. */
  20342. toColor4(alpha?: number): Color4;
  20343. /**
  20344. * Returns a new array populated with 3 numeric elements : red, green and blue values
  20345. * @returns the new array
  20346. */
  20347. asArray(): number[];
  20348. /**
  20349. * Returns the luminance value
  20350. * @returns a float value
  20351. */
  20352. toLuminance(): number;
  20353. /**
  20354. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  20355. * @param otherColor defines the second operand
  20356. * @returns the new Color3 object
  20357. */
  20358. multiply(otherColor: DeepImmutable<Color3>): Color3;
  20359. /**
  20360. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  20361. * @param otherColor defines the second operand
  20362. * @param result defines the Color3 object where to store the result
  20363. * @returns the current Color3
  20364. */
  20365. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20366. /**
  20367. * Determines equality between Color3 objects
  20368. * @param otherColor defines the second operand
  20369. * @returns true if the rgb values are equal to the given ones
  20370. */
  20371. equals(otherColor: DeepImmutable<Color3>): boolean;
  20372. /**
  20373. * Determines equality between the current Color3 object and a set of r,b,g values
  20374. * @param r defines the red component to check
  20375. * @param g defines the green component to check
  20376. * @param b defines the blue component to check
  20377. * @returns true if the rgb values are equal to the given ones
  20378. */
  20379. equalsFloats(r: number, g: number, b: number): boolean;
  20380. /**
  20381. * Multiplies in place each rgb value by scale
  20382. * @param scale defines the scaling factor
  20383. * @returns the updated Color3
  20384. */
  20385. scale(scale: number): Color3;
  20386. /**
  20387. * Multiplies the rgb values by scale and stores the result into "result"
  20388. * @param scale defines the scaling factor
  20389. * @param result defines the Color3 object where to store the result
  20390. * @returns the unmodified current Color3
  20391. */
  20392. scaleToRef(scale: number, result: Color3): Color3;
  20393. /**
  20394. * Scale the current Color3 values by a factor and add the result to a given Color3
  20395. * @param scale defines the scale factor
  20396. * @param result defines color to store the result into
  20397. * @returns the unmodified current Color3
  20398. */
  20399. scaleAndAddToRef(scale: number, result: Color3): Color3;
  20400. /**
  20401. * Clamps the rgb values by the min and max values and stores the result into "result"
  20402. * @param min defines minimum clamping value (default is 0)
  20403. * @param max defines maximum clamping value (default is 1)
  20404. * @param result defines color to store the result into
  20405. * @returns the original Color3
  20406. */
  20407. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  20408. /**
  20409. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  20410. * @param otherColor defines the second operand
  20411. * @returns the new Color3
  20412. */
  20413. add(otherColor: DeepImmutable<Color3>): Color3;
  20414. /**
  20415. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  20416. * @param otherColor defines the second operand
  20417. * @param result defines Color3 object to store the result into
  20418. * @returns the unmodified current Color3
  20419. */
  20420. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20421. /**
  20422. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  20423. * @param otherColor defines the second operand
  20424. * @returns the new Color3
  20425. */
  20426. subtract(otherColor: DeepImmutable<Color3>): Color3;
  20427. /**
  20428. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  20429. * @param otherColor defines the second operand
  20430. * @param result defines Color3 object to store the result into
  20431. * @returns the unmodified current Color3
  20432. */
  20433. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20434. /**
  20435. * Copy the current object
  20436. * @returns a new Color3 copied the current one
  20437. */
  20438. clone(): Color3;
  20439. /**
  20440. * Copies the rgb values from the source in the current Color3
  20441. * @param source defines the source Color3 object
  20442. * @returns the updated Color3 object
  20443. */
  20444. copyFrom(source: DeepImmutable<Color3>): Color3;
  20445. /**
  20446. * Updates the Color3 rgb values from the given floats
  20447. * @param r defines the red component to read from
  20448. * @param g defines the green component to read from
  20449. * @param b defines the blue component to read from
  20450. * @returns the current Color3 object
  20451. */
  20452. copyFromFloats(r: number, g: number, b: number): Color3;
  20453. /**
  20454. * Updates the Color3 rgb values from the given floats
  20455. * @param r defines the red component to read from
  20456. * @param g defines the green component to read from
  20457. * @param b defines the blue component to read from
  20458. * @returns the current Color3 object
  20459. */
  20460. set(r: number, g: number, b: number): Color3;
  20461. /**
  20462. * Compute the Color3 hexadecimal code as a string
  20463. * @returns a string containing the hexadecimal representation of the Color3 object
  20464. */
  20465. toHexString(): string;
  20466. /**
  20467. * Computes a new Color3 converted from the current one to linear space
  20468. * @returns a new Color3 object
  20469. */
  20470. toLinearSpace(): Color3;
  20471. /**
  20472. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  20473. * @param convertedColor defines the Color3 object where to store the linear space version
  20474. * @returns the unmodified Color3
  20475. */
  20476. toLinearSpaceToRef(convertedColor: Color3): Color3;
  20477. /**
  20478. * Computes a new Color3 converted from the current one to gamma space
  20479. * @returns a new Color3 object
  20480. */
  20481. toGammaSpace(): Color3;
  20482. /**
  20483. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  20484. * @param convertedColor defines the Color3 object where to store the gamma space version
  20485. * @returns the unmodified Color3
  20486. */
  20487. toGammaSpaceToRef(convertedColor: Color3): Color3;
  20488. /**
  20489. * Creates a new Color3 from the string containing valid hexadecimal values
  20490. * @param hex defines a string containing valid hexadecimal values
  20491. * @returns a new Color3 object
  20492. */
  20493. static FromHexString(hex: string): Color3;
  20494. /**
  20495. * Creates a new Vector3 from the starting index of the given array
  20496. * @param array defines the source array
  20497. * @param offset defines an offset in the source array
  20498. * @returns a new Color3 object
  20499. */
  20500. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  20501. /**
  20502. * Creates a new Color3 from integer values (< 256)
  20503. * @param r defines the red component to read from (value between 0 and 255)
  20504. * @param g defines the green component to read from (value between 0 and 255)
  20505. * @param b defines the blue component to read from (value between 0 and 255)
  20506. * @returns a new Color3 object
  20507. */
  20508. static FromInts(r: number, g: number, b: number): Color3;
  20509. /**
  20510. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20511. * @param start defines the start Color3 value
  20512. * @param end defines the end Color3 value
  20513. * @param amount defines the gradient value between start and end
  20514. * @returns a new Color3 object
  20515. */
  20516. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  20517. /**
  20518. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20519. * @param left defines the start value
  20520. * @param right defines the end value
  20521. * @param amount defines the gradient factor
  20522. * @param result defines the Color3 object where to store the result
  20523. */
  20524. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  20525. /**
  20526. * Returns a Color3 value containing a red color
  20527. * @returns a new Color3 object
  20528. */
  20529. static Red(): Color3;
  20530. /**
  20531. * Returns a Color3 value containing a green color
  20532. * @returns a new Color3 object
  20533. */
  20534. static Green(): Color3;
  20535. /**
  20536. * Returns a Color3 value containing a blue color
  20537. * @returns a new Color3 object
  20538. */
  20539. static Blue(): Color3;
  20540. /**
  20541. * Returns a Color3 value containing a black color
  20542. * @returns a new Color3 object
  20543. */
  20544. static Black(): Color3;
  20545. /**
  20546. * Returns a Color3 value containing a white color
  20547. * @returns a new Color3 object
  20548. */
  20549. static White(): Color3;
  20550. /**
  20551. * Returns a Color3 value containing a purple color
  20552. * @returns a new Color3 object
  20553. */
  20554. static Purple(): Color3;
  20555. /**
  20556. * Returns a Color3 value containing a magenta color
  20557. * @returns a new Color3 object
  20558. */
  20559. static Magenta(): Color3;
  20560. /**
  20561. * Returns a Color3 value containing a yellow color
  20562. * @returns a new Color3 object
  20563. */
  20564. static Yellow(): Color3;
  20565. /**
  20566. * Returns a Color3 value containing a gray color
  20567. * @returns a new Color3 object
  20568. */
  20569. static Gray(): Color3;
  20570. /**
  20571. * Returns a Color3 value containing a teal color
  20572. * @returns a new Color3 object
  20573. */
  20574. static Teal(): Color3;
  20575. /**
  20576. * Returns a Color3 value containing a random color
  20577. * @returns a new Color3 object
  20578. */
  20579. static Random(): Color3;
  20580. }
  20581. /**
  20582. * Class used to hold a RBGA color
  20583. */
  20584. class Color4 {
  20585. /**
  20586. * Defines the red component (between 0 and 1, default is 0)
  20587. */
  20588. r: number;
  20589. /**
  20590. * Defines the green component (between 0 and 1, default is 0)
  20591. */
  20592. g: number;
  20593. /**
  20594. * Defines the blue component (between 0 and 1, default is 0)
  20595. */
  20596. b: number;
  20597. /**
  20598. * Defines the alpha component (between 0 and 1, default is 1)
  20599. */
  20600. a: number;
  20601. /**
  20602. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  20603. * @param r defines the red component (between 0 and 1, default is 0)
  20604. * @param g defines the green component (between 0 and 1, default is 0)
  20605. * @param b defines the blue component (between 0 and 1, default is 0)
  20606. * @param a defines the alpha component (between 0 and 1, default is 1)
  20607. */
  20608. constructor(
  20609. /**
  20610. * Defines the red component (between 0 and 1, default is 0)
  20611. */
  20612. r?: number,
  20613. /**
  20614. * Defines the green component (between 0 and 1, default is 0)
  20615. */
  20616. g?: number,
  20617. /**
  20618. * Defines the blue component (between 0 and 1, default is 0)
  20619. */
  20620. b?: number,
  20621. /**
  20622. * Defines the alpha component (between 0 and 1, default is 1)
  20623. */
  20624. a?: number);
  20625. /**
  20626. * Adds in place the given Color4 values to the current Color4 object
  20627. * @param right defines the second operand
  20628. * @returns the current updated Color4 object
  20629. */
  20630. addInPlace(right: DeepImmutable<Color4>): Color4;
  20631. /**
  20632. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  20633. * @returns the new array
  20634. */
  20635. asArray(): number[];
  20636. /**
  20637. * Stores from the starting index in the given array the Color4 successive values
  20638. * @param array defines the array where to store the r,g,b components
  20639. * @param index defines an optional index in the target array to define where to start storing values
  20640. * @returns the current Color4 object
  20641. */
  20642. toArray(array: number[], index?: number): Color4;
  20643. /**
  20644. * Determines equality between Color4 objects
  20645. * @param otherColor defines the second operand
  20646. * @returns true if the rgba values are equal to the given ones
  20647. */
  20648. equals(otherColor: DeepImmutable<Color4>): boolean;
  20649. /**
  20650. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  20651. * @param right defines the second operand
  20652. * @returns a new Color4 object
  20653. */
  20654. add(right: DeepImmutable<Color4>): Color4;
  20655. /**
  20656. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  20657. * @param right defines the second operand
  20658. * @returns a new Color4 object
  20659. */
  20660. subtract(right: DeepImmutable<Color4>): Color4;
  20661. /**
  20662. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  20663. * @param right defines the second operand
  20664. * @param result defines the Color4 object where to store the result
  20665. * @returns the current Color4 object
  20666. */
  20667. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  20668. /**
  20669. * Creates a new Color4 with the current Color4 values multiplied by scale
  20670. * @param scale defines the scaling factor to apply
  20671. * @returns a new Color4 object
  20672. */
  20673. scale(scale: number): Color4;
  20674. /**
  20675. * Multiplies the current Color4 values by scale and stores the result in "result"
  20676. * @param scale defines the scaling factor to apply
  20677. * @param result defines the Color4 object where to store the result
  20678. * @returns the current unmodified Color4
  20679. */
  20680. scaleToRef(scale: number, result: Color4): Color4;
  20681. /**
  20682. * Scale the current Color4 values by a factor and add the result to a given Color4
  20683. * @param scale defines the scale factor
  20684. * @param result defines the Color4 object where to store the result
  20685. * @returns the unmodified current Color4
  20686. */
  20687. scaleAndAddToRef(scale: number, result: Color4): Color4;
  20688. /**
  20689. * Clamps the rgb values by the min and max values and stores the result into "result"
  20690. * @param min defines minimum clamping value (default is 0)
  20691. * @param max defines maximum clamping value (default is 1)
  20692. * @param result defines color to store the result into.
  20693. * @returns the cuurent Color4
  20694. */
  20695. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  20696. /**
  20697. * Multipy an Color4 value by another and return a new Color4 object
  20698. * @param color defines the Color4 value to multiply by
  20699. * @returns a new Color4 object
  20700. */
  20701. multiply(color: Color4): Color4;
  20702. /**
  20703. * Multipy a Color4 value by another and push the result in a reference value
  20704. * @param color defines the Color4 value to multiply by
  20705. * @param result defines the Color4 to fill the result in
  20706. * @returns the result Color4
  20707. */
  20708. multiplyToRef(color: Color4, result: Color4): Color4;
  20709. /**
  20710. * Creates a string with the Color4 current values
  20711. * @returns the string representation of the Color4 object
  20712. */
  20713. toString(): string;
  20714. /**
  20715. * Returns the string "Color4"
  20716. * @returns "Color4"
  20717. */
  20718. getClassName(): string;
  20719. /**
  20720. * Compute the Color4 hash code
  20721. * @returns an unique number that can be used to hash Color4 objects
  20722. */
  20723. getHashCode(): number;
  20724. /**
  20725. * Creates a new Color4 copied from the current one
  20726. * @returns a new Color4 object
  20727. */
  20728. clone(): Color4;
  20729. /**
  20730. * Copies the given Color4 values into the current one
  20731. * @param source defines the source Color4 object
  20732. * @returns the current updated Color4 object
  20733. */
  20734. copyFrom(source: Color4): Color4;
  20735. /**
  20736. * Copies the given float values into the current one
  20737. * @param r defines the red component to read from
  20738. * @param g defines the green component to read from
  20739. * @param b defines the blue component to read from
  20740. * @param a defines the alpha component to read from
  20741. * @returns the current updated Color4 object
  20742. */
  20743. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  20744. /**
  20745. * Copies the given float values into the current one
  20746. * @param r defines the red component to read from
  20747. * @param g defines the green component to read from
  20748. * @param b defines the blue component to read from
  20749. * @param a defines the alpha component to read from
  20750. * @returns the current updated Color4 object
  20751. */
  20752. set(r: number, g: number, b: number, a: number): Color4;
  20753. /**
  20754. * Compute the Color4 hexadecimal code as a string
  20755. * @returns a string containing the hexadecimal representation of the Color4 object
  20756. */
  20757. toHexString(): string;
  20758. /**
  20759. * Computes a new Color4 converted from the current one to linear space
  20760. * @returns a new Color4 object
  20761. */
  20762. toLinearSpace(): Color4;
  20763. /**
  20764. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  20765. * @param convertedColor defines the Color4 object where to store the linear space version
  20766. * @returns the unmodified Color4
  20767. */
  20768. toLinearSpaceToRef(convertedColor: Color4): Color4;
  20769. /**
  20770. * Computes a new Color4 converted from the current one to gamma space
  20771. * @returns a new Color4 object
  20772. */
  20773. toGammaSpace(): Color4;
  20774. /**
  20775. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  20776. * @param convertedColor defines the Color4 object where to store the gamma space version
  20777. * @returns the unmodified Color4
  20778. */
  20779. toGammaSpaceToRef(convertedColor: Color4): Color4;
  20780. /**
  20781. * Creates a new Color4 from the string containing valid hexadecimal values
  20782. * @param hex defines a string containing valid hexadecimal values
  20783. * @returns a new Color4 object
  20784. */
  20785. static FromHexString(hex: string): Color4;
  20786. /**
  20787. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20788. * @param left defines the start value
  20789. * @param right defines the end value
  20790. * @param amount defines the gradient factor
  20791. * @returns a new Color4 object
  20792. */
  20793. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  20794. /**
  20795. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20796. * @param left defines the start value
  20797. * @param right defines the end value
  20798. * @param amount defines the gradient factor
  20799. * @param result defines the Color4 object where to store data
  20800. */
  20801. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  20802. /**
  20803. * Creates a new Color4 from a Color3 and an alpha value
  20804. * @param color3 defines the source Color3 to read from
  20805. * @param alpha defines the alpha component (1.0 by default)
  20806. * @returns a new Color4 object
  20807. */
  20808. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  20809. /**
  20810. * Creates a new Color4 from the starting index element of the given array
  20811. * @param array defines the source array to read from
  20812. * @param offset defines the offset in the source array
  20813. * @returns a new Color4 object
  20814. */
  20815. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  20816. /**
  20817. * Creates a new Color3 from integer values (< 256)
  20818. * @param r defines the red component to read from (value between 0 and 255)
  20819. * @param g defines the green component to read from (value between 0 and 255)
  20820. * @param b defines the blue component to read from (value between 0 and 255)
  20821. * @param a defines the alpha component to read from (value between 0 and 255)
  20822. * @returns a new Color3 object
  20823. */
  20824. static FromInts(r: number, g: number, b: number, a: number): Color4;
  20825. /**
  20826. * Check the content of a given array and convert it to an array containing RGBA data
  20827. * If the original array was already containing count * 4 values then it is returned directly
  20828. * @param colors defines the array to check
  20829. * @param count defines the number of RGBA data to expect
  20830. * @returns an array containing count * 4 values (RGBA)
  20831. */
  20832. static CheckColors4(colors: number[], count: number): number[];
  20833. }
  20834. /**
  20835. * Class representing a vector containing 2 coordinates
  20836. */
  20837. class Vector2 {
  20838. /** defines the first coordinate */
  20839. x: number;
  20840. /** defines the second coordinate */
  20841. y: number;
  20842. /**
  20843. * Creates a new Vector2 from the given x and y coordinates
  20844. * @param x defines the first coordinate
  20845. * @param y defines the second coordinate
  20846. */
  20847. constructor(
  20848. /** defines the first coordinate */
  20849. x?: number,
  20850. /** defines the second coordinate */
  20851. y?: number);
  20852. /**
  20853. * Gets a string with the Vector2 coordinates
  20854. * @returns a string with the Vector2 coordinates
  20855. */
  20856. toString(): string;
  20857. /**
  20858. * Gets class name
  20859. * @returns the string "Vector2"
  20860. */
  20861. getClassName(): string;
  20862. /**
  20863. * Gets current vector hash code
  20864. * @returns the Vector2 hash code as a number
  20865. */
  20866. getHashCode(): number;
  20867. /**
  20868. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  20869. * @param array defines the source array
  20870. * @param index defines the offset in source array
  20871. * @returns the current Vector2
  20872. */
  20873. toArray(array: FloatArray, index?: number): Vector2;
  20874. /**
  20875. * Copy the current vector to an array
  20876. * @returns a new array with 2 elements: the Vector2 coordinates.
  20877. */
  20878. asArray(): number[];
  20879. /**
  20880. * Sets the Vector2 coordinates with the given Vector2 coordinates
  20881. * @param source defines the source Vector2
  20882. * @returns the current updated Vector2
  20883. */
  20884. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  20885. /**
  20886. * Sets the Vector2 coordinates with the given floats
  20887. * @param x defines the first coordinate
  20888. * @param y defines the second coordinate
  20889. * @returns the current updated Vector2
  20890. */
  20891. copyFromFloats(x: number, y: number): Vector2;
  20892. /**
  20893. * Sets the Vector2 coordinates with the given floats
  20894. * @param x defines the first coordinate
  20895. * @param y defines the second coordinate
  20896. * @returns the current updated Vector2
  20897. */
  20898. set(x: number, y: number): Vector2;
  20899. /**
  20900. * Add another vector with the current one
  20901. * @param otherVector defines the other vector
  20902. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  20903. */
  20904. add(otherVector: DeepImmutable<Vector2>): Vector2;
  20905. /**
  20906. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  20907. * @param otherVector defines the other vector
  20908. * @param result defines the target vector
  20909. * @returns the unmodified current Vector2
  20910. */
  20911. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20912. /**
  20913. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  20914. * @param otherVector defines the other vector
  20915. * @returns the current updated Vector2
  20916. */
  20917. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20918. /**
  20919. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  20920. * @param otherVector defines the other vector
  20921. * @returns a new Vector2
  20922. */
  20923. addVector3(otherVector: Vector3): Vector2;
  20924. /**
  20925. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  20926. * @param otherVector defines the other vector
  20927. * @returns a new Vector2
  20928. */
  20929. subtract(otherVector: Vector2): Vector2;
  20930. /**
  20931. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  20932. * @param otherVector defines the other vector
  20933. * @param result defines the target vector
  20934. * @returns the unmodified current Vector2
  20935. */
  20936. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20937. /**
  20938. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  20939. * @param otherVector defines the other vector
  20940. * @returns the current updated Vector2
  20941. */
  20942. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20943. /**
  20944. * Multiplies in place the current Vector2 coordinates by the given ones
  20945. * @param otherVector defines the other vector
  20946. * @returns the current updated Vector2
  20947. */
  20948. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20949. /**
  20950. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  20951. * @param otherVector defines the other vector
  20952. * @returns a new Vector2
  20953. */
  20954. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  20955. /**
  20956. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  20957. * @param otherVector defines the other vector
  20958. * @param result defines the target vector
  20959. * @returns the unmodified current Vector2
  20960. */
  20961. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20962. /**
  20963. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  20964. * @param x defines the first coordinate
  20965. * @param y defines the second coordinate
  20966. * @returns a new Vector2
  20967. */
  20968. multiplyByFloats(x: number, y: number): Vector2;
  20969. /**
  20970. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  20971. * @param otherVector defines the other vector
  20972. * @returns a new Vector2
  20973. */
  20974. divide(otherVector: Vector2): Vector2;
  20975. /**
  20976. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  20977. * @param otherVector defines the other vector
  20978. * @param result defines the target vector
  20979. * @returns the unmodified current Vector2
  20980. */
  20981. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20982. /**
  20983. * Divides the current Vector2 coordinates by the given ones
  20984. * @param otherVector defines the other vector
  20985. * @returns the current updated Vector2
  20986. */
  20987. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20988. /**
  20989. * Gets a new Vector2 with current Vector2 negated coordinates
  20990. * @returns a new Vector2
  20991. */
  20992. negate(): Vector2;
  20993. /**
  20994. * Multiply the Vector2 coordinates by scale
  20995. * @param scale defines the scaling factor
  20996. * @returns the current updated Vector2
  20997. */
  20998. scaleInPlace(scale: number): Vector2;
  20999. /**
  21000. * Returns a new Vector2 scaled by "scale" from the current Vector2
  21001. * @param scale defines the scaling factor
  21002. * @returns a new Vector2
  21003. */
  21004. scale(scale: number): Vector2;
  21005. /**
  21006. * Scale the current Vector2 values by a factor to a given Vector2
  21007. * @param scale defines the scale factor
  21008. * @param result defines the Vector2 object where to store the result
  21009. * @returns the unmodified current Vector2
  21010. */
  21011. scaleToRef(scale: number, result: Vector2): Vector2;
  21012. /**
  21013. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  21014. * @param scale defines the scale factor
  21015. * @param result defines the Vector2 object where to store the result
  21016. * @returns the unmodified current Vector2
  21017. */
  21018. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  21019. /**
  21020. * Gets a boolean if two vectors are equals
  21021. * @param otherVector defines the other vector
  21022. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  21023. */
  21024. equals(otherVector: DeepImmutable<Vector2>): boolean;
  21025. /**
  21026. * Gets a boolean if two vectors are equals (using an epsilon value)
  21027. * @param otherVector defines the other vector
  21028. * @param epsilon defines the minimal distance to consider equality
  21029. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  21030. */
  21031. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  21032. /**
  21033. * Gets a new Vector2 from current Vector2 floored values
  21034. * @returns a new Vector2
  21035. */
  21036. floor(): Vector2;
  21037. /**
  21038. * Gets a new Vector2 from current Vector2 floored values
  21039. * @returns a new Vector2
  21040. */
  21041. fract(): Vector2;
  21042. /**
  21043. * Gets the length of the vector
  21044. * @returns the vector length (float)
  21045. */
  21046. length(): number;
  21047. /**
  21048. * Gets the vector squared length
  21049. * @returns the vector squared length (float)
  21050. */
  21051. lengthSquared(): number;
  21052. /**
  21053. * Normalize the vector
  21054. * @returns the current updated Vector2
  21055. */
  21056. normalize(): Vector2;
  21057. /**
  21058. * Gets a new Vector2 copied from the Vector2
  21059. * @returns a new Vector2
  21060. */
  21061. clone(): Vector2;
  21062. /**
  21063. * Gets a new Vector2(0, 0)
  21064. * @returns a new Vector2
  21065. */
  21066. static Zero(): Vector2;
  21067. /**
  21068. * Gets a new Vector2(1, 1)
  21069. * @returns a new Vector2
  21070. */
  21071. static One(): Vector2;
  21072. /**
  21073. * Gets a new Vector2 set from the given index element of the given array
  21074. * @param array defines the data source
  21075. * @param offset defines the offset in the data source
  21076. * @returns a new Vector2
  21077. */
  21078. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  21079. /**
  21080. * Sets "result" from the given index element of the given array
  21081. * @param array defines the data source
  21082. * @param offset defines the offset in the data source
  21083. * @param result defines the target vector
  21084. */
  21085. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  21086. /**
  21087. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  21088. * @param value1 defines 1st point of control
  21089. * @param value2 defines 2nd point of control
  21090. * @param value3 defines 3rd point of control
  21091. * @param value4 defines 4th point of control
  21092. * @param amount defines the interpolation factor
  21093. * @returns a new Vector2
  21094. */
  21095. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  21096. /**
  21097. * 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".
  21098. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  21099. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  21100. * @param value defines the value to clamp
  21101. * @param min defines the lower limit
  21102. * @param max defines the upper limit
  21103. * @returns a new Vector2
  21104. */
  21105. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  21106. /**
  21107. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  21108. * @param value1 defines the 1st control point
  21109. * @param tangent1 defines the outgoing tangent
  21110. * @param value2 defines the 2nd control point
  21111. * @param tangent2 defines the incoming tangent
  21112. * @param amount defines the interpolation factor
  21113. * @returns a new Vector2
  21114. */
  21115. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  21116. /**
  21117. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  21118. * @param start defines the start vector
  21119. * @param end defines the end vector
  21120. * @param amount defines the interpolation factor
  21121. * @returns a new Vector2
  21122. */
  21123. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  21124. /**
  21125. * Gets the dot product of the vector "left" and the vector "right"
  21126. * @param left defines first vector
  21127. * @param right defines second vector
  21128. * @returns the dot product (float)
  21129. */
  21130. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  21131. /**
  21132. * Returns a new Vector2 equal to the normalized given vector
  21133. * @param vector defines the vector to normalize
  21134. * @returns a new Vector2
  21135. */
  21136. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  21137. /**
  21138. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  21139. * @param left defines 1st vector
  21140. * @param right defines 2nd vector
  21141. * @returns a new Vector2
  21142. */
  21143. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  21144. /**
  21145. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  21146. * @param left defines 1st vector
  21147. * @param right defines 2nd vector
  21148. * @returns a new Vector2
  21149. */
  21150. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  21151. /**
  21152. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  21153. * @param vector defines the vector to transform
  21154. * @param transformation defines the matrix to apply
  21155. * @returns a new Vector2
  21156. */
  21157. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  21158. /**
  21159. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  21160. * @param vector defines the vector to transform
  21161. * @param transformation defines the matrix to apply
  21162. * @param result defines the target vector
  21163. */
  21164. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  21165. /**
  21166. * Determines if a given vector is included in a triangle
  21167. * @param p defines the vector to test
  21168. * @param p0 defines 1st triangle point
  21169. * @param p1 defines 2nd triangle point
  21170. * @param p2 defines 3rd triangle point
  21171. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  21172. */
  21173. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  21174. /**
  21175. * Gets the distance between the vectors "value1" and "value2"
  21176. * @param value1 defines first vector
  21177. * @param value2 defines second vector
  21178. * @returns the distance between vectors
  21179. */
  21180. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  21181. /**
  21182. * Returns the squared distance between the vectors "value1" and "value2"
  21183. * @param value1 defines first vector
  21184. * @param value2 defines second vector
  21185. * @returns the squared distance between vectors
  21186. */
  21187. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  21188. /**
  21189. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  21190. * @param value1 defines first vector
  21191. * @param value2 defines second vector
  21192. * @returns a new Vector2
  21193. */
  21194. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  21195. /**
  21196. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  21197. * @param p defines the middle point
  21198. * @param segA defines one point of the segment
  21199. * @param segB defines the other point of the segment
  21200. * @returns the shortest distance
  21201. */
  21202. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  21203. }
  21204. /**
  21205. * Classed used to store (x,y,z) vector representation
  21206. * A Vector3 is the main object used in 3D geometry
  21207. * It can represent etiher the coordinates of a point the space, either a direction
  21208. * Reminder: Babylon.js uses a left handed forward facing system
  21209. */
  21210. class Vector3 {
  21211. /**
  21212. * Defines the first coordinates (on X axis)
  21213. */
  21214. x: number;
  21215. /**
  21216. * Defines the second coordinates (on Y axis)
  21217. */
  21218. y: number;
  21219. /**
  21220. * Defines the third coordinates (on Z axis)
  21221. */
  21222. z: number;
  21223. /**
  21224. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  21225. * @param x defines the first coordinates (on X axis)
  21226. * @param y defines the second coordinates (on Y axis)
  21227. * @param z defines the third coordinates (on Z axis)
  21228. */
  21229. constructor(
  21230. /**
  21231. * Defines the first coordinates (on X axis)
  21232. */
  21233. x?: number,
  21234. /**
  21235. * Defines the second coordinates (on Y axis)
  21236. */
  21237. y?: number,
  21238. /**
  21239. * Defines the third coordinates (on Z axis)
  21240. */
  21241. z?: number);
  21242. /**
  21243. * Creates a string representation of the Vector3
  21244. * @returns a string with the Vector3 coordinates.
  21245. */
  21246. toString(): string;
  21247. /**
  21248. * Gets the class name
  21249. * @returns the string "Vector3"
  21250. */
  21251. getClassName(): string;
  21252. /**
  21253. * Creates the Vector3 hash code
  21254. * @returns a number which tends to be unique between Vector3 instances
  21255. */
  21256. getHashCode(): number;
  21257. /**
  21258. * Creates an array containing three elements : the coordinates of the Vector3
  21259. * @returns a new array of numbers
  21260. */
  21261. asArray(): number[];
  21262. /**
  21263. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  21264. * @param array defines the destination array
  21265. * @param index defines the offset in the destination array
  21266. * @returns the current Vector3
  21267. */
  21268. toArray(array: FloatArray, index?: number): Vector3;
  21269. /**
  21270. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  21271. * @returns a new Quaternion object, computed from the Vector3 coordinates
  21272. */
  21273. toQuaternion(): Quaternion;
  21274. /**
  21275. * Adds the given vector to the current Vector3
  21276. * @param otherVector defines the second operand
  21277. * @returns the current updated Vector3
  21278. */
  21279. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21280. /**
  21281. * Adds the given coordinates to the current Vector3
  21282. * @param x defines the x coordinate of the operand
  21283. * @param y defines the y coordinate of the operand
  21284. * @param z defines the z coordinate of the operand
  21285. * @returns the current updated Vector3
  21286. */
  21287. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21288. /**
  21289. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  21290. * @param otherVector defines the second operand
  21291. * @returns the resulting Vector3
  21292. */
  21293. add(otherVector: DeepImmutable<Vector3>): Vector3;
  21294. /**
  21295. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  21296. * @param otherVector defines the second operand
  21297. * @param result defines the Vector3 object where to store the result
  21298. * @returns the current Vector3
  21299. */
  21300. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21301. /**
  21302. * Subtract the given vector from the current Vector3
  21303. * @param otherVector defines the second operand
  21304. * @returns the current updated Vector3
  21305. */
  21306. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21307. /**
  21308. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  21309. * @param otherVector defines the second operand
  21310. * @returns the resulting Vector3
  21311. */
  21312. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  21313. /**
  21314. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  21315. * @param otherVector defines the second operand
  21316. * @param result defines the Vector3 object where to store the result
  21317. * @returns the current Vector3
  21318. */
  21319. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21320. /**
  21321. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  21322. * @param x defines the x coordinate of the operand
  21323. * @param y defines the y coordinate of the operand
  21324. * @param z defines the z coordinate of the operand
  21325. * @returns the resulting Vector3
  21326. */
  21327. subtractFromFloats(x: number, y: number, z: number): Vector3;
  21328. /**
  21329. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  21330. * @param x defines the x coordinate of the operand
  21331. * @param y defines the y coordinate of the operand
  21332. * @param z defines the z coordinate of the operand
  21333. * @param result defines the Vector3 object where to store the result
  21334. * @returns the current Vector3
  21335. */
  21336. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  21337. /**
  21338. * Gets a new Vector3 set with the current Vector3 negated coordinates
  21339. * @returns a new Vector3
  21340. */
  21341. negate(): Vector3;
  21342. /**
  21343. * Multiplies the Vector3 coordinates by the float "scale"
  21344. * @param scale defines the multiplier factor
  21345. * @returns the current updated Vector3
  21346. */
  21347. scaleInPlace(scale: number): Vector3;
  21348. /**
  21349. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  21350. * @param scale defines the multiplier factor
  21351. * @returns a new Vector3
  21352. */
  21353. scale(scale: number): Vector3;
  21354. /**
  21355. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  21356. * @param scale defines the multiplier factor
  21357. * @param result defines the Vector3 object where to store the result
  21358. * @returns the current Vector3
  21359. */
  21360. scaleToRef(scale: number, result: Vector3): Vector3;
  21361. /**
  21362. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  21363. * @param scale defines the scale factor
  21364. * @param result defines the Vector3 object where to store the result
  21365. * @returns the unmodified current Vector3
  21366. */
  21367. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  21368. /**
  21369. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  21370. * @param otherVector defines the second operand
  21371. * @returns true if both vectors are equals
  21372. */
  21373. equals(otherVector: DeepImmutable<Vector3>): boolean;
  21374. /**
  21375. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  21376. * @param otherVector defines the second operand
  21377. * @param epsilon defines the minimal distance to define values as equals
  21378. * @returns true if both vectors are distant less than epsilon
  21379. */
  21380. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  21381. /**
  21382. * Returns true if the current Vector3 coordinates equals the given floats
  21383. * @param x defines the x coordinate of the operand
  21384. * @param y defines the y coordinate of the operand
  21385. * @param z defines the z coordinate of the operand
  21386. * @returns true if both vectors are equals
  21387. */
  21388. equalsToFloats(x: number, y: number, z: number): boolean;
  21389. /**
  21390. * Multiplies the current Vector3 coordinates by the given ones
  21391. * @param otherVector defines the second operand
  21392. * @returns the current updated Vector3
  21393. */
  21394. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21395. /**
  21396. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  21397. * @param otherVector defines the second operand
  21398. * @returns the new Vector3
  21399. */
  21400. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  21401. /**
  21402. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  21403. * @param otherVector defines the second operand
  21404. * @param result defines the Vector3 object where to store the result
  21405. * @returns the current Vector3
  21406. */
  21407. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21408. /**
  21409. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  21410. * @param x defines the x coordinate of the operand
  21411. * @param y defines the y coordinate of the operand
  21412. * @param z defines the z coordinate of the operand
  21413. * @returns the new Vector3
  21414. */
  21415. multiplyByFloats(x: number, y: number, z: number): Vector3;
  21416. /**
  21417. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  21418. * @param otherVector defines the second operand
  21419. * @returns the new Vector3
  21420. */
  21421. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  21422. /**
  21423. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  21424. * @param otherVector defines the second operand
  21425. * @param result defines the Vector3 object where to store the result
  21426. * @returns the current Vector3
  21427. */
  21428. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21429. /**
  21430. * Divides the current Vector3 coordinates by the given ones.
  21431. * @param otherVector defines the second operand
  21432. * @returns the current updated Vector3
  21433. */
  21434. divideInPlace(otherVector: Vector3): Vector3;
  21435. /**
  21436. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  21437. * @param other defines the second operand
  21438. * @returns the current updated Vector3
  21439. */
  21440. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21441. /**
  21442. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  21443. * @param other defines the second operand
  21444. * @returns the current updated Vector3
  21445. */
  21446. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21447. /**
  21448. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  21449. * @param x defines the x coordinate of the operand
  21450. * @param y defines the y coordinate of the operand
  21451. * @param z defines the z coordinate of the operand
  21452. * @returns the current updated Vector3
  21453. */
  21454. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21455. /**
  21456. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  21457. * @param x defines the x coordinate of the operand
  21458. * @param y defines the y coordinate of the operand
  21459. * @param z defines the z coordinate of the operand
  21460. * @returns the current updated Vector3
  21461. */
  21462. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21463. /**
  21464. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  21465. */
  21466. readonly isNonUniform: boolean;
  21467. /**
  21468. * Gets a new Vector3 from current Vector3 floored values
  21469. * @returns a new Vector3
  21470. */
  21471. floor(): Vector3;
  21472. /**
  21473. * Gets a new Vector3 from current Vector3 floored values
  21474. * @returns a new Vector3
  21475. */
  21476. fract(): Vector3;
  21477. /**
  21478. * Gets the length of the Vector3
  21479. * @returns the length of the Vecto3
  21480. */
  21481. length(): number;
  21482. /**
  21483. * Gets the squared length of the Vector3
  21484. * @returns squared length of the Vector3
  21485. */
  21486. lengthSquared(): number;
  21487. /**
  21488. * Normalize the current Vector3.
  21489. * Please note that this is an in place operation.
  21490. * @returns the current updated Vector3
  21491. */
  21492. normalize(): Vector3;
  21493. /**
  21494. * Reorders the x y z properties of the vector in place
  21495. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  21496. * @returns the current updated vector
  21497. */
  21498. reorderInPlace(order: string): this;
  21499. /**
  21500. * Rotates the vector around 0,0,0 by a quaternion
  21501. * @param quaternion the rotation quaternion
  21502. * @param result vector to store the result
  21503. * @returns the resulting vector
  21504. */
  21505. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  21506. /**
  21507. * Rotates a vector around a given point
  21508. * @param quaternion the rotation quaternion
  21509. * @param point the point to rotate around
  21510. * @param result vector to store the result
  21511. * @returns the resulting vector
  21512. */
  21513. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  21514. /**
  21515. * Normalize the current Vector3 with the given input length.
  21516. * Please note that this is an in place operation.
  21517. * @param len the length of the vector
  21518. * @returns the current updated Vector3
  21519. */
  21520. normalizeFromLength(len: number): Vector3;
  21521. /**
  21522. * Normalize the current Vector3 to a new vector
  21523. * @returns the new Vector3
  21524. */
  21525. normalizeToNew(): Vector3;
  21526. /**
  21527. * Normalize the current Vector3 to the reference
  21528. * @param reference define the Vector3 to update
  21529. * @returns the updated Vector3
  21530. */
  21531. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  21532. /**
  21533. * Creates a new Vector3 copied from the current Vector3
  21534. * @returns the new Vector3
  21535. */
  21536. clone(): Vector3;
  21537. /**
  21538. * Copies the given vector coordinates to the current Vector3 ones
  21539. * @param source defines the source Vector3
  21540. * @returns the current updated Vector3
  21541. */
  21542. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  21543. /**
  21544. * Copies the given floats to the current Vector3 coordinates
  21545. * @param x defines the x coordinate of the operand
  21546. * @param y defines the y coordinate of the operand
  21547. * @param z defines the z coordinate of the operand
  21548. * @returns the current updated Vector3
  21549. */
  21550. copyFromFloats(x: number, y: number, z: number): Vector3;
  21551. /**
  21552. * Copies the given floats to the current Vector3 coordinates
  21553. * @param x defines the x coordinate of the operand
  21554. * @param y defines the y coordinate of the operand
  21555. * @param z defines the z coordinate of the operand
  21556. * @returns the current updated Vector3
  21557. */
  21558. set(x: number, y: number, z: number): Vector3;
  21559. /**
  21560. * Copies the given float to the current Vector3 coordinates
  21561. * @param v defines the x, y and z coordinates of the operand
  21562. * @returns the current updated Vector3
  21563. */
  21564. setAll(v: number): Vector3;
  21565. /**
  21566. * Get the clip factor between two vectors
  21567. * @param vector0 defines the first operand
  21568. * @param vector1 defines the second operand
  21569. * @param axis defines the axis to use
  21570. * @param size defines the size along the axis
  21571. * @returns the clip factor
  21572. */
  21573. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  21574. /**
  21575. * Get angle between two vectors
  21576. * @param vector0 angle between vector0 and vector1
  21577. * @param vector1 angle between vector0 and vector1
  21578. * @param normal direction of the normal
  21579. * @return the angle between vector0 and vector1
  21580. */
  21581. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  21582. /**
  21583. * Returns a new Vector3 set from the index "offset" of the given array
  21584. * @param array defines the source array
  21585. * @param offset defines the offset in the source array
  21586. * @returns the new Vector3
  21587. */
  21588. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  21589. /**
  21590. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  21591. * This function is deprecated. Use FromArray instead
  21592. * @param array defines the source array
  21593. * @param offset defines the offset in the source array
  21594. * @returns the new Vector3
  21595. */
  21596. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  21597. /**
  21598. * Sets the given vector "result" with the element values from the index "offset" of the given array
  21599. * @param array defines the source array
  21600. * @param offset defines the offset in the source array
  21601. * @param result defines the Vector3 where to store the result
  21602. */
  21603. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  21604. /**
  21605. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  21606. * This function is deprecated. Use FromArrayToRef instead.
  21607. * @param array defines the source array
  21608. * @param offset defines the offset in the source array
  21609. * @param result defines the Vector3 where to store the result
  21610. */
  21611. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  21612. /**
  21613. * Sets the given vector "result" with the given floats.
  21614. * @param x defines the x coordinate of the source
  21615. * @param y defines the y coordinate of the source
  21616. * @param z defines the z coordinate of the source
  21617. * @param result defines the Vector3 where to store the result
  21618. */
  21619. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  21620. /**
  21621. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  21622. * @returns a new empty Vector3
  21623. */
  21624. static Zero(): Vector3;
  21625. /**
  21626. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  21627. * @returns a new unit Vector3
  21628. */
  21629. static One(): Vector3;
  21630. /**
  21631. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  21632. * @returns a new up Vector3
  21633. */
  21634. static Up(): Vector3;
  21635. /**
  21636. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  21637. * @returns a new down Vector3
  21638. */
  21639. static Down(): Vector3;
  21640. /**
  21641. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  21642. * @returns a new forward Vector3
  21643. */
  21644. static Forward(): Vector3;
  21645. /**
  21646. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  21647. * @returns a new forward Vector3
  21648. */
  21649. static Backward(): Vector3;
  21650. /**
  21651. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  21652. * @returns a new right Vector3
  21653. */
  21654. static Right(): Vector3;
  21655. /**
  21656. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  21657. * @returns a new left Vector3
  21658. */
  21659. static Left(): Vector3;
  21660. /**
  21661. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  21662. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21663. * @param vector defines the Vector3 to transform
  21664. * @param transformation defines the transformation matrix
  21665. * @returns the transformed Vector3
  21666. */
  21667. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21668. /**
  21669. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  21670. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21671. * @param vector defines the Vector3 to transform
  21672. * @param transformation defines the transformation matrix
  21673. * @param result defines the Vector3 where to store the result
  21674. */
  21675. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21676. /**
  21677. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  21678. * This method computes tranformed coordinates only, not transformed direction vectors
  21679. * @param x define the x coordinate of the source vector
  21680. * @param y define the y coordinate of the source vector
  21681. * @param z define the z coordinate of the source vector
  21682. * @param transformation defines the transformation matrix
  21683. * @param result defines the Vector3 where to store the result
  21684. */
  21685. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21686. /**
  21687. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  21688. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21689. * @param vector defines the Vector3 to transform
  21690. * @param transformation defines the transformation matrix
  21691. * @returns the new Vector3
  21692. */
  21693. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21694. /**
  21695. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  21696. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21697. * @param vector defines the Vector3 to transform
  21698. * @param transformation defines the transformation matrix
  21699. * @param result defines the Vector3 where to store the result
  21700. */
  21701. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21702. /**
  21703. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  21704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21705. * @param x define the x coordinate of the source vector
  21706. * @param y define the y coordinate of the source vector
  21707. * @param z define the z coordinate of the source vector
  21708. * @param transformation defines the transformation matrix
  21709. * @param result defines the Vector3 where to store the result
  21710. */
  21711. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21712. /**
  21713. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  21714. * @param value1 defines the first control point
  21715. * @param value2 defines the second control point
  21716. * @param value3 defines the third control point
  21717. * @param value4 defines the fourth control point
  21718. * @param amount defines the amount on the spline to use
  21719. * @returns the new Vector3
  21720. */
  21721. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  21722. /**
  21723. * 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"
  21724. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21725. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21726. * @param value defines the current value
  21727. * @param min defines the lower range value
  21728. * @param max defines the upper range value
  21729. * @returns the new Vector3
  21730. */
  21731. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  21732. /**
  21733. * 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"
  21734. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21735. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21736. * @param value defines the current value
  21737. * @param min defines the lower range value
  21738. * @param max defines the upper range value
  21739. * @param result defines the Vector3 where to store the result
  21740. */
  21741. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  21742. /**
  21743. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  21744. * @param value1 defines the first control point
  21745. * @param tangent1 defines the first tangent vector
  21746. * @param value2 defines the second control point
  21747. * @param tangent2 defines the second tangent vector
  21748. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  21749. * @returns the new Vector3
  21750. */
  21751. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  21752. /**
  21753. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  21754. * @param start defines the start value
  21755. * @param end defines the end value
  21756. * @param amount max defines amount between both (between 0 and 1)
  21757. * @returns the new Vector3
  21758. */
  21759. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  21760. /**
  21761. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  21762. * @param start defines the start value
  21763. * @param end defines the end value
  21764. * @param amount max defines amount between both (between 0 and 1)
  21765. * @param result defines the Vector3 where to store the result
  21766. */
  21767. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  21768. /**
  21769. * Returns the dot product (float) between the vectors "left" and "right"
  21770. * @param left defines the left operand
  21771. * @param right defines the right operand
  21772. * @returns the dot product
  21773. */
  21774. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  21775. /**
  21776. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  21777. * The cross product is then orthogonal to both "left" and "right"
  21778. * @param left defines the left operand
  21779. * @param right defines the right operand
  21780. * @returns the cross product
  21781. */
  21782. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21783. /**
  21784. * Sets the given vector "result" with the cross product of "left" and "right"
  21785. * The cross product is then orthogonal to both "left" and "right"
  21786. * @param left defines the left operand
  21787. * @param right defines the right operand
  21788. * @param result defines the Vector3 where to store the result
  21789. */
  21790. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  21791. /**
  21792. * Returns a new Vector3 as the normalization of the given vector
  21793. * @param vector defines the Vector3 to normalize
  21794. * @returns the new Vector3
  21795. */
  21796. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  21797. /**
  21798. * Sets the given vector "result" with the normalization of the given first vector
  21799. * @param vector defines the Vector3 to normalize
  21800. * @param result defines the Vector3 where to store the result
  21801. */
  21802. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  21803. /**
  21804. * Project a Vector3 onto screen space
  21805. * @param vector defines the Vector3 to project
  21806. * @param world defines the world matrix to use
  21807. * @param transform defines the transform (view x projection) matrix to use
  21808. * @param viewport defines the screen viewport to use
  21809. * @returns the new Vector3
  21810. */
  21811. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  21812. /** @hidden */
  21813. private static UnprojectFromInvertedMatrixToRef;
  21814. /**
  21815. * Unproject from screen space to object space
  21816. * @param source defines the screen space Vector3 to use
  21817. * @param viewportWidth defines the current width of the viewport
  21818. * @param viewportHeight defines the current height of the viewport
  21819. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21820. * @param transform defines the transform (view x projection) matrix to use
  21821. * @returns the new Vector3
  21822. */
  21823. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  21824. /**
  21825. * Unproject from screen space to object space
  21826. * @param source defines the screen space Vector3 to use
  21827. * @param viewportWidth defines the current width of the viewport
  21828. * @param viewportHeight defines the current height of the viewport
  21829. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21830. * @param view defines the view matrix to use
  21831. * @param projection defines the projection matrix to use
  21832. * @returns the new Vector3
  21833. */
  21834. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  21835. /**
  21836. * Unproject from screen space to object space
  21837. * @param source defines the screen space Vector3 to use
  21838. * @param viewportWidth defines the current width of the viewport
  21839. * @param viewportHeight defines the current height of the viewport
  21840. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21841. * @param view defines the view matrix to use
  21842. * @param projection defines the projection matrix to use
  21843. * @param result defines the Vector3 where to store the result
  21844. */
  21845. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21846. /**
  21847. * Unproject from screen space to object space
  21848. * @param sourceX defines the screen space x coordinate to use
  21849. * @param sourceY defines the screen space y coordinate to use
  21850. * @param sourceZ defines the screen space z coordinate to use
  21851. * @param viewportWidth defines the current width of the viewport
  21852. * @param viewportHeight defines the current height of the viewport
  21853. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21854. * @param view defines the view matrix to use
  21855. * @param projection defines the projection matrix to use
  21856. * @param result defines the Vector3 where to store the result
  21857. */
  21858. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21859. /**
  21860. * Unproject a ray from screen space to object space
  21861. * @param sourceX defines the screen space x coordinate to use
  21862. * @param sourceY defines the screen space y coordinate to use
  21863. * @param viewportWidth defines the current width of the viewport
  21864. * @param viewportHeight defines the current height of the viewport
  21865. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21866. * @param view defines the view matrix to use
  21867. * @param projection defines the projection matrix to use
  21868. * @param ray defines the Ray where to store the result
  21869. */
  21870. static UnprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, ray: Ray): void;
  21871. /**
  21872. * Gets the minimal coordinate values between two Vector3
  21873. * @param left defines the first operand
  21874. * @param right defines the second operand
  21875. * @returns the new Vector3
  21876. */
  21877. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21878. /**
  21879. * Gets the maximal coordinate values between two Vector3
  21880. * @param left defines the first operand
  21881. * @param right defines the second operand
  21882. * @returns the new Vector3
  21883. */
  21884. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21885. /**
  21886. * Returns the distance between the vectors "value1" and "value2"
  21887. * @param value1 defines the first operand
  21888. * @param value2 defines the second operand
  21889. * @returns the distance
  21890. */
  21891. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21892. /**
  21893. * Returns the squared distance between the vectors "value1" and "value2"
  21894. * @param value1 defines the first operand
  21895. * @param value2 defines the second operand
  21896. * @returns the squared distance
  21897. */
  21898. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21899. /**
  21900. * Returns a new Vector3 located at the center between "value1" and "value2"
  21901. * @param value1 defines the first operand
  21902. * @param value2 defines the second operand
  21903. * @returns the new Vector3
  21904. */
  21905. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  21906. /**
  21907. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  21908. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  21909. * to something in order to rotate it from its local system to the given target system
  21910. * Note: axis1, axis2 and axis3 are normalized during this operation
  21911. * @param axis1 defines the first axis
  21912. * @param axis2 defines the second axis
  21913. * @param axis3 defines the third axis
  21914. * @returns a new Vector3
  21915. */
  21916. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  21917. /**
  21918. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  21919. * @param axis1 defines the first axis
  21920. * @param axis2 defines the second axis
  21921. * @param axis3 defines the third axis
  21922. * @param ref defines the Vector3 where to store the result
  21923. */
  21924. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  21925. }
  21926. /**
  21927. * Vector4 class created for EulerAngle class conversion to Quaternion
  21928. */
  21929. class Vector4 {
  21930. /** x value of the vector */
  21931. x: number;
  21932. /** y value of the vector */
  21933. y: number;
  21934. /** z value of the vector */
  21935. z: number;
  21936. /** w value of the vector */
  21937. w: number;
  21938. /**
  21939. * Creates a Vector4 object from the given floats.
  21940. * @param x x value of the vector
  21941. * @param y y value of the vector
  21942. * @param z z value of the vector
  21943. * @param w w value of the vector
  21944. */
  21945. constructor(
  21946. /** x value of the vector */
  21947. x: number,
  21948. /** y value of the vector */
  21949. y: number,
  21950. /** z value of the vector */
  21951. z: number,
  21952. /** w value of the vector */
  21953. w: number);
  21954. /**
  21955. * Returns the string with the Vector4 coordinates.
  21956. * @returns a string containing all the vector values
  21957. */
  21958. toString(): string;
  21959. /**
  21960. * Returns the string "Vector4".
  21961. * @returns "Vector4"
  21962. */
  21963. getClassName(): string;
  21964. /**
  21965. * Returns the Vector4 hash code.
  21966. * @returns a unique hash code
  21967. */
  21968. getHashCode(): number;
  21969. /**
  21970. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  21971. * @returns the resulting array
  21972. */
  21973. asArray(): number[];
  21974. /**
  21975. * Populates the given array from the given index with the Vector4 coordinates.
  21976. * @param array array to populate
  21977. * @param index index of the array to start at (default: 0)
  21978. * @returns the Vector4.
  21979. */
  21980. toArray(array: FloatArray, index?: number): Vector4;
  21981. /**
  21982. * Adds the given vector to the current Vector4.
  21983. * @param otherVector the vector to add
  21984. * @returns the updated Vector4.
  21985. */
  21986. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  21987. /**
  21988. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  21989. * @param otherVector the vector to add
  21990. * @returns the resulting vector
  21991. */
  21992. add(otherVector: DeepImmutable<Vector4>): Vector4;
  21993. /**
  21994. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  21995. * @param otherVector the vector to add
  21996. * @param result the vector to store the result
  21997. * @returns the current Vector4.
  21998. */
  21999. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22000. /**
  22001. * Subtract in place the given vector from the current Vector4.
  22002. * @param otherVector the vector to subtract
  22003. * @returns the updated Vector4.
  22004. */
  22005. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22006. /**
  22007. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  22008. * @param otherVector the vector to add
  22009. * @returns the new vector with the result
  22010. */
  22011. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  22012. /**
  22013. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  22014. * @param otherVector the vector to subtract
  22015. * @param result the vector to store the result
  22016. * @returns the current Vector4.
  22017. */
  22018. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22019. /**
  22020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  22021. */
  22022. /**
  22023. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  22024. * @param x value to subtract
  22025. * @param y value to subtract
  22026. * @param z value to subtract
  22027. * @param w value to subtract
  22028. * @returns new vector containing the result
  22029. */
  22030. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  22031. /**
  22032. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  22033. * @param x value to subtract
  22034. * @param y value to subtract
  22035. * @param z value to subtract
  22036. * @param w value to subtract
  22037. * @param result the vector to store the result in
  22038. * @returns the current Vector4.
  22039. */
  22040. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  22041. /**
  22042. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  22043. * @returns a new vector with the negated values
  22044. */
  22045. negate(): Vector4;
  22046. /**
  22047. * Multiplies the current Vector4 coordinates by scale (float).
  22048. * @param scale the number to scale with
  22049. * @returns the updated Vector4.
  22050. */
  22051. scaleInPlace(scale: number): Vector4;
  22052. /**
  22053. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  22054. * @param scale the number to scale with
  22055. * @returns a new vector with the result
  22056. */
  22057. scale(scale: number): Vector4;
  22058. /**
  22059. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  22060. * @param scale the number to scale with
  22061. * @param result a vector to store the result in
  22062. * @returns the current Vector4.
  22063. */
  22064. scaleToRef(scale: number, result: Vector4): Vector4;
  22065. /**
  22066. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  22067. * @param scale defines the scale factor
  22068. * @param result defines the Vector4 object where to store the result
  22069. * @returns the unmodified current Vector4
  22070. */
  22071. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  22072. /**
  22073. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  22074. * @param otherVector the vector to compare against
  22075. * @returns true if they are equal
  22076. */
  22077. equals(otherVector: DeepImmutable<Vector4>): boolean;
  22078. /**
  22079. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  22080. * @param otherVector vector to compare against
  22081. * @param epsilon (Default: very small number)
  22082. * @returns true if they are equal
  22083. */
  22084. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  22085. /**
  22086. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  22087. * @param x x value to compare against
  22088. * @param y y value to compare against
  22089. * @param z z value to compare against
  22090. * @param w w value to compare against
  22091. * @returns true if equal
  22092. */
  22093. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  22094. /**
  22095. * Multiplies in place the current Vector4 by the given one.
  22096. * @param otherVector vector to multiple with
  22097. * @returns the updated Vector4.
  22098. */
  22099. multiplyInPlace(otherVector: Vector4): Vector4;
  22100. /**
  22101. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  22102. * @param otherVector vector to multiple with
  22103. * @returns resulting new vector
  22104. */
  22105. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  22106. /**
  22107. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  22108. * @param otherVector vector to multiple with
  22109. * @param result vector to store the result
  22110. * @returns the current Vector4.
  22111. */
  22112. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22113. /**
  22114. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  22115. * @param x x value multiply with
  22116. * @param y y value multiply with
  22117. * @param z z value multiply with
  22118. * @param w w value multiply with
  22119. * @returns resulting new vector
  22120. */
  22121. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  22122. /**
  22123. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  22124. * @param otherVector vector to devide with
  22125. * @returns resulting new vector
  22126. */
  22127. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  22128. /**
  22129. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  22130. * @param otherVector vector to devide with
  22131. * @param result vector to store the result
  22132. * @returns the current Vector4.
  22133. */
  22134. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22135. /**
  22136. * Divides the current Vector3 coordinates by the given ones.
  22137. * @param otherVector vector to devide with
  22138. * @returns the updated Vector3.
  22139. */
  22140. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22141. /**
  22142. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  22143. * @param other defines the second operand
  22144. * @returns the current updated Vector4
  22145. */
  22146. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  22147. /**
  22148. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  22149. * @param other defines the second operand
  22150. * @returns the current updated Vector4
  22151. */
  22152. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  22153. /**
  22154. * Gets a new Vector4 from current Vector4 floored values
  22155. * @returns a new Vector4
  22156. */
  22157. floor(): Vector4;
  22158. /**
  22159. * Gets a new Vector4 from current Vector3 floored values
  22160. * @returns a new Vector4
  22161. */
  22162. fract(): Vector4;
  22163. /**
  22164. * Returns the Vector4 length (float).
  22165. * @returns the length
  22166. */
  22167. length(): number;
  22168. /**
  22169. * Returns the Vector4 squared length (float).
  22170. * @returns the length squared
  22171. */
  22172. lengthSquared(): number;
  22173. /**
  22174. * Normalizes in place the Vector4.
  22175. * @returns the updated Vector4.
  22176. */
  22177. normalize(): Vector4;
  22178. /**
  22179. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  22180. * @returns this converted to a new vector3
  22181. */
  22182. toVector3(): Vector3;
  22183. /**
  22184. * Returns a new Vector4 copied from the current one.
  22185. * @returns the new cloned vector
  22186. */
  22187. clone(): Vector4;
  22188. /**
  22189. * Updates the current Vector4 with the given one coordinates.
  22190. * @param source the source vector to copy from
  22191. * @returns the updated Vector4.
  22192. */
  22193. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  22194. /**
  22195. * Updates the current Vector4 coordinates with the given floats.
  22196. * @param x float to copy from
  22197. * @param y float to copy from
  22198. * @param z float to copy from
  22199. * @param w float to copy from
  22200. * @returns the updated Vector4.
  22201. */
  22202. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  22203. /**
  22204. * Updates the current Vector4 coordinates with the given floats.
  22205. * @param x float to set from
  22206. * @param y float to set from
  22207. * @param z float to set from
  22208. * @param w float to set from
  22209. * @returns the updated Vector4.
  22210. */
  22211. set(x: number, y: number, z: number, w: number): Vector4;
  22212. /**
  22213. * Copies the given float to the current Vector3 coordinates
  22214. * @param v defines the x, y, z and w coordinates of the operand
  22215. * @returns the current updated Vector3
  22216. */
  22217. setAll(v: number): Vector4;
  22218. /**
  22219. * Returns a new Vector4 set from the starting index of the given array.
  22220. * @param array the array to pull values from
  22221. * @param offset the offset into the array to start at
  22222. * @returns the new vector
  22223. */
  22224. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  22225. /**
  22226. * Updates the given vector "result" from the starting index of the given array.
  22227. * @param array the array to pull values from
  22228. * @param offset the offset into the array to start at
  22229. * @param result the vector to store the result in
  22230. */
  22231. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  22232. /**
  22233. * Updates the given vector "result" from the starting index of the given Float32Array.
  22234. * @param array the array to pull values from
  22235. * @param offset the offset into the array to start at
  22236. * @param result the vector to store the result in
  22237. */
  22238. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  22239. /**
  22240. * Updates the given vector "result" coordinates from the given floats.
  22241. * @param x float to set from
  22242. * @param y float to set from
  22243. * @param z float to set from
  22244. * @param w float to set from
  22245. * @param result the vector to the floats in
  22246. */
  22247. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  22248. /**
  22249. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  22250. * @returns the new vector
  22251. */
  22252. static Zero(): Vector4;
  22253. /**
  22254. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  22255. * @returns the new vector
  22256. */
  22257. static One(): Vector4;
  22258. /**
  22259. * Returns a new normalized Vector4 from the given one.
  22260. * @param vector the vector to normalize
  22261. * @returns the vector
  22262. */
  22263. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  22264. /**
  22265. * Updates the given vector "result" from the normalization of the given one.
  22266. * @param vector the vector to normalize
  22267. * @param result the vector to store the result in
  22268. */
  22269. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  22270. /**
  22271. * Returns a vector with the minimum values from the left and right vectors
  22272. * @param left left vector to minimize
  22273. * @param right right vector to minimize
  22274. * @returns a new vector with the minimum of the left and right vector values
  22275. */
  22276. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  22277. /**
  22278. * Returns a vector with the maximum values from the left and right vectors
  22279. * @param left left vector to maximize
  22280. * @param right right vector to maximize
  22281. * @returns a new vector with the maximum of the left and right vector values
  22282. */
  22283. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  22284. /**
  22285. * Returns the distance (float) between the vectors "value1" and "value2".
  22286. * @param value1 value to calulate the distance between
  22287. * @param value2 value to calulate the distance between
  22288. * @return the distance between the two vectors
  22289. */
  22290. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  22291. /**
  22292. * Returns the squared distance (float) between the vectors "value1" and "value2".
  22293. * @param value1 value to calulate the distance between
  22294. * @param value2 value to calulate the distance between
  22295. * @return the distance between the two vectors squared
  22296. */
  22297. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  22298. /**
  22299. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  22300. * @param value1 value to calulate the center between
  22301. * @param value2 value to calulate the center between
  22302. * @return the center between the two vectors
  22303. */
  22304. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  22305. /**
  22306. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  22307. * This methods computes transformed normalized direction vectors only.
  22308. * @param vector the vector to transform
  22309. * @param transformation the transformation matrix to apply
  22310. * @returns the new vector
  22311. */
  22312. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  22313. /**
  22314. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  22315. * This methods computes transformed normalized direction vectors only.
  22316. * @param vector the vector to transform
  22317. * @param transformation the transformation matrix to apply
  22318. * @param result the vector to store the result in
  22319. */
  22320. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22321. /**
  22322. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  22323. * This methods computes transformed normalized direction vectors only.
  22324. * @param x value to transform
  22325. * @param y value to transform
  22326. * @param z value to transform
  22327. * @param w value to transform
  22328. * @param transformation the transformation matrix to apply
  22329. * @param result the vector to store the results in
  22330. */
  22331. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22332. }
  22333. /**
  22334. * Interface for the size containing width and height
  22335. */
  22336. interface ISize {
  22337. /**
  22338. * Width
  22339. */
  22340. width: number;
  22341. /**
  22342. * Heighht
  22343. */
  22344. height: number;
  22345. }
  22346. /**
  22347. * Size containing widht and height
  22348. */
  22349. class Size implements ISize {
  22350. /**
  22351. * Width
  22352. */
  22353. width: number;
  22354. /**
  22355. * Height
  22356. */
  22357. height: number;
  22358. /**
  22359. * Creates a Size object from the given width and height (floats).
  22360. * @param width width of the new size
  22361. * @param height height of the new size
  22362. */
  22363. constructor(width: number, height: number);
  22364. /**
  22365. * Returns a string with the Size width and height
  22366. * @returns a string with the Size width and height
  22367. */
  22368. toString(): string;
  22369. /**
  22370. * "Size"
  22371. * @returns the string "Size"
  22372. */
  22373. getClassName(): string;
  22374. /**
  22375. * Returns the Size hash code.
  22376. * @returns a hash code for a unique width and height
  22377. */
  22378. getHashCode(): number;
  22379. /**
  22380. * Updates the current size from the given one.
  22381. * @param src the given size
  22382. */
  22383. copyFrom(src: Size): void;
  22384. /**
  22385. * Updates in place the current Size from the given floats.
  22386. * @param width width of the new size
  22387. * @param height height of the new size
  22388. * @returns the updated Size.
  22389. */
  22390. copyFromFloats(width: number, height: number): Size;
  22391. /**
  22392. * Updates in place the current Size from the given floats.
  22393. * @param width width to set
  22394. * @param height height to set
  22395. * @returns the updated Size.
  22396. */
  22397. set(width: number, height: number): Size;
  22398. /**
  22399. * Multiplies the width and height by numbers
  22400. * @param w factor to multiple the width by
  22401. * @param h factor to multiple the height by
  22402. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  22403. */
  22404. multiplyByFloats(w: number, h: number): Size;
  22405. /**
  22406. * Clones the size
  22407. * @returns a new Size copied from the given one.
  22408. */
  22409. clone(): Size;
  22410. /**
  22411. * True if the current Size and the given one width and height are strictly equal.
  22412. * @param other the other size to compare against
  22413. * @returns True if the current Size and the given one width and height are strictly equal.
  22414. */
  22415. equals(other: Size): boolean;
  22416. /**
  22417. * The surface of the Size : width * height (float).
  22418. */
  22419. readonly surface: number;
  22420. /**
  22421. * Create a new size of zero
  22422. * @returns a new Size set to (0.0, 0.0)
  22423. */
  22424. static Zero(): Size;
  22425. /**
  22426. * Sums the width and height of two sizes
  22427. * @param otherSize size to add to this size
  22428. * @returns a new Size set as the addition result of the current Size and the given one.
  22429. */
  22430. add(otherSize: Size): Size;
  22431. /**
  22432. * Subtracts the width and height of two
  22433. * @param otherSize size to subtract to this size
  22434. * @returns a new Size set as the subtraction result of the given one from the current Size.
  22435. */
  22436. subtract(otherSize: Size): Size;
  22437. /**
  22438. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  22439. * @param start starting size to lerp between
  22440. * @param end end size to lerp between
  22441. * @param amount amount to lerp between the start and end values
  22442. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  22443. */
  22444. static Lerp(start: Size, end: Size, amount: number): Size;
  22445. }
  22446. /**
  22447. * Class used to store quaternion data
  22448. * @see https://en.wikipedia.org/wiki/Quaternion
  22449. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  22450. */
  22451. class Quaternion {
  22452. /** defines the first component (0 by default) */
  22453. x: number;
  22454. /** defines the second component (0 by default) */
  22455. y: number;
  22456. /** defines the third component (0 by default) */
  22457. z: number;
  22458. /** defines the fourth component (1.0 by default) */
  22459. w: number;
  22460. /**
  22461. * Creates a new Quaternion from the given floats
  22462. * @param x defines the first component (0 by default)
  22463. * @param y defines the second component (0 by default)
  22464. * @param z defines the third component (0 by default)
  22465. * @param w defines the fourth component (1.0 by default)
  22466. */
  22467. constructor(
  22468. /** defines the first component (0 by default) */
  22469. x?: number,
  22470. /** defines the second component (0 by default) */
  22471. y?: number,
  22472. /** defines the third component (0 by default) */
  22473. z?: number,
  22474. /** defines the fourth component (1.0 by default) */
  22475. w?: number);
  22476. /**
  22477. * Gets a string representation for the current quaternion
  22478. * @returns a string with the Quaternion coordinates
  22479. */
  22480. toString(): string;
  22481. /**
  22482. * Gets the class name of the quaternion
  22483. * @returns the string "Quaternion"
  22484. */
  22485. getClassName(): string;
  22486. /**
  22487. * Gets a hash code for this quaternion
  22488. * @returns the quaternion hash code
  22489. */
  22490. getHashCode(): number;
  22491. /**
  22492. * Copy the quaternion to an array
  22493. * @returns a new array populated with 4 elements from the quaternion coordinates
  22494. */
  22495. asArray(): number[];
  22496. /**
  22497. * Check if two quaternions are equals
  22498. * @param otherQuaternion defines the second operand
  22499. * @return true if the current quaternion and the given one coordinates are strictly equals
  22500. */
  22501. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  22502. /**
  22503. * Clone the current quaternion
  22504. * @returns a new quaternion copied from the current one
  22505. */
  22506. clone(): Quaternion;
  22507. /**
  22508. * Copy a quaternion to the current one
  22509. * @param other defines the other quaternion
  22510. * @returns the updated current quaternion
  22511. */
  22512. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  22513. /**
  22514. * Updates the current quaternion with the given float coordinates
  22515. * @param x defines the x coordinate
  22516. * @param y defines the y coordinate
  22517. * @param z defines the z coordinate
  22518. * @param w defines the w coordinate
  22519. * @returns the updated current quaternion
  22520. */
  22521. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  22522. /**
  22523. * Updates the current quaternion from the given float coordinates
  22524. * @param x defines the x coordinate
  22525. * @param y defines the y coordinate
  22526. * @param z defines the z coordinate
  22527. * @param w defines the w coordinate
  22528. * @returns the updated current quaternion
  22529. */
  22530. set(x: number, y: number, z: number, w: number): Quaternion;
  22531. /**
  22532. * Adds two quaternions
  22533. * @param other defines the second operand
  22534. * @returns a new quaternion as the addition result of the given one and the current quaternion
  22535. */
  22536. add(other: DeepImmutable<Quaternion>): Quaternion;
  22537. /**
  22538. * Add a quaternion to the current one
  22539. * @param other defines the quaternion to add
  22540. * @returns the current quaternion
  22541. */
  22542. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  22543. /**
  22544. * Subtract two quaternions
  22545. * @param other defines the second operand
  22546. * @returns a new quaternion as the subtraction result of the given one from the current one
  22547. */
  22548. subtract(other: Quaternion): Quaternion;
  22549. /**
  22550. * Multiplies the current quaternion by a scale factor
  22551. * @param value defines the scale factor
  22552. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  22553. */
  22554. scale(value: number): Quaternion;
  22555. /**
  22556. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  22557. * @param scale defines the scale factor
  22558. * @param result defines the Quaternion object where to store the result
  22559. * @returns the unmodified current quaternion
  22560. */
  22561. scaleToRef(scale: number, result: Quaternion): Quaternion;
  22562. /**
  22563. * Multiplies in place the current quaternion by a scale factor
  22564. * @param value defines the scale factor
  22565. * @returns the current modified quaternion
  22566. */
  22567. scaleInPlace(value: number): Quaternion;
  22568. /**
  22569. * Scale the current quaternion values by a factor and add the result to a given quaternion
  22570. * @param scale defines the scale factor
  22571. * @param result defines the Quaternion object where to store the result
  22572. * @returns the unmodified current quaternion
  22573. */
  22574. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  22575. /**
  22576. * Multiplies two quaternions
  22577. * @param q1 defines the second operand
  22578. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  22579. */
  22580. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  22581. /**
  22582. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  22583. * @param q1 defines the second operand
  22584. * @param result defines the target quaternion
  22585. * @returns the current quaternion
  22586. */
  22587. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  22588. /**
  22589. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  22590. * @param q1 defines the second operand
  22591. * @returns the currentupdated quaternion
  22592. */
  22593. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  22594. /**
  22595. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  22596. * @param ref defines the target quaternion
  22597. * @returns the current quaternion
  22598. */
  22599. conjugateToRef(ref: Quaternion): Quaternion;
  22600. /**
  22601. * Conjugates in place (1-q) the current quaternion
  22602. * @returns the current updated quaternion
  22603. */
  22604. conjugateInPlace(): Quaternion;
  22605. /**
  22606. * Conjugates in place (1-q) the current quaternion
  22607. * @returns a new quaternion
  22608. */
  22609. conjugate(): Quaternion;
  22610. /**
  22611. * Gets length of current quaternion
  22612. * @returns the quaternion length (float)
  22613. */
  22614. length(): number;
  22615. /**
  22616. * Normalize in place the current quaternion
  22617. * @returns the current updated quaternion
  22618. */
  22619. normalize(): Quaternion;
  22620. /**
  22621. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  22622. * @param order is a reserved parameter and is ignore for now
  22623. * @returns a new Vector3 containing the Euler angles
  22624. */
  22625. toEulerAngles(order?: string): Vector3;
  22626. /**
  22627. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  22628. * @param result defines the vector which will be filled with the Euler angles
  22629. * @param order is a reserved parameter and is ignore for now
  22630. * @returns the current unchanged quaternion
  22631. */
  22632. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  22633. /**
  22634. * Updates the given rotation matrix with the current quaternion values
  22635. * @param result defines the target matrix
  22636. * @returns the current unchanged quaternion
  22637. */
  22638. toRotationMatrix(result: Matrix): Quaternion;
  22639. /**
  22640. * Updates the current quaternion from the given rotation matrix values
  22641. * @param matrix defines the source matrix
  22642. * @returns the current updated quaternion
  22643. */
  22644. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22645. /**
  22646. * Creates a new quaternion from a rotation matrix
  22647. * @param matrix defines the source matrix
  22648. * @returns a new quaternion created from the given rotation matrix values
  22649. */
  22650. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22651. /**
  22652. * Updates the given quaternion with the given rotation matrix values
  22653. * @param matrix defines the source matrix
  22654. * @param result defines the target quaternion
  22655. */
  22656. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  22657. /**
  22658. * Returns the dot product (float) between the quaternions "left" and "right"
  22659. * @param left defines the left operand
  22660. * @param right defines the right operand
  22661. * @returns the dot product
  22662. */
  22663. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  22664. /**
  22665. * Checks if the two quaternions are close to each other
  22666. * @param quat0 defines the first quaternion to check
  22667. * @param quat1 defines the second quaternion to check
  22668. * @returns true if the two quaternions are close to each other
  22669. */
  22670. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  22671. /**
  22672. * Creates an empty quaternion
  22673. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  22674. */
  22675. static Zero(): Quaternion;
  22676. /**
  22677. * Inverse a given quaternion
  22678. * @param q defines the source quaternion
  22679. * @returns a new quaternion as the inverted current quaternion
  22680. */
  22681. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  22682. /**
  22683. * Inverse a given quaternion
  22684. * @param q defines the source quaternion
  22685. * @param result the quaternion the result will be stored in
  22686. * @returns the result quaternion
  22687. */
  22688. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  22689. /**
  22690. * Creates an identity quaternion
  22691. * @returns the identity quaternion
  22692. */
  22693. static Identity(): Quaternion;
  22694. /**
  22695. * Gets a boolean indicating if the given quaternion is identity
  22696. * @param quaternion defines the quaternion to check
  22697. * @returns true if the quaternion is identity
  22698. */
  22699. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  22700. /**
  22701. * Creates a quaternion from a rotation around an axis
  22702. * @param axis defines the axis to use
  22703. * @param angle defines the angle to use
  22704. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  22705. */
  22706. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  22707. /**
  22708. * Creates a rotation around an axis and stores it into the given quaternion
  22709. * @param axis defines the axis to use
  22710. * @param angle defines the angle to use
  22711. * @param result defines the target quaternion
  22712. * @returns the target quaternion
  22713. */
  22714. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  22715. /**
  22716. * Creates a new quaternion from data stored into an array
  22717. * @param array defines the data source
  22718. * @param offset defines the offset in the source array where the data starts
  22719. * @returns a new quaternion
  22720. */
  22721. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  22722. /**
  22723. * Create a quaternion from Euler rotation angles
  22724. * @param x Pitch
  22725. * @param y Yaw
  22726. * @param z Roll
  22727. * @returns the new Quaternion
  22728. */
  22729. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  22730. /**
  22731. * Updates a quaternion from Euler rotation angles
  22732. * @param x Pitch
  22733. * @param y Yaw
  22734. * @param z Roll
  22735. * @param result the quaternion to store the result
  22736. * @returns the updated quaternion
  22737. */
  22738. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  22739. /**
  22740. * Create a quaternion from Euler rotation vector
  22741. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22742. * @returns the new Quaternion
  22743. */
  22744. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  22745. /**
  22746. * Updates a quaternion from Euler rotation vector
  22747. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22748. * @param result the quaternion to store the result
  22749. * @returns the updated quaternion
  22750. */
  22751. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  22752. /**
  22753. * Creates a new quaternion from the given Euler float angles (y, x, z)
  22754. * @param yaw defines the rotation around Y axis
  22755. * @param pitch defines the rotation around X axis
  22756. * @param roll defines the rotation around Z axis
  22757. * @returns the new quaternion
  22758. */
  22759. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  22760. /**
  22761. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  22762. * @param yaw defines the rotation around Y axis
  22763. * @param pitch defines the rotation around X axis
  22764. * @param roll defines the rotation around Z axis
  22765. * @param result defines the target quaternion
  22766. */
  22767. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  22768. /**
  22769. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  22770. * @param alpha defines the rotation around first axis
  22771. * @param beta defines the rotation around second axis
  22772. * @param gamma defines the rotation around third axis
  22773. * @returns the new quaternion
  22774. */
  22775. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  22776. /**
  22777. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  22778. * @param alpha defines the rotation around first axis
  22779. * @param beta defines the rotation around second axis
  22780. * @param gamma defines the rotation around third axis
  22781. * @param result defines the target quaternion
  22782. */
  22783. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  22784. /**
  22785. * 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)
  22786. * @param axis1 defines the first axis
  22787. * @param axis2 defines the second axis
  22788. * @param axis3 defines the third axis
  22789. * @returns the new quaternion
  22790. */
  22791. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  22792. /**
  22793. * 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
  22794. * @param axis1 defines the first axis
  22795. * @param axis2 defines the second axis
  22796. * @param axis3 defines the third axis
  22797. * @param ref defines the target quaternion
  22798. */
  22799. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  22800. /**
  22801. * Interpolates between two quaternions
  22802. * @param left defines first quaternion
  22803. * @param right defines second quaternion
  22804. * @param amount defines the gradient to use
  22805. * @returns the new interpolated quaternion
  22806. */
  22807. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22808. /**
  22809. * Interpolates between two quaternions and stores it into a target quaternion
  22810. * @param left defines first quaternion
  22811. * @param right defines second quaternion
  22812. * @param amount defines the gradient to use
  22813. * @param result defines the target quaternion
  22814. */
  22815. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  22816. /**
  22817. * Interpolate between two quaternions using Hermite interpolation
  22818. * @param value1 defines first quaternion
  22819. * @param tangent1 defines the incoming tangent
  22820. * @param value2 defines second quaternion
  22821. * @param tangent2 defines the outgoing tangent
  22822. * @param amount defines the target quaternion
  22823. * @returns the new interpolated quaternion
  22824. */
  22825. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22826. }
  22827. /**
  22828. * Class used to store matrix data (4x4)
  22829. */
  22830. class Matrix {
  22831. private static _updateFlagSeed;
  22832. private static _identityReadOnly;
  22833. private _isIdentity;
  22834. private _isIdentityDirty;
  22835. private _isIdentity3x2;
  22836. private _isIdentity3x2Dirty;
  22837. /**
  22838. * Gets the update flag of the matrix which is an unique number for the matrix.
  22839. * It will be incremented every time the matrix data change.
  22840. * You can use it to speed the comparison between two versions of the same matrix.
  22841. */
  22842. updateFlag: number;
  22843. private readonly _m;
  22844. /**
  22845. * Gets the internal data of the matrix
  22846. */
  22847. readonly m: DeepImmutable<Float32Array>;
  22848. /** @hidden */
  22849. _markAsUpdated(): void;
  22850. /** @hidden */
  22851. private _updateIdentityStatus;
  22852. /**
  22853. * Creates an empty matrix (filled with zeros)
  22854. */
  22855. constructor();
  22856. /**
  22857. * Check if the current matrix is identity
  22858. * @returns true is the matrix is the identity matrix
  22859. */
  22860. isIdentity(): boolean;
  22861. /**
  22862. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  22863. * @returns true is the matrix is the identity matrix
  22864. */
  22865. isIdentityAs3x2(): boolean;
  22866. /**
  22867. * Gets the determinant of the matrix
  22868. * @returns the matrix determinant
  22869. */
  22870. determinant(): number;
  22871. /**
  22872. * Returns the matrix as a Float32Array
  22873. * @returns the matrix underlying array
  22874. */
  22875. toArray(): DeepImmutable<Float32Array>;
  22876. /**
  22877. * Returns the matrix as a Float32Array
  22878. * @returns the matrix underlying array.
  22879. */
  22880. asArray(): DeepImmutable<Float32Array>;
  22881. /**
  22882. * Inverts the current matrix in place
  22883. * @returns the current inverted matrix
  22884. */
  22885. invert(): Matrix;
  22886. /**
  22887. * Sets all the matrix elements to zero
  22888. * @returns the current matrix
  22889. */
  22890. reset(): Matrix;
  22891. /**
  22892. * Adds the current matrix with a second one
  22893. * @param other defines the matrix to add
  22894. * @returns a new matrix as the addition of the current matrix and the given one
  22895. */
  22896. add(other: DeepImmutable<Matrix>): Matrix;
  22897. /**
  22898. * Sets the given matrix "result" to the addition of the current matrix and the given one
  22899. * @param other defines the matrix to add
  22900. * @param result defines the target matrix
  22901. * @returns the current matrix
  22902. */
  22903. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  22904. /**
  22905. * Adds in place the given matrix to the current matrix
  22906. * @param other defines the second operand
  22907. * @returns the current updated matrix
  22908. */
  22909. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  22910. /**
  22911. * Sets the given matrix to the current inverted Matrix
  22912. * @param other defines the target matrix
  22913. * @returns the unmodified current matrix
  22914. */
  22915. invertToRef(other: Matrix): Matrix;
  22916. /**
  22917. * add a value at the specified position in the current Matrix
  22918. * @param index the index of the value within the matrix. between 0 and 15.
  22919. * @param value the value to be added
  22920. * @returns the current updated matrix
  22921. */
  22922. addAtIndex(index: number, value: number): Matrix;
  22923. /**
  22924. * mutiply the specified position in the current Matrix by a value
  22925. * @param index the index of the value within the matrix. between 0 and 15.
  22926. * @param value the value to be added
  22927. * @returns the current updated matrix
  22928. */
  22929. multiplyAtIndex(index: number, value: number): Matrix;
  22930. /**
  22931. * Inserts the translation vector (using 3 floats) in the current matrix
  22932. * @param x defines the 1st component of the translation
  22933. * @param y defines the 2nd component of the translation
  22934. * @param z defines the 3rd component of the translation
  22935. * @returns the current updated matrix
  22936. */
  22937. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  22938. /**
  22939. * Inserts the translation vector in the current matrix
  22940. * @param vector3 defines the translation to insert
  22941. * @returns the current updated matrix
  22942. */
  22943. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  22944. /**
  22945. * Gets the translation value of the current matrix
  22946. * @returns a new Vector3 as the extracted translation from the matrix
  22947. */
  22948. getTranslation(): Vector3;
  22949. /**
  22950. * Fill a Vector3 with the extracted translation from the matrix
  22951. * @param result defines the Vector3 where to store the translation
  22952. * @returns the current matrix
  22953. */
  22954. getTranslationToRef(result: Vector3): Matrix;
  22955. /**
  22956. * Remove rotation and scaling part from the matrix
  22957. * @returns the updated matrix
  22958. */
  22959. removeRotationAndScaling(): Matrix;
  22960. /**
  22961. * Multiply two matrices
  22962. * @param other defines the second operand
  22963. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  22964. */
  22965. multiply(other: DeepImmutable<Matrix>): Matrix;
  22966. /**
  22967. * Copy the current matrix from the given one
  22968. * @param other defines the source matrix
  22969. * @returns the current updated matrix
  22970. */
  22971. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  22972. /**
  22973. * Populates the given array from the starting index with the current matrix values
  22974. * @param array defines the target array
  22975. * @param offset defines the offset in the target array where to start storing values
  22976. * @returns the current matrix
  22977. */
  22978. copyToArray(array: Float32Array, offset?: number): Matrix;
  22979. /**
  22980. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  22981. * @param other defines the second operand
  22982. * @param result defines the matrix where to store the multiplication
  22983. * @returns the current matrix
  22984. */
  22985. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  22986. /**
  22987. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  22988. * @param other defines the second operand
  22989. * @param result defines the array where to store the multiplication
  22990. * @param offset defines the offset in the target array where to start storing values
  22991. * @returns the current matrix
  22992. */
  22993. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  22994. /**
  22995. * Check equality between this matrix and a second one
  22996. * @param value defines the second matrix to compare
  22997. * @returns true is the current matrix and the given one values are strictly equal
  22998. */
  22999. equals(value: DeepImmutable<Matrix>): boolean;
  23000. /**
  23001. * Clone the current matrix
  23002. * @returns a new matrix from the current matrix
  23003. */
  23004. clone(): Matrix;
  23005. /**
  23006. * Returns the name of the current matrix class
  23007. * @returns the string "Matrix"
  23008. */
  23009. getClassName(): string;
  23010. /**
  23011. * Gets the hash code of the current matrix
  23012. * @returns the hash code
  23013. */
  23014. getHashCode(): number;
  23015. /**
  23016. * Decomposes the current Matrix into a translation, rotation and scaling components
  23017. * @param scale defines the scale vector3 given as a reference to update
  23018. * @param rotation defines the rotation quaternion given as a reference to update
  23019. * @param translation defines the translation vector3 given as a reference to update
  23020. * @returns true if operation was successful
  23021. */
  23022. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  23023. /**
  23024. * Gets specific row of the matrix
  23025. * @param index defines the number of the row to get
  23026. * @returns the index-th row of the current matrix as a new Vector4
  23027. */
  23028. getRow(index: number): Nullable<Vector4>;
  23029. /**
  23030. * Sets the index-th row of the current matrix to the vector4 values
  23031. * @param index defines the number of the row to set
  23032. * @param row defines the target vector4
  23033. * @returns the updated current matrix
  23034. */
  23035. setRow(index: number, row: Vector4): Matrix;
  23036. /**
  23037. * Compute the transpose of the matrix
  23038. * @returns the new transposed matrix
  23039. */
  23040. transpose(): Matrix;
  23041. /**
  23042. * Compute the transpose of the matrix and store it in a given matrix
  23043. * @param result defines the target matrix
  23044. * @returns the current matrix
  23045. */
  23046. transposeToRef(result: Matrix): Matrix;
  23047. /**
  23048. * Sets the index-th row of the current matrix with the given 4 x float values
  23049. * @param index defines the row index
  23050. * @param x defines the x component to set
  23051. * @param y defines the y component to set
  23052. * @param z defines the z component to set
  23053. * @param w defines the w component to set
  23054. * @returns the updated current matrix
  23055. */
  23056. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  23057. /**
  23058. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  23059. * @param scale defines the scale factor
  23060. * @returns a new matrix
  23061. */
  23062. scale(scale: number): Matrix;
  23063. /**
  23064. * Scale the current matrix values by a factor to a given result matrix
  23065. * @param scale defines the scale factor
  23066. * @param result defines the matrix to store the result
  23067. * @returns the current matrix
  23068. */
  23069. scaleToRef(scale: number, result: Matrix): Matrix;
  23070. /**
  23071. * Scale the current matrix values by a factor and add the result to a given matrix
  23072. * @param scale defines the scale factor
  23073. * @param result defines the Matrix to store the result
  23074. * @returns the current matrix
  23075. */
  23076. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  23077. /**
  23078. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  23079. * @param ref matrix to store the result
  23080. */
  23081. toNormalMatrix(ref: Matrix): void;
  23082. /**
  23083. * Gets only rotation part of the current matrix
  23084. * @returns a new matrix sets to the extracted rotation matrix from the current one
  23085. */
  23086. getRotationMatrix(): Matrix;
  23087. /**
  23088. * Extracts the rotation matrix from the current one and sets it as the given "result"
  23089. * @param result defines the target matrix to store data to
  23090. * @returns the current matrix
  23091. */
  23092. getRotationMatrixToRef(result: Matrix): Matrix;
  23093. /**
  23094. * Toggles model matrix from being right handed to left handed in place and vice versa
  23095. */
  23096. toggleModelMatrixHandInPlace(): void;
  23097. /**
  23098. * Toggles projection matrix from being right handed to left handed in place and vice versa
  23099. */
  23100. toggleProjectionMatrixHandInPlace(): void;
  23101. /**
  23102. * Creates a matrix from an array
  23103. * @param array defines the source array
  23104. * @param offset defines an offset in the source array
  23105. * @returns a new Matrix set from the starting index of the given array
  23106. */
  23107. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  23108. /**
  23109. * Copy the content of an array into a given matrix
  23110. * @param array defines the source array
  23111. * @param offset defines an offset in the source array
  23112. * @param result defines the target matrix
  23113. */
  23114. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  23115. /**
  23116. * Stores an array into a matrix after having multiplied each component by a given factor
  23117. * @param array defines the source array
  23118. * @param offset defines the offset in the source array
  23119. * @param scale defines the scaling factor
  23120. * @param result defines the target matrix
  23121. */
  23122. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  23123. /**
  23124. * Gets an identity matrix that must not be updated
  23125. */
  23126. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  23127. /**
  23128. * Stores a list of values (16) inside a given matrix
  23129. * @param initialM11 defines 1st value of 1st row
  23130. * @param initialM12 defines 2nd value of 1st row
  23131. * @param initialM13 defines 3rd value of 1st row
  23132. * @param initialM14 defines 4th value of 1st row
  23133. * @param initialM21 defines 1st value of 2nd row
  23134. * @param initialM22 defines 2nd value of 2nd row
  23135. * @param initialM23 defines 3rd value of 2nd row
  23136. * @param initialM24 defines 4th value of 2nd row
  23137. * @param initialM31 defines 1st value of 3rd row
  23138. * @param initialM32 defines 2nd value of 3rd row
  23139. * @param initialM33 defines 3rd value of 3rd row
  23140. * @param initialM34 defines 4th value of 3rd row
  23141. * @param initialM41 defines 1st value of 4th row
  23142. * @param initialM42 defines 2nd value of 4th row
  23143. * @param initialM43 defines 3rd value of 4th row
  23144. * @param initialM44 defines 4th value of 4th row
  23145. * @param result defines the target matrix
  23146. */
  23147. 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;
  23148. /**
  23149. * Creates new matrix from a list of values (16)
  23150. * @param initialM11 defines 1st value of 1st row
  23151. * @param initialM12 defines 2nd value of 1st row
  23152. * @param initialM13 defines 3rd value of 1st row
  23153. * @param initialM14 defines 4th value of 1st row
  23154. * @param initialM21 defines 1st value of 2nd row
  23155. * @param initialM22 defines 2nd value of 2nd row
  23156. * @param initialM23 defines 3rd value of 2nd row
  23157. * @param initialM24 defines 4th value of 2nd row
  23158. * @param initialM31 defines 1st value of 3rd row
  23159. * @param initialM32 defines 2nd value of 3rd row
  23160. * @param initialM33 defines 3rd value of 3rd row
  23161. * @param initialM34 defines 4th value of 3rd row
  23162. * @param initialM41 defines 1st value of 4th row
  23163. * @param initialM42 defines 2nd value of 4th row
  23164. * @param initialM43 defines 3rd value of 4th row
  23165. * @param initialM44 defines 4th value of 4th row
  23166. * @returns the new matrix
  23167. */
  23168. 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;
  23169. /**
  23170. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  23171. * @param scale defines the scale vector3
  23172. * @param rotation defines the rotation quaternion
  23173. * @param translation defines the translation vector3
  23174. * @returns a new matrix
  23175. */
  23176. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  23177. /**
  23178. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  23179. * @param scale defines the scale vector3
  23180. * @param rotation defines the rotation quaternion
  23181. * @param translation defines the translation vector3
  23182. * @param result defines the target matrix
  23183. */
  23184. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  23185. /**
  23186. * Creates a new identity matrix
  23187. * @returns a new identity matrix
  23188. */
  23189. static Identity(): Matrix;
  23190. /**
  23191. * Creates a new identity matrix and stores the result in a given matrix
  23192. * @param result defines the target matrix
  23193. */
  23194. static IdentityToRef(result: Matrix): void;
  23195. /**
  23196. * Creates a new zero matrix
  23197. * @returns a new zero matrix
  23198. */
  23199. static Zero(): Matrix;
  23200. /**
  23201. * Creates a new rotation matrix for "angle" radians around the X axis
  23202. * @param angle defines the angle (in radians) to use
  23203. * @return the new matrix
  23204. */
  23205. static RotationX(angle: number): Matrix;
  23206. /**
  23207. * Creates a new matrix as the invert of a given matrix
  23208. * @param source defines the source matrix
  23209. * @returns the new matrix
  23210. */
  23211. static Invert(source: DeepImmutable<Matrix>): Matrix;
  23212. /**
  23213. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  23214. * @param angle defines the angle (in radians) to use
  23215. * @param result defines the target matrix
  23216. */
  23217. static RotationXToRef(angle: number, result: Matrix): void;
  23218. /**
  23219. * Creates a new rotation matrix for "angle" radians around the Y axis
  23220. * @param angle defines the angle (in radians) to use
  23221. * @return the new matrix
  23222. */
  23223. static RotationY(angle: number): Matrix;
  23224. /**
  23225. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  23226. * @param angle defines the angle (in radians) to use
  23227. * @param result defines the target matrix
  23228. */
  23229. static RotationYToRef(angle: number, result: Matrix): void;
  23230. /**
  23231. * Creates a new rotation matrix for "angle" radians around the Z axis
  23232. * @param angle defines the angle (in radians) to use
  23233. * @return the new matrix
  23234. */
  23235. static RotationZ(angle: number): Matrix;
  23236. /**
  23237. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  23238. * @param angle defines the angle (in radians) to use
  23239. * @param result defines the target matrix
  23240. */
  23241. static RotationZToRef(angle: number, result: Matrix): void;
  23242. /**
  23243. * Creates a new rotation matrix for "angle" radians around the given axis
  23244. * @param axis defines the axis to use
  23245. * @param angle defines the angle (in radians) to use
  23246. * @return the new matrix
  23247. */
  23248. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  23249. /**
  23250. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  23251. * @param axis defines the axis to use
  23252. * @param angle defines the angle (in radians) to use
  23253. * @param result defines the target matrix
  23254. */
  23255. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  23256. /**
  23257. * Creates a rotation matrix
  23258. * @param yaw defines the yaw angle in radians (Y axis)
  23259. * @param pitch defines the pitch angle in radians (X axis)
  23260. * @param roll defines the roll angle in radians (X axis)
  23261. * @returns the new rotation matrix
  23262. */
  23263. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  23264. /**
  23265. * Creates a rotation matrix and stores it in a given matrix
  23266. * @param yaw defines the yaw angle in radians (Y axis)
  23267. * @param pitch defines the pitch angle in radians (X axis)
  23268. * @param roll defines the roll angle in radians (X axis)
  23269. * @param result defines the target matrix
  23270. */
  23271. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  23272. /**
  23273. * Creates a scaling matrix
  23274. * @param x defines the scale factor on X axis
  23275. * @param y defines the scale factor on Y axis
  23276. * @param z defines the scale factor on Z axis
  23277. * @returns the new matrix
  23278. */
  23279. static Scaling(x: number, y: number, z: number): Matrix;
  23280. /**
  23281. * Creates a scaling matrix and stores it in a given matrix
  23282. * @param x defines the scale factor on X axis
  23283. * @param y defines the scale factor on Y axis
  23284. * @param z defines the scale factor on Z axis
  23285. * @param result defines the target matrix
  23286. */
  23287. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  23288. /**
  23289. * Creates a translation matrix
  23290. * @param x defines the translation on X axis
  23291. * @param y defines the translation on Y axis
  23292. * @param z defines the translationon Z axis
  23293. * @returns the new matrix
  23294. */
  23295. static Translation(x: number, y: number, z: number): Matrix;
  23296. /**
  23297. * Creates a translation matrix and stores it in a given matrix
  23298. * @param x defines the translation on X axis
  23299. * @param y defines the translation on Y axis
  23300. * @param z defines the translationon Z axis
  23301. * @param result defines the target matrix
  23302. */
  23303. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  23304. /**
  23305. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23306. * @param startValue defines the start value
  23307. * @param endValue defines the end value
  23308. * @param gradient defines the gradient factor
  23309. * @returns the new matrix
  23310. */
  23311. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23312. /**
  23313. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23314. * @param startValue defines the start value
  23315. * @param endValue defines the end value
  23316. * @param gradient defines the gradient factor
  23317. * @param result defines the Matrix object where to store data
  23318. */
  23319. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23320. /**
  23321. * Builds a new matrix whose values are computed by:
  23322. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23323. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23324. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23325. * @param startValue defines the first matrix
  23326. * @param endValue defines the second matrix
  23327. * @param gradient defines the gradient between the two matrices
  23328. * @returns the new matrix
  23329. */
  23330. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23331. /**
  23332. * Update a matrix to values which are computed by:
  23333. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23334. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23335. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23336. * @param startValue defines the first matrix
  23337. * @param endValue defines the second matrix
  23338. * @param gradient defines the gradient between the two matrices
  23339. * @param result defines the target matrix
  23340. */
  23341. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23342. /**
  23343. * 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"
  23344. * This function works in left handed mode
  23345. * @param eye defines the final position of the entity
  23346. * @param target defines where the entity should look at
  23347. * @param up defines the up vector for the entity
  23348. * @returns the new matrix
  23349. */
  23350. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23351. /**
  23352. * 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".
  23353. * This function works in left handed mode
  23354. * @param eye defines the final position of the entity
  23355. * @param target defines where the entity should look at
  23356. * @param up defines the up vector for the entity
  23357. * @param result defines the target matrix
  23358. */
  23359. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23360. /**
  23361. * 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"
  23362. * This function works in right handed mode
  23363. * @param eye defines the final position of the entity
  23364. * @param target defines where the entity should look at
  23365. * @param up defines the up vector for the entity
  23366. * @returns the new matrix
  23367. */
  23368. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23369. /**
  23370. * 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".
  23371. * This function works in right handed mode
  23372. * @param eye defines the final position of the entity
  23373. * @param target defines where the entity should look at
  23374. * @param up defines the up vector for the entity
  23375. * @param result defines the target matrix
  23376. */
  23377. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23378. /**
  23379. * Create a left-handed orthographic projection matrix
  23380. * @param width defines the viewport width
  23381. * @param height defines the viewport height
  23382. * @param znear defines the near clip plane
  23383. * @param zfar defines the far clip plane
  23384. * @returns a new matrix as a left-handed orthographic projection matrix
  23385. */
  23386. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23387. /**
  23388. * Store a left-handed orthographic projection to a given matrix
  23389. * @param width defines the viewport width
  23390. * @param height defines the viewport height
  23391. * @param znear defines the near clip plane
  23392. * @param zfar defines the far clip plane
  23393. * @param result defines the target matrix
  23394. */
  23395. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  23396. /**
  23397. * Create a left-handed orthographic projection matrix
  23398. * @param left defines the viewport left coordinate
  23399. * @param right defines the viewport right coordinate
  23400. * @param bottom defines the viewport bottom coordinate
  23401. * @param top defines the viewport top coordinate
  23402. * @param znear defines the near clip plane
  23403. * @param zfar defines the far clip plane
  23404. * @returns a new matrix as a left-handed orthographic projection matrix
  23405. */
  23406. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23407. /**
  23408. * Stores a left-handed orthographic projection into a given matrix
  23409. * @param left defines the viewport left coordinate
  23410. * @param right defines the viewport right coordinate
  23411. * @param bottom defines the viewport bottom coordinate
  23412. * @param top defines the viewport top coordinate
  23413. * @param znear defines the near clip plane
  23414. * @param zfar defines the far clip plane
  23415. * @param result defines the target matrix
  23416. */
  23417. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23418. /**
  23419. * Creates a right-handed orthographic projection matrix
  23420. * @param left defines the viewport left coordinate
  23421. * @param right defines the viewport right coordinate
  23422. * @param bottom defines the viewport bottom coordinate
  23423. * @param top defines the viewport top coordinate
  23424. * @param znear defines the near clip plane
  23425. * @param zfar defines the far clip plane
  23426. * @returns a new matrix as a right-handed orthographic projection matrix
  23427. */
  23428. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23429. /**
  23430. * Stores a right-handed orthographic projection into a given matrix
  23431. * @param left defines the viewport left coordinate
  23432. * @param right defines the viewport right coordinate
  23433. * @param bottom defines the viewport bottom coordinate
  23434. * @param top defines the viewport top coordinate
  23435. * @param znear defines the near clip plane
  23436. * @param zfar defines the far clip plane
  23437. * @param result defines the target matrix
  23438. */
  23439. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23440. /**
  23441. * Creates a left-handed perspective projection matrix
  23442. * @param width defines the viewport width
  23443. * @param height defines the viewport height
  23444. * @param znear defines the near clip plane
  23445. * @param zfar defines the far clip plane
  23446. * @returns a new matrix as a left-handed perspective projection matrix
  23447. */
  23448. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23449. /**
  23450. * Creates a left-handed perspective projection matrix
  23451. * @param fov defines the horizontal field of view
  23452. * @param aspect defines the aspect ratio
  23453. * @param znear defines the near clip plane
  23454. * @param zfar defines the far clip plane
  23455. * @returns a new matrix as a left-handed perspective projection matrix
  23456. */
  23457. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23458. /**
  23459. * Stores a left-handed perspective projection into a given matrix
  23460. * @param fov defines the horizontal field of view
  23461. * @param aspect defines the aspect ratio
  23462. * @param znear defines the near clip plane
  23463. * @param zfar defines the far clip plane
  23464. * @param result defines the target matrix
  23465. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23466. */
  23467. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23468. /**
  23469. * Creates a right-handed perspective projection matrix
  23470. * @param fov defines the horizontal field of view
  23471. * @param aspect defines the aspect ratio
  23472. * @param znear defines the near clip plane
  23473. * @param zfar defines the far clip plane
  23474. * @returns a new matrix as a right-handed perspective projection matrix
  23475. */
  23476. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23477. /**
  23478. * Stores a right-handed perspective projection into a given matrix
  23479. * @param fov defines the horizontal field of view
  23480. * @param aspect defines the aspect ratio
  23481. * @param znear defines the near clip plane
  23482. * @param zfar defines the far clip plane
  23483. * @param result defines the target matrix
  23484. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23485. */
  23486. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23487. /**
  23488. * Stores a perspective projection for WebVR info a given matrix
  23489. * @param fov defines the field of view
  23490. * @param znear defines the near clip plane
  23491. * @param zfar defines the far clip plane
  23492. * @param result defines the target matrix
  23493. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  23494. */
  23495. static PerspectiveFovWebVRToRef(fov: {
  23496. upDegrees: number;
  23497. downDegrees: number;
  23498. leftDegrees: number;
  23499. rightDegrees: number;
  23500. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  23501. /**
  23502. * Computes a complete transformation matrix
  23503. * @param viewport defines the viewport to use
  23504. * @param world defines the world matrix
  23505. * @param view defines the view matrix
  23506. * @param projection defines the projection matrix
  23507. * @param zmin defines the near clip plane
  23508. * @param zmax defines the far clip plane
  23509. * @returns the transformation matrix
  23510. */
  23511. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  23512. /**
  23513. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  23514. * @param matrix defines the matrix to use
  23515. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  23516. */
  23517. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  23518. /**
  23519. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  23520. * @param matrix defines the matrix to use
  23521. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  23522. */
  23523. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  23524. /**
  23525. * Compute the transpose of a given matrix
  23526. * @param matrix defines the matrix to transpose
  23527. * @returns the new matrix
  23528. */
  23529. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  23530. /**
  23531. * Compute the transpose of a matrix and store it in a target matrix
  23532. * @param matrix defines the matrix to transpose
  23533. * @param result defines the target matrix
  23534. */
  23535. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  23536. /**
  23537. * Computes a reflection matrix from a plane
  23538. * @param plane defines the reflection plane
  23539. * @returns a new matrix
  23540. */
  23541. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  23542. /**
  23543. * Computes a reflection matrix from a plane
  23544. * @param plane defines the reflection plane
  23545. * @param result defines the target matrix
  23546. */
  23547. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  23548. /**
  23549. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  23550. * @param xaxis defines the value of the 1st axis
  23551. * @param yaxis defines the value of the 2nd axis
  23552. * @param zaxis defines the value of the 3rd axis
  23553. * @param result defines the target matrix
  23554. */
  23555. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  23556. /**
  23557. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  23558. * @param quat defines the quaternion to use
  23559. * @param result defines the target matrix
  23560. */
  23561. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  23562. }
  23563. /**
  23564. * Represens a plane by the equation ax + by + cz + d = 0
  23565. */
  23566. class Plane {
  23567. /**
  23568. * Normal of the plane (a,b,c)
  23569. */
  23570. normal: Vector3;
  23571. /**
  23572. * d component of the plane
  23573. */
  23574. d: number;
  23575. /**
  23576. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  23577. * @param a a component of the plane
  23578. * @param b b component of the plane
  23579. * @param c c component of the plane
  23580. * @param d d component of the plane
  23581. */
  23582. constructor(a: number, b: number, c: number, d: number);
  23583. /**
  23584. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  23585. */
  23586. asArray(): number[];
  23587. /**
  23588. * @returns a new plane copied from the current Plane.
  23589. */
  23590. clone(): Plane;
  23591. /**
  23592. * @returns the string "Plane".
  23593. */
  23594. getClassName(): string;
  23595. /**
  23596. * @returns the Plane hash code.
  23597. */
  23598. getHashCode(): number;
  23599. /**
  23600. * Normalize the current Plane in place.
  23601. * @returns the updated Plane.
  23602. */
  23603. normalize(): Plane;
  23604. /**
  23605. * Applies a transformation the plane and returns the result
  23606. * @param transformation the transformation matrix to be applied to the plane
  23607. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  23608. */
  23609. transform(transformation: DeepImmutable<Matrix>): Plane;
  23610. /**
  23611. * Calcualtte the dot product between the point and the plane normal
  23612. * @param point point to calculate the dot product with
  23613. * @returns the dot product (float) of the point coordinates and the plane normal.
  23614. */
  23615. dotCoordinate(point: DeepImmutable<Vector3>): number;
  23616. /**
  23617. * Updates the current Plane from the plane defined by the three given points.
  23618. * @param point1 one of the points used to contruct the plane
  23619. * @param point2 one of the points used to contruct the plane
  23620. * @param point3 one of the points used to contruct the plane
  23621. * @returns the updated Plane.
  23622. */
  23623. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23624. /**
  23625. * Checks if the plane is facing a given direction
  23626. * @param direction the direction to check if the plane is facing
  23627. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  23628. * @returns True is the vector "direction" is the same side than the plane normal.
  23629. */
  23630. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  23631. /**
  23632. * Calculates the distance to a point
  23633. * @param point point to calculate distance to
  23634. * @returns the signed distance (float) from the given point to the Plane.
  23635. */
  23636. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  23637. /**
  23638. * Creates a plane from an array
  23639. * @param array the array to create a plane from
  23640. * @returns a new Plane from the given array.
  23641. */
  23642. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  23643. /**
  23644. * Creates a plane from three points
  23645. * @param point1 point used to create the plane
  23646. * @param point2 point used to create the plane
  23647. * @param point3 point used to create the plane
  23648. * @returns a new Plane defined by the three given points.
  23649. */
  23650. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23651. /**
  23652. * Creates a plane from an origin point and a normal
  23653. * @param origin origin of the plane to be constructed
  23654. * @param normal normal of the plane to be constructed
  23655. * @returns a new Plane the normal vector to this plane at the given origin point.
  23656. * Note : the vector "normal" is updated because normalized.
  23657. */
  23658. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  23659. /**
  23660. * Calculates the distance from a plane and a point
  23661. * @param origin origin of the plane to be constructed
  23662. * @param normal normal of the plane to be constructed
  23663. * @param point point to calculate distance to
  23664. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  23665. */
  23666. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  23667. }
  23668. /**
  23669. * Class used to represent a viewport on screen
  23670. */
  23671. class Viewport {
  23672. /** viewport left coordinate */
  23673. x: number;
  23674. /** viewport top coordinate */
  23675. y: number;
  23676. /**viewport width */
  23677. width: number;
  23678. /** viewport height */
  23679. height: number;
  23680. /**
  23681. * Creates a Viewport object located at (x, y) and sized (width, height)
  23682. * @param x defines viewport left coordinate
  23683. * @param y defines viewport top coordinate
  23684. * @param width defines the viewport width
  23685. * @param height defines the viewport height
  23686. */
  23687. constructor(
  23688. /** viewport left coordinate */
  23689. x: number,
  23690. /** viewport top coordinate */
  23691. y: number,
  23692. /**viewport width */
  23693. width: number,
  23694. /** viewport height */
  23695. height: number);
  23696. /**
  23697. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  23698. * @param renderWidthOrEngine defines either an engine or the rendering width
  23699. * @param renderHeight defines the rendering height
  23700. * @returns a new Viewport
  23701. */
  23702. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  23703. /**
  23704. * Returns a new Viewport copied from the current one
  23705. * @returns a new Viewport
  23706. */
  23707. clone(): Viewport;
  23708. }
  23709. /**
  23710. * Reprasents a camera frustum
  23711. */
  23712. class Frustum {
  23713. /**
  23714. * Gets the planes representing the frustum
  23715. * @param transform matrix to be applied to the returned planes
  23716. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  23717. */
  23718. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  23719. /**
  23720. * Gets the near frustum plane transformed by the transform matrix
  23721. * @param transform transformation matrix to be applied to the resulting frustum plane
  23722. * @param frustumPlane the resuling frustum plane
  23723. */
  23724. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23725. /**
  23726. * Gets the far frustum plane transformed by the transform matrix
  23727. * @param transform transformation matrix to be applied to the resulting frustum plane
  23728. * @param frustumPlane the resuling frustum plane
  23729. */
  23730. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23731. /**
  23732. * Gets the left frustum plane transformed by the transform matrix
  23733. * @param transform transformation matrix to be applied to the resulting frustum plane
  23734. * @param frustumPlane the resuling frustum plane
  23735. */
  23736. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23737. /**
  23738. * Gets the right frustum plane transformed by the transform matrix
  23739. * @param transform transformation matrix to be applied to the resulting frustum plane
  23740. * @param frustumPlane the resuling frustum plane
  23741. */
  23742. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23743. /**
  23744. * Gets the top frustum plane transformed by the transform matrix
  23745. * @param transform transformation matrix to be applied to the resulting frustum plane
  23746. * @param frustumPlane the resuling frustum plane
  23747. */
  23748. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23749. /**
  23750. * Gets the bottom frustum plane transformed by the transform matrix
  23751. * @param transform transformation matrix to be applied to the resulting frustum plane
  23752. * @param frustumPlane the resuling frustum plane
  23753. */
  23754. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23755. /**
  23756. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  23757. * @param transform transformation matrix to be applied to the resulting frustum planes
  23758. * @param frustumPlanes the resuling frustum planes
  23759. */
  23760. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  23761. }
  23762. /** Defines supported spaces */
  23763. enum Space {
  23764. /** Local (object) space */
  23765. LOCAL = 0,
  23766. /** World space */
  23767. WORLD = 1,
  23768. /** Bone space */
  23769. BONE = 2
  23770. }
  23771. /** Defines the 3 main axes */
  23772. class Axis {
  23773. /** X axis */
  23774. static X: Vector3;
  23775. /** Y axis */
  23776. static Y: Vector3;
  23777. /** Z axis */
  23778. static Z: Vector3;
  23779. }
  23780. /** Class used to represent a Bezier curve */
  23781. class BezierCurve {
  23782. /**
  23783. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  23784. * @param t defines the time
  23785. * @param x1 defines the left coordinate on X axis
  23786. * @param y1 defines the left coordinate on Y axis
  23787. * @param x2 defines the right coordinate on X axis
  23788. * @param y2 defines the right coordinate on Y axis
  23789. * @returns the interpolated value
  23790. */
  23791. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  23792. }
  23793. /**
  23794. * Defines potential orientation for back face culling
  23795. */
  23796. enum Orientation {
  23797. /**
  23798. * Clockwise
  23799. */
  23800. CW = 0,
  23801. /** Counter clockwise */
  23802. CCW = 1
  23803. }
  23804. /**
  23805. * Defines angle representation
  23806. */
  23807. class Angle {
  23808. private _radians;
  23809. /**
  23810. * Creates an Angle object of "radians" radians (float).
  23811. */
  23812. constructor(radians: number);
  23813. /**
  23814. * Get value in degrees
  23815. * @returns the Angle value in degrees (float)
  23816. */
  23817. degrees(): number;
  23818. /**
  23819. * Get value in radians
  23820. * @returns the Angle value in radians (float)
  23821. */
  23822. radians(): number;
  23823. /**
  23824. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  23825. * @param a defines first vector
  23826. * @param b defines second vector
  23827. * @returns a new Angle
  23828. */
  23829. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  23830. /**
  23831. * Gets a new Angle object from the given float in radians
  23832. * @param radians defines the angle value in radians
  23833. * @returns a new Angle
  23834. */
  23835. static FromRadians(radians: number): Angle;
  23836. /**
  23837. * Gets a new Angle object from the given float in degrees
  23838. * @param degrees defines the angle value in degrees
  23839. * @returns a new Angle
  23840. */
  23841. static FromDegrees(degrees: number): Angle;
  23842. }
  23843. /**
  23844. * This represents an arc in a 2d space.
  23845. */
  23846. class Arc2 {
  23847. /** Defines the start point of the arc */
  23848. startPoint: Vector2;
  23849. /** Defines the mid point of the arc */
  23850. midPoint: Vector2;
  23851. /** Defines the end point of the arc */
  23852. endPoint: Vector2;
  23853. /**
  23854. * Defines the center point of the arc.
  23855. */
  23856. centerPoint: Vector2;
  23857. /**
  23858. * Defines the radius of the arc.
  23859. */
  23860. radius: number;
  23861. /**
  23862. * Defines the angle of the arc (from mid point to end point).
  23863. */
  23864. angle: Angle;
  23865. /**
  23866. * Defines the start angle of the arc (from start point to middle point).
  23867. */
  23868. startAngle: Angle;
  23869. /**
  23870. * Defines the orientation of the arc (clock wise/counter clock wise).
  23871. */
  23872. orientation: Orientation;
  23873. /**
  23874. * Creates an Arc object from the three given points : start, middle and end.
  23875. * @param startPoint Defines the start point of the arc
  23876. * @param midPoint Defines the midlle point of the arc
  23877. * @param endPoint Defines the end point of the arc
  23878. */
  23879. constructor(
  23880. /** Defines the start point of the arc */
  23881. startPoint: Vector2,
  23882. /** Defines the mid point of the arc */
  23883. midPoint: Vector2,
  23884. /** Defines the end point of the arc */
  23885. endPoint: Vector2);
  23886. }
  23887. /**
  23888. * Represents a 2D path made up of multiple 2D points
  23889. */
  23890. class Path2 {
  23891. private _points;
  23892. private _length;
  23893. /**
  23894. * If the path start and end point are the same
  23895. */
  23896. closed: boolean;
  23897. /**
  23898. * Creates a Path2 object from the starting 2D coordinates x and y.
  23899. * @param x the starting points x value
  23900. * @param y the starting points y value
  23901. */
  23902. constructor(x: number, y: number);
  23903. /**
  23904. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  23905. * @param x the added points x value
  23906. * @param y the added points y value
  23907. * @returns the updated Path2.
  23908. */
  23909. addLineTo(x: number, y: number): Path2;
  23910. /**
  23911. * 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.
  23912. * @param midX middle point x value
  23913. * @param midY middle point y value
  23914. * @param endX end point x value
  23915. * @param endY end point y value
  23916. * @param numberOfSegments (default: 36)
  23917. * @returns the updated Path2.
  23918. */
  23919. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  23920. /**
  23921. * Closes the Path2.
  23922. * @returns the Path2.
  23923. */
  23924. close(): Path2;
  23925. /**
  23926. * Gets the sum of the distance between each sequential point in the path
  23927. * @returns the Path2 total length (float).
  23928. */
  23929. length(): number;
  23930. /**
  23931. * Gets the points which construct the path
  23932. * @returns the Path2 internal array of points.
  23933. */
  23934. getPoints(): Vector2[];
  23935. /**
  23936. * Retreives the point at the distance aways from the starting point
  23937. * @param normalizedLengthPosition the length along the path to retreive the point from
  23938. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  23939. */
  23940. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  23941. /**
  23942. * Creates a new path starting from an x and y position
  23943. * @param x starting x value
  23944. * @param y starting y value
  23945. * @returns a new Path2 starting at the coordinates (x, y).
  23946. */
  23947. static StartingAt(x: number, y: number): Path2;
  23948. }
  23949. /**
  23950. * Represents a 3D path made up of multiple 3D points
  23951. */
  23952. class Path3D {
  23953. /**
  23954. * an array of Vector3, the curve axis of the Path3D
  23955. */
  23956. path: Vector3[];
  23957. private _curve;
  23958. private _distances;
  23959. private _tangents;
  23960. private _normals;
  23961. private _binormals;
  23962. private _raw;
  23963. /**
  23964. * new Path3D(path, normal, raw)
  23965. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  23966. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  23967. * @param path an array of Vector3, the curve axis of the Path3D
  23968. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  23969. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  23970. */
  23971. constructor(
  23972. /**
  23973. * an array of Vector3, the curve axis of the Path3D
  23974. */
  23975. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  23976. /**
  23977. * Returns the Path3D array of successive Vector3 designing its curve.
  23978. * @returns the Path3D array of successive Vector3 designing its curve.
  23979. */
  23980. getCurve(): Vector3[];
  23981. /**
  23982. * Returns an array populated with tangent vectors on each Path3D curve point.
  23983. * @returns an array populated with tangent vectors on each Path3D curve point.
  23984. */
  23985. getTangents(): Vector3[];
  23986. /**
  23987. * Returns an array populated with normal vectors on each Path3D curve point.
  23988. * @returns an array populated with normal vectors on each Path3D curve point.
  23989. */
  23990. getNormals(): Vector3[];
  23991. /**
  23992. * Returns an array populated with binormal vectors on each Path3D curve point.
  23993. * @returns an array populated with binormal vectors on each Path3D curve point.
  23994. */
  23995. getBinormals(): Vector3[];
  23996. /**
  23997. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  23998. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  23999. */
  24000. getDistances(): number[];
  24001. /**
  24002. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  24003. * @param path path which all values are copied into the curves points
  24004. * @param firstNormal which should be projected onto the curve
  24005. * @returns the same object updated.
  24006. */
  24007. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  24008. private _compute;
  24009. private _getFirstNonNullVector;
  24010. private _getLastNonNullVector;
  24011. private _normalVector;
  24012. }
  24013. /**
  24014. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  24015. * A Curve3 is designed from a series of successive Vector3.
  24016. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  24017. */
  24018. class Curve3 {
  24019. private _points;
  24020. private _length;
  24021. /**
  24022. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  24023. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  24024. * @param v1 (Vector3) the control point
  24025. * @param v2 (Vector3) the end point of the Quadratic Bezier
  24026. * @param nbPoints (integer) the wanted number of points in the curve
  24027. * @returns the created Curve3
  24028. */
  24029. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24030. /**
  24031. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  24032. * @param v0 (Vector3) the origin point of the Cubic Bezier
  24033. * @param v1 (Vector3) the first control point
  24034. * @param v2 (Vector3) the second control point
  24035. * @param v3 (Vector3) the end point of the Cubic Bezier
  24036. * @param nbPoints (integer) the wanted number of points in the curve
  24037. * @returns the created Curve3
  24038. */
  24039. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24040. /**
  24041. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  24042. * @param p1 (Vector3) the origin point of the Hermite Spline
  24043. * @param t1 (Vector3) the tangent vector at the origin point
  24044. * @param p2 (Vector3) the end point of the Hermite Spline
  24045. * @param t2 (Vector3) the tangent vector at the end point
  24046. * @param nbPoints (integer) the wanted number of points in the curve
  24047. * @returns the created Curve3
  24048. */
  24049. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24050. /**
  24051. * Returns a Curve3 object along a CatmullRom Spline curve :
  24052. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  24053. * @param nbPoints (integer) the wanted number of points between each curve control points
  24054. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  24055. * @returns the created Curve3
  24056. */
  24057. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  24058. /**
  24059. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  24060. * A Curve3 is designed from a series of successive Vector3.
  24061. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  24062. * @param points points which make up the curve
  24063. */
  24064. constructor(points: Vector3[]);
  24065. /**
  24066. * @returns the Curve3 stored array of successive Vector3
  24067. */
  24068. getPoints(): Vector3[];
  24069. /**
  24070. * @returns the computed length (float) of the curve.
  24071. */
  24072. length(): number;
  24073. /**
  24074. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  24075. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  24076. * curveA and curveB keep unchanged.
  24077. * @param curve the curve to continue from this curve
  24078. * @returns the newly constructed curve
  24079. */
  24080. continue(curve: DeepImmutable<Curve3>): Curve3;
  24081. private _computeLength;
  24082. }
  24083. /**
  24084. * Contains position and normal vectors for a vertex
  24085. */
  24086. class PositionNormalVertex {
  24087. /** the position of the vertex (defaut: 0,0,0) */
  24088. position: Vector3;
  24089. /** the normal of the vertex (defaut: 0,1,0) */
  24090. normal: Vector3;
  24091. /**
  24092. * Creates a PositionNormalVertex
  24093. * @param position the position of the vertex (defaut: 0,0,0)
  24094. * @param normal the normal of the vertex (defaut: 0,1,0)
  24095. */
  24096. constructor(
  24097. /** the position of the vertex (defaut: 0,0,0) */
  24098. position?: Vector3,
  24099. /** the normal of the vertex (defaut: 0,1,0) */
  24100. normal?: Vector3);
  24101. /**
  24102. * Clones the PositionNormalVertex
  24103. * @returns the cloned PositionNormalVertex
  24104. */
  24105. clone(): PositionNormalVertex;
  24106. }
  24107. /**
  24108. * Contains position, normal and uv vectors for a vertex
  24109. */
  24110. class PositionNormalTextureVertex {
  24111. /** the position of the vertex (defaut: 0,0,0) */
  24112. position: Vector3;
  24113. /** the normal of the vertex (defaut: 0,1,0) */
  24114. normal: Vector3;
  24115. /** the uv of the vertex (default: 0,0) */
  24116. uv: Vector2;
  24117. /**
  24118. * Creates a PositionNormalTextureVertex
  24119. * @param position the position of the vertex (defaut: 0,0,0)
  24120. * @param normal the normal of the vertex (defaut: 0,1,0)
  24121. * @param uv the uv of the vertex (default: 0,0)
  24122. */
  24123. constructor(
  24124. /** the position of the vertex (defaut: 0,0,0) */
  24125. position?: Vector3,
  24126. /** the normal of the vertex (defaut: 0,1,0) */
  24127. normal?: Vector3,
  24128. /** the uv of the vertex (default: 0,0) */
  24129. uv?: Vector2);
  24130. /**
  24131. * Clones the PositionNormalTextureVertex
  24132. * @returns the cloned PositionNormalTextureVertex
  24133. */
  24134. clone(): PositionNormalTextureVertex;
  24135. }
  24136. /**
  24137. * @hidden
  24138. */
  24139. class Tmp {
  24140. static Color3: Color3[];
  24141. static Color4: Color4[];
  24142. static Vector2: Vector2[];
  24143. static Vector3: Vector3[];
  24144. static Vector4: Vector4[];
  24145. static Quaternion: Quaternion[];
  24146. static Matrix: Matrix[];
  24147. }
  24148. }
  24149. declare module BABYLON {
  24150. /**
  24151. * Class representing spherical polynomial coefficients to the 3rd degree
  24152. */
  24153. class SphericalPolynomial {
  24154. /**
  24155. * The x coefficients of the spherical polynomial
  24156. */
  24157. x: Vector3;
  24158. /**
  24159. * The y coefficients of the spherical polynomial
  24160. */
  24161. y: Vector3;
  24162. /**
  24163. * The z coefficients of the spherical polynomial
  24164. */
  24165. z: Vector3;
  24166. /**
  24167. * The xx coefficients of the spherical polynomial
  24168. */
  24169. xx: Vector3;
  24170. /**
  24171. * The yy coefficients of the spherical polynomial
  24172. */
  24173. yy: Vector3;
  24174. /**
  24175. * The zz coefficients of the spherical polynomial
  24176. */
  24177. zz: Vector3;
  24178. /**
  24179. * The xy coefficients of the spherical polynomial
  24180. */
  24181. xy: Vector3;
  24182. /**
  24183. * The yz coefficients of the spherical polynomial
  24184. */
  24185. yz: Vector3;
  24186. /**
  24187. * The zx coefficients of the spherical polynomial
  24188. */
  24189. zx: Vector3;
  24190. /**
  24191. * Adds an ambient color to the spherical polynomial
  24192. * @param color the color to add
  24193. */
  24194. addAmbient(color: Color3): void;
  24195. /**
  24196. * Scales the spherical polynomial by the given amount
  24197. * @param scale the amount to scale
  24198. */
  24199. scale(scale: number): void;
  24200. /**
  24201. * Gets the spherical polynomial from harmonics
  24202. * @param harmonics the spherical harmonics
  24203. * @returns the spherical polynomial
  24204. */
  24205. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  24206. /**
  24207. * Constructs a spherical polynomial from an array.
  24208. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  24209. * @returns the spherical polynomial
  24210. */
  24211. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  24212. }
  24213. /**
  24214. * Class representing spherical harmonics coefficients to the 3rd degree
  24215. */
  24216. class SphericalHarmonics {
  24217. /**
  24218. * The l0,0 coefficients of the spherical harmonics
  24219. */
  24220. l00: Vector3;
  24221. /**
  24222. * The l1,-1 coefficients of the spherical harmonics
  24223. */
  24224. l1_1: Vector3;
  24225. /**
  24226. * The l1,0 coefficients of the spherical harmonics
  24227. */
  24228. l10: Vector3;
  24229. /**
  24230. * The l1,1 coefficients of the spherical harmonics
  24231. */
  24232. l11: Vector3;
  24233. /**
  24234. * The l2,-2 coefficients of the spherical harmonics
  24235. */
  24236. l2_2: Vector3;
  24237. /**
  24238. * The l2,-1 coefficients of the spherical harmonics
  24239. */
  24240. l2_1: Vector3;
  24241. /**
  24242. * The l2,0 coefficients of the spherical harmonics
  24243. */
  24244. l20: Vector3;
  24245. /**
  24246. * The l2,1 coefficients of the spherical harmonics
  24247. */
  24248. l21: Vector3;
  24249. /**
  24250. * The l2,2 coefficients of the spherical harmonics
  24251. */
  24252. lL22: Vector3;
  24253. /**
  24254. * Adds a light to the spherical harmonics
  24255. * @param direction the direction of the light
  24256. * @param color the color of the light
  24257. * @param deltaSolidAngle the delta solid angle of the light
  24258. */
  24259. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  24260. /**
  24261. * Scales the spherical harmonics by the given amount
  24262. * @param scale the amount to scale
  24263. */
  24264. scale(scale: number): void;
  24265. /**
  24266. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  24267. *
  24268. * ```
  24269. * E_lm = A_l * L_lm
  24270. * ```
  24271. *
  24272. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  24273. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  24274. * the scaling factors are given in equation 9.
  24275. */
  24276. convertIncidentRadianceToIrradiance(): void;
  24277. /**
  24278. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  24279. *
  24280. * ```
  24281. * L = (1/pi) * E * rho
  24282. * ```
  24283. *
  24284. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  24285. */
  24286. convertIrradianceToLambertianRadiance(): void;
  24287. /**
  24288. * Gets the spherical harmonics from polynomial
  24289. * @param polynomial the spherical polynomial
  24290. * @returns the spherical harmonics
  24291. */
  24292. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  24293. /**
  24294. * Constructs a spherical harmonics from an array.
  24295. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  24296. * @returns the spherical harmonics
  24297. */
  24298. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  24299. }
  24300. }
  24301. declare module BABYLON {
  24302. /**
  24303. * Class used to store all common mesh properties
  24304. */
  24305. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24306. /** No occlusion */
  24307. static OCCLUSION_TYPE_NONE: number;
  24308. /** Occlusion set to optimisitic */
  24309. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24310. /** Occlusion set to strict */
  24311. static OCCLUSION_TYPE_STRICT: number;
  24312. /** Use an accurante occlusion algorithm */
  24313. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24314. /** Use a conservative occlusion algorithm */
  24315. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24316. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  24317. static readonly CULLINGSTRATEGY_STANDARD: number;
  24318. /** Culling strategy with bounding sphere only and then frustum culling */
  24319. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24320. /**
  24321. * No billboard
  24322. */
  24323. static readonly BILLBOARDMODE_NONE: number;
  24324. /** Billboard on X axis */
  24325. static readonly BILLBOARDMODE_X: number;
  24326. /** Billboard on Y axis */
  24327. static readonly BILLBOARDMODE_Y: number;
  24328. /** Billboard on Z axis */
  24329. static readonly BILLBOARDMODE_Z: number;
  24330. /** Billboard on all axes */
  24331. static readonly BILLBOARDMODE_ALL: number;
  24332. private _facetData;
  24333. /** Gets ot sets the culling strategy to use to find visible meshes */
  24334. cullingStrategy: number;
  24335. /**
  24336. * Gets the number of facets in the mesh
  24337. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24338. */
  24339. readonly facetNb: number;
  24340. /**
  24341. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24342. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24343. */
  24344. partitioningSubdivisions: number;
  24345. /**
  24346. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24347. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24348. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24349. */
  24350. partitioningBBoxRatio: number;
  24351. /**
  24352. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24353. * Works only for updatable meshes.
  24354. * Doesn't work with multi-materials
  24355. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24356. */
  24357. mustDepthSortFacets: boolean;
  24358. /**
  24359. * The location (Vector3) where the facet depth sort must be computed from.
  24360. * By default, the active camera position.
  24361. * Used only when facet depth sort is enabled
  24362. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24363. */
  24364. facetDepthSortFrom: Vector3;
  24365. /**
  24366. * gets a boolean indicating if facetData is enabled
  24367. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24368. */
  24369. readonly isFacetDataEnabled: boolean;
  24370. /** @hidden */
  24371. _updateNonUniformScalingState(value: boolean): boolean;
  24372. /**
  24373. * An event triggered when this mesh collides with another one
  24374. */
  24375. onCollideObservable: Observable<AbstractMesh>;
  24376. private _onCollideObserver;
  24377. /** Set a function to call when this mesh collides with another one */
  24378. onCollide: () => void;
  24379. /**
  24380. * An event triggered when the collision's position changes
  24381. */
  24382. onCollisionPositionChangeObservable: Observable<Vector3>;
  24383. private _onCollisionPositionChangeObserver;
  24384. /** Set a function to call when the collision's position changes */
  24385. onCollisionPositionChange: () => void;
  24386. /**
  24387. * An event triggered when material is changed
  24388. */
  24389. onMaterialChangedObservable: Observable<AbstractMesh>;
  24390. /**
  24391. * Gets or sets the orientation for POV movement & rotation
  24392. */
  24393. definedFacingForward: boolean;
  24394. /** @hidden */
  24395. _occlusionQuery: Nullable<WebGLQuery>;
  24396. private _visibility;
  24397. /**
  24398. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24399. */
  24400. /**
  24401. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24402. */
  24403. visibility: number;
  24404. /** Gets or sets the alpha index used to sort transparent meshes
  24405. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24406. */
  24407. alphaIndex: number;
  24408. /**
  24409. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24410. */
  24411. isVisible: boolean;
  24412. /**
  24413. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24414. */
  24415. isPickable: boolean;
  24416. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24417. showSubMeshesBoundingBox: boolean;
  24418. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24419. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24420. */
  24421. isBlocker: boolean;
  24422. /**
  24423. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24424. */
  24425. enablePointerMoveEvents: boolean;
  24426. /**
  24427. * Specifies the rendering group id for this mesh (0 by default)
  24428. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24429. */
  24430. renderingGroupId: number;
  24431. private _material;
  24432. /** Gets or sets current material */
  24433. material: Nullable<Material>;
  24434. private _receiveShadows;
  24435. /**
  24436. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24437. * @see http://doc.babylonjs.com/babylon101/shadows
  24438. */
  24439. receiveShadows: boolean;
  24440. /** Defines color to use when rendering outline */
  24441. outlineColor: Color3;
  24442. /** Define width to use when rendering outline */
  24443. outlineWidth: number;
  24444. /** Defines color to use when rendering overlay */
  24445. overlayColor: Color3;
  24446. /** Defines alpha to use when rendering overlay */
  24447. overlayAlpha: number;
  24448. private _hasVertexAlpha;
  24449. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24450. hasVertexAlpha: boolean;
  24451. private _useVertexColors;
  24452. /** 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) */
  24453. useVertexColors: boolean;
  24454. private _computeBonesUsingShaders;
  24455. /**
  24456. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24457. */
  24458. computeBonesUsingShaders: boolean;
  24459. private _numBoneInfluencers;
  24460. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24461. numBoneInfluencers: number;
  24462. private _applyFog;
  24463. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24464. applyFog: boolean;
  24465. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24466. useOctreeForRenderingSelection: boolean;
  24467. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24468. useOctreeForPicking: boolean;
  24469. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24470. useOctreeForCollisions: boolean;
  24471. private _layerMask;
  24472. /**
  24473. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24474. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24475. */
  24476. layerMask: number;
  24477. /**
  24478. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24479. */
  24480. alwaysSelectAsActiveMesh: boolean;
  24481. /**
  24482. * Gets or sets the current action manager
  24483. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24484. */
  24485. actionManager: Nullable<ActionManager>;
  24486. private _checkCollisions;
  24487. private _collisionMask;
  24488. private _collisionGroup;
  24489. /**
  24490. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24491. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24492. */
  24493. ellipsoid: Vector3;
  24494. /**
  24495. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24496. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24497. */
  24498. ellipsoidOffset: Vector3;
  24499. private _collider;
  24500. private _oldPositionForCollisions;
  24501. private _diffPositionForCollisions;
  24502. /**
  24503. * Gets or sets a collision mask used to mask collisions (default is -1).
  24504. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24505. */
  24506. collisionMask: number;
  24507. /**
  24508. * Gets or sets the current collision group mask (-1 by default).
  24509. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24510. */
  24511. collisionGroup: number;
  24512. /**
  24513. * Defines edge width used when edgesRenderer is enabled
  24514. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24515. */
  24516. edgesWidth: number;
  24517. /**
  24518. * Defines edge color used when edgesRenderer is enabled
  24519. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24520. */
  24521. edgesColor: Color4;
  24522. /** @hidden */
  24523. _edgesRenderer: Nullable<IEdgesRenderer>;
  24524. /** @hidden */
  24525. _masterMesh: Nullable<AbstractMesh>;
  24526. /** @hidden */
  24527. _boundingInfo: Nullable<BoundingInfo>;
  24528. /** @hidden */
  24529. _renderId: number;
  24530. /**
  24531. * Gets or sets the list of subMeshes
  24532. * @see http://doc.babylonjs.com/how_to/multi_materials
  24533. */
  24534. subMeshes: SubMesh[];
  24535. /** @hidden */
  24536. _intersectionsInProgress: AbstractMesh[];
  24537. /** @hidden */
  24538. _unIndexed: boolean;
  24539. /** @hidden */
  24540. _lightSources: Light[];
  24541. /** @hidden */
  24542. readonly _positions: Nullable<Vector3[]>;
  24543. /** @hidden */
  24544. _waitingActions: any;
  24545. /** @hidden */
  24546. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24547. private _skeleton;
  24548. /** @hidden */
  24549. _bonesTransformMatrices: Nullable<Float32Array>;
  24550. /**
  24551. * Gets or sets a skeleton to apply skining transformations
  24552. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24553. */
  24554. skeleton: Nullable<Skeleton>;
  24555. /**
  24556. * An event triggered when the mesh is rebuilt.
  24557. */
  24558. onRebuildObservable: Observable<AbstractMesh>;
  24559. /**
  24560. * Creates a new AbstractMesh
  24561. * @param name defines the name of the mesh
  24562. * @param scene defines the hosting scene
  24563. */
  24564. constructor(name: string, scene?: Nullable<Scene>);
  24565. /**
  24566. * Returns the string "AbstractMesh"
  24567. * @returns "AbstractMesh"
  24568. */
  24569. getClassName(): string;
  24570. /**
  24571. * Gets a string representation of the current mesh
  24572. * @param fullDetails defines a boolean indicating if full details must be included
  24573. * @returns a string representation of the current mesh
  24574. */
  24575. toString(fullDetails?: boolean): string;
  24576. /** @hidden */
  24577. _rebuild(): void;
  24578. /** @hidden */
  24579. _resyncLightSources(): void;
  24580. /** @hidden */
  24581. _resyncLighSource(light: Light): void;
  24582. /** @hidden */
  24583. _unBindEffect(): void;
  24584. /** @hidden */
  24585. _removeLightSource(light: Light): void;
  24586. private _markSubMeshesAsDirty;
  24587. /** @hidden */
  24588. _markSubMeshesAsLightDirty(): void;
  24589. /** @hidden */
  24590. _markSubMeshesAsAttributesDirty(): void;
  24591. /** @hidden */
  24592. _markSubMeshesAsMiscDirty(): void;
  24593. /**
  24594. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24595. */
  24596. scaling: Vector3;
  24597. /**
  24598. * Returns true if the mesh is blocked. Implemented by child classes
  24599. */
  24600. readonly isBlocked: boolean;
  24601. /**
  24602. * Returns the mesh itself by default. Implemented by child classes
  24603. * @param camera defines the camera to use to pick the right LOD level
  24604. * @returns the currentAbstractMesh
  24605. */
  24606. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24607. /**
  24608. * Returns 0 by default. Implemented by child classes
  24609. * @returns an integer
  24610. */
  24611. getTotalVertices(): number;
  24612. /**
  24613. * Returns a positive integer : the total number of indices in this mesh geometry.
  24614. * @returns the numner of indices or zero if the mesh has no geometry.
  24615. */
  24616. getTotalIndices(): number;
  24617. /**
  24618. * Returns null by default. Implemented by child classes
  24619. * @returns null
  24620. */
  24621. getIndices(): Nullable<IndicesArray>;
  24622. /**
  24623. * Returns the array of the requested vertex data kind. Implemented by child classes
  24624. * @param kind defines the vertex data kind to use
  24625. * @returns null
  24626. */
  24627. getVerticesData(kind: string): Nullable<FloatArray>;
  24628. /**
  24629. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24630. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24631. * Note that a new underlying VertexBuffer object is created each call.
  24632. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24633. * @param kind defines vertex data kind:
  24634. * * BABYLON.VertexBuffer.PositionKind
  24635. * * BABYLON.VertexBuffer.UVKind
  24636. * * BABYLON.VertexBuffer.UV2Kind
  24637. * * BABYLON.VertexBuffer.UV3Kind
  24638. * * BABYLON.VertexBuffer.UV4Kind
  24639. * * BABYLON.VertexBuffer.UV5Kind
  24640. * * BABYLON.VertexBuffer.UV6Kind
  24641. * * BABYLON.VertexBuffer.ColorKind
  24642. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24643. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24644. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24645. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24646. * @param data defines the data source
  24647. * @param updatable defines if the data must be flagged as updatable (or static)
  24648. * @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
  24649. * @returns the current mesh
  24650. */
  24651. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24652. /**
  24653. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24654. * If the mesh has no geometry, it is simply returned as it is.
  24655. * @param kind defines vertex data kind:
  24656. * * BABYLON.VertexBuffer.PositionKind
  24657. * * BABYLON.VertexBuffer.UVKind
  24658. * * BABYLON.VertexBuffer.UV2Kind
  24659. * * BABYLON.VertexBuffer.UV3Kind
  24660. * * BABYLON.VertexBuffer.UV4Kind
  24661. * * BABYLON.VertexBuffer.UV5Kind
  24662. * * BABYLON.VertexBuffer.UV6Kind
  24663. * * BABYLON.VertexBuffer.ColorKind
  24664. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24665. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24666. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24667. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24668. * @param data defines the data source
  24669. * @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
  24670. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24671. * @returns the current mesh
  24672. */
  24673. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24674. /**
  24675. * Sets the mesh indices,
  24676. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24677. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24678. * @param totalVertices Defines the total number of vertices
  24679. * @returns the current mesh
  24680. */
  24681. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24682. /**
  24683. * Gets a boolean indicating if specific vertex data is present
  24684. * @param kind defines the vertex data kind to use
  24685. * @returns true is data kind is present
  24686. */
  24687. isVerticesDataPresent(kind: string): boolean;
  24688. /**
  24689. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24690. * @returns a BoundingInfo
  24691. */
  24692. getBoundingInfo(): BoundingInfo;
  24693. /**
  24694. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24695. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24696. * @returns the current mesh
  24697. */
  24698. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24699. /**
  24700. * Overwrite the current bounding info
  24701. * @param boundingInfo defines the new bounding info
  24702. * @returns the current mesh
  24703. */
  24704. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24705. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24706. readonly useBones: boolean;
  24707. /** @hidden */
  24708. _preActivate(): void;
  24709. /** @hidden */
  24710. _preActivateForIntermediateRendering(renderId: number): void;
  24711. /** @hidden */
  24712. _activate(renderId: number): void;
  24713. /**
  24714. * Gets the current world matrix
  24715. * @returns a Matrix
  24716. */
  24717. getWorldMatrix(): Matrix;
  24718. /** @hidden */
  24719. _getWorldMatrixDeterminant(): number;
  24720. /**
  24721. * Perform relative position change from the point of view of behind the front of the mesh.
  24722. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24723. * Supports definition of mesh facing forward or backward
  24724. * @param amountRight defines the distance on the right axis
  24725. * @param amountUp defines the distance on the up axis
  24726. * @param amountForward defines the distance on the forward axis
  24727. * @returns the current mesh
  24728. */
  24729. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24730. /**
  24731. * Calculate relative position change from the point of view of behind the front of the mesh.
  24732. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24733. * Supports definition of mesh facing forward or backward
  24734. * @param amountRight defines the distance on the right axis
  24735. * @param amountUp defines the distance on the up axis
  24736. * @param amountForward defines the distance on the forward axis
  24737. * @returns the new displacement vector
  24738. */
  24739. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24740. /**
  24741. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24742. * Supports definition of mesh facing forward or backward
  24743. * @param flipBack defines the flip
  24744. * @param twirlClockwise defines the twirl
  24745. * @param tiltRight defines the tilt
  24746. * @returns the current mesh
  24747. */
  24748. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24749. /**
  24750. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24751. * Supports definition of mesh facing forward or backward.
  24752. * @param flipBack defines the flip
  24753. * @param twirlClockwise defines the twirl
  24754. * @param tiltRight defines the tilt
  24755. * @returns the new rotation vector
  24756. */
  24757. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24758. /**
  24759. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24760. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24761. * @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
  24762. * @returns the new bounding vectors
  24763. */
  24764. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24765. min: Vector3;
  24766. max: Vector3;
  24767. };
  24768. /**
  24769. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24770. * This means the mesh underlying bounding box and sphere are recomputed.
  24771. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24772. * @returns the current mesh
  24773. */
  24774. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24775. /** @hidden */
  24776. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24777. /** @hidden */
  24778. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24779. /** @hidden */
  24780. _updateBoundingInfo(): AbstractMesh;
  24781. /** @hidden */
  24782. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24783. /** @hidden */
  24784. protected _afterComputeWorldMatrix(): void;
  24785. /**
  24786. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24787. * A mesh is in the frustum if its bounding box intersects the frustum
  24788. * @param frustumPlanes defines the frustum to test
  24789. * @returns true if the mesh is in the frustum planes
  24790. */
  24791. isInFrustum(frustumPlanes: Plane[]): boolean;
  24792. /**
  24793. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24794. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24795. * @param frustumPlanes defines the frustum to test
  24796. * @returns true if the mesh is completely in the frustum planes
  24797. */
  24798. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24799. /**
  24800. * True if the mesh intersects another mesh or a SolidParticle object
  24801. * @param mesh defines a target mesh or SolidParticle to test
  24802. * @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)
  24803. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24804. * @returns true if there is an intersection
  24805. */
  24806. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24807. /**
  24808. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24809. * @param point defines the point to test
  24810. * @returns true if there is an intersection
  24811. */
  24812. intersectsPoint(point: Vector3): boolean;
  24813. /**
  24814. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24815. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24816. */
  24817. checkCollisions: boolean;
  24818. /**
  24819. * Gets Collider object used to compute collisions (not physics)
  24820. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24821. */
  24822. readonly collider: Collider;
  24823. /**
  24824. * Move the mesh using collision engine
  24825. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24826. * @param displacement defines the requested displacement vector
  24827. * @returns the current mesh
  24828. */
  24829. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24830. private _onCollisionPositionChange;
  24831. /** @hidden */
  24832. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24833. /** @hidden */
  24834. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24835. /** @hidden */
  24836. _checkCollision(collider: Collider): AbstractMesh;
  24837. /** @hidden */
  24838. _generatePointsArray(): boolean;
  24839. /**
  24840. * Checks if the passed Ray intersects with the mesh
  24841. * @param ray defines the ray to use
  24842. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24843. * @returns the picking info
  24844. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24845. */
  24846. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24847. /**
  24848. * Clones the current mesh
  24849. * @param name defines the mesh name
  24850. * @param newParent defines the new mesh parent
  24851. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24852. * @returns the new mesh
  24853. */
  24854. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24855. /**
  24856. * Disposes all the submeshes of the current meshnp
  24857. * @returns the current mesh
  24858. */
  24859. releaseSubMeshes(): AbstractMesh;
  24860. /**
  24861. * Releases resources associated with this abstract mesh.
  24862. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24863. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24864. */
  24865. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24866. /**
  24867. * Adds the passed mesh as a child to the current mesh
  24868. * @param mesh defines the child mesh
  24869. * @returns the current mesh
  24870. */
  24871. addChild(mesh: AbstractMesh): AbstractMesh;
  24872. /**
  24873. * Removes the passed mesh from the current mesh children list
  24874. * @param mesh defines the child mesh
  24875. * @returns the current mesh
  24876. */
  24877. removeChild(mesh: AbstractMesh): AbstractMesh;
  24878. /** @hidden */
  24879. private _initFacetData;
  24880. /**
  24881. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24882. * This method can be called within the render loop.
  24883. * 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
  24884. * @returns the current mesh
  24885. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24886. */
  24887. updateFacetData(): AbstractMesh;
  24888. /**
  24889. * Returns the facetLocalNormals array.
  24890. * The normals are expressed in the mesh local spac
  24891. * @returns an array of Vector3
  24892. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24893. */
  24894. getFacetLocalNormals(): Vector3[];
  24895. /**
  24896. * Returns the facetLocalPositions array.
  24897. * The facet positions are expressed in the mesh local space
  24898. * @returns an array of Vector3
  24899. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24900. */
  24901. getFacetLocalPositions(): Vector3[];
  24902. /**
  24903. * Returns the facetLocalPartioning array
  24904. * @returns an array of array of numbers
  24905. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24906. */
  24907. getFacetLocalPartitioning(): number[][];
  24908. /**
  24909. * Returns the i-th facet position in the world system.
  24910. * This method allocates a new Vector3 per call
  24911. * @param i defines the facet index
  24912. * @returns a new Vector3
  24913. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24914. */
  24915. getFacetPosition(i: number): Vector3;
  24916. /**
  24917. * Sets the reference Vector3 with the i-th facet position in the world system
  24918. * @param i defines the facet index
  24919. * @param ref defines the target vector
  24920. * @returns the current mesh
  24921. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24922. */
  24923. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24924. /**
  24925. * Returns the i-th facet normal in the world system.
  24926. * This method allocates a new Vector3 per call
  24927. * @param i defines the facet index
  24928. * @returns a new Vector3
  24929. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24930. */
  24931. getFacetNormal(i: number): Vector3;
  24932. /**
  24933. * Sets the reference Vector3 with the i-th facet normal in the world system
  24934. * @param i defines the facet index
  24935. * @param ref defines the target vector
  24936. * @returns the current mesh
  24937. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24938. */
  24939. getFacetNormalToRef(i: number, ref: Vector3): this;
  24940. /**
  24941. * 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)
  24942. * @param x defines x coordinate
  24943. * @param y defines y coordinate
  24944. * @param z defines z coordinate
  24945. * @returns the array of facet indexes
  24946. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24947. */
  24948. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24949. /**
  24950. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24951. * @param projected sets as the (x,y,z) world projection on the facet
  24952. * @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
  24953. * @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
  24954. * @param x defines x coordinate
  24955. * @param y defines y coordinate
  24956. * @param z defines z coordinate
  24957. * @returns the face index if found (or null instead)
  24958. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24959. */
  24960. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24961. /**
  24962. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24963. * @param projected sets as the (x,y,z) local projection on the facet
  24964. * @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
  24965. * @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
  24966. * @param x defines x coordinate
  24967. * @param y defines y coordinate
  24968. * @param z defines z coordinate
  24969. * @returns the face index if found (or null instead)
  24970. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24971. */
  24972. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24973. /**
  24974. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24975. * @returns the parameters
  24976. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24977. */
  24978. getFacetDataParameters(): any;
  24979. /**
  24980. * Disables the feature FacetData and frees the related memory
  24981. * @returns the current mesh
  24982. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24983. */
  24984. disableFacetData(): AbstractMesh;
  24985. /**
  24986. * Updates the AbstractMesh indices array
  24987. * @param indices defines the data source
  24988. * @returns the current mesh
  24989. */
  24990. updateIndices(indices: IndicesArray): AbstractMesh;
  24991. /**
  24992. * Creates new normals data for the mesh
  24993. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24994. * @returns the current mesh
  24995. */
  24996. createNormals(updatable: boolean): AbstractMesh;
  24997. /**
  24998. * Align the mesh with a normal
  24999. * @param normal defines the normal to use
  25000. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25001. * @returns the current mesh
  25002. */
  25003. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25004. /** @hidden */
  25005. _checkOcclusionQuery(): boolean;
  25006. }
  25007. }
  25008. declare module BABYLON {
  25009. /**
  25010. * Class used to store data that will be store in GPU memory
  25011. */
  25012. class Buffer {
  25013. private _engine;
  25014. private _buffer;
  25015. /** @hidden */
  25016. _data: Nullable<DataArray>;
  25017. private _updatable;
  25018. private _instanced;
  25019. /**
  25020. * Gets the byte stride.
  25021. */
  25022. readonly byteStride: number;
  25023. /**
  25024. * Constructor
  25025. * @param engine the engine
  25026. * @param data the data to use for this buffer
  25027. * @param updatable whether the data is updatable
  25028. * @param stride the stride (optional)
  25029. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  25030. * @param instanced whether the buffer is instanced (optional)
  25031. * @param useBytes set to true if the stride in in bytes (optional)
  25032. */
  25033. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  25034. /**
  25035. * Create a new VertexBuffer based on the current buffer
  25036. * @param kind defines the vertex buffer kind (position, normal, etc.)
  25037. * @param offset defines offset in the buffer (0 by default)
  25038. * @param size defines the size in floats of attributes (position is 3 for instance)
  25039. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  25040. * @param instanced defines if the vertex buffer contains indexed data
  25041. * @param useBytes defines if the offset and stride are in bytes
  25042. * @returns the new vertex buffer
  25043. */
  25044. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  25045. /**
  25046. * Gets a boolean indicating if the Buffer is updatable?
  25047. * @returns true if the buffer is updatable
  25048. */
  25049. isUpdatable(): boolean;
  25050. /**
  25051. * Gets current buffer's data
  25052. * @returns a DataArray or null
  25053. */
  25054. getData(): Nullable<DataArray>;
  25055. /**
  25056. * Gets underlying native buffer
  25057. * @returns underlying native buffer
  25058. */
  25059. getBuffer(): Nullable<WebGLBuffer>;
  25060. /**
  25061. * Gets the stride in float32 units (i.e. byte stride / 4).
  25062. * May not be an integer if the byte stride is not divisible by 4.
  25063. * DEPRECATED. Use byteStride instead.
  25064. * @returns the stride in float32 units
  25065. */
  25066. getStrideSize(): number;
  25067. /**
  25068. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  25069. * @param data defines the data to store
  25070. */
  25071. create(data?: Nullable<DataArray>): void;
  25072. /** @hidden */
  25073. _rebuild(): void;
  25074. /**
  25075. * Update current buffer data
  25076. * @param data defines the data to store
  25077. */
  25078. update(data: DataArray): void;
  25079. /**
  25080. * Updates the data directly.
  25081. * @param data the new data
  25082. * @param offset the new offset
  25083. * @param vertexCount the vertex count (optional)
  25084. * @param useBytes set to true if the offset is in bytes
  25085. */
  25086. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  25087. /**
  25088. * Release all resources
  25089. */
  25090. dispose(): void;
  25091. }
  25092. }
  25093. declare module BABYLON {
  25094. /**
  25095. * Class for building Constructive Solid Geometry
  25096. */
  25097. class CSG {
  25098. private polygons;
  25099. /**
  25100. * The world matrix
  25101. */
  25102. matrix: Matrix;
  25103. /**
  25104. * Stores the position
  25105. */
  25106. position: Vector3;
  25107. /**
  25108. * Stores the rotation
  25109. */
  25110. rotation: Vector3;
  25111. /**
  25112. * Stores the rotation quaternion
  25113. */
  25114. rotationQuaternion: Nullable<Quaternion>;
  25115. /**
  25116. * Stores the scaling vector
  25117. */
  25118. scaling: Vector3;
  25119. /**
  25120. * Convert the BABYLON.Mesh to BABYLON.CSG
  25121. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  25122. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  25123. */
  25124. static FromMesh(mesh: Mesh): CSG;
  25125. /**
  25126. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  25127. * @param polygons Polygons used to construct a BABYLON.CSG solid
  25128. */
  25129. private static FromPolygons;
  25130. /**
  25131. * Clones, or makes a deep copy, of the BABYLON.CSG
  25132. * @returns A new BABYLON.CSG
  25133. */
  25134. clone(): CSG;
  25135. /**
  25136. * Unions this CSG with another CSG
  25137. * @param csg The CSG to union against this CSG
  25138. * @returns The unioned CSG
  25139. */
  25140. union(csg: CSG): CSG;
  25141. /**
  25142. * Unions this CSG with another CSG in place
  25143. * @param csg The CSG to union against this CSG
  25144. */
  25145. unionInPlace(csg: CSG): void;
  25146. /**
  25147. * Subtracts this CSG with another CSG
  25148. * @param csg The CSG to subtract against this CSG
  25149. * @returns A new BABYLON.CSG
  25150. */
  25151. subtract(csg: CSG): CSG;
  25152. /**
  25153. * Subtracts this CSG with another CSG in place
  25154. * @param csg The CSG to subtact against this CSG
  25155. */
  25156. subtractInPlace(csg: CSG): void;
  25157. /**
  25158. * Intersect this CSG with another CSG
  25159. * @param csg The CSG to intersect against this CSG
  25160. * @returns A new BABYLON.CSG
  25161. */
  25162. intersect(csg: CSG): CSG;
  25163. /**
  25164. * Intersects this CSG with another CSG in place
  25165. * @param csg The CSG to intersect against this CSG
  25166. */
  25167. intersectInPlace(csg: CSG): void;
  25168. /**
  25169. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  25170. * not modified.
  25171. * @returns A new BABYLON.CSG solid with solid and empty space switched
  25172. */
  25173. inverse(): CSG;
  25174. /**
  25175. * Inverses the BABYLON.CSG in place
  25176. */
  25177. inverseInPlace(): void;
  25178. /**
  25179. * This is used to keep meshes transformations so they can be restored
  25180. * when we build back a Babylon Mesh
  25181. * NB : All CSG operations are performed in world coordinates
  25182. * @param csg The BABYLON.CSG to copy the transform attributes from
  25183. * @returns This BABYLON.CSG
  25184. */
  25185. copyTransformAttributes(csg: CSG): CSG;
  25186. /**
  25187. * Build Raw mesh from CSG
  25188. * Coordinates here are in world space
  25189. * @param name The name of the mesh geometry
  25190. * @param scene The BABYLON.Scene
  25191. * @param keepSubMeshes Specifies if the submeshes should be kept
  25192. * @returns A new BABYLON.Mesh
  25193. */
  25194. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  25195. /**
  25196. * Build Mesh from CSG taking material and transforms into account
  25197. * @param name The name of the BABYLON.Mesh
  25198. * @param material The material of the BABYLON.Mesh
  25199. * @param scene The BABYLON.Scene
  25200. * @param keepSubMeshes Specifies if submeshes should be kept
  25201. * @returns The new BABYLON.Mesh
  25202. */
  25203. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  25204. }
  25205. }
  25206. declare module BABYLON {
  25207. /**
  25208. * Class used to store geometry data (vertex buffers + index buffer)
  25209. */
  25210. class Geometry implements IGetSetVerticesData {
  25211. /**
  25212. * Gets or sets the ID of the geometry
  25213. */
  25214. id: string;
  25215. /**
  25216. * Gets or sets the unique ID of the geometry
  25217. */
  25218. uniqueId: number;
  25219. /**
  25220. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25221. */
  25222. delayLoadState: number;
  25223. /**
  25224. * Gets the file containing the data to load when running in delay load state
  25225. */
  25226. delayLoadingFile: Nullable<string>;
  25227. /**
  25228. * Callback called when the geometry is updated
  25229. */
  25230. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25231. private _scene;
  25232. private _engine;
  25233. private _meshes;
  25234. private _totalVertices;
  25235. /** @hidden */
  25236. _indices: IndicesArray;
  25237. /** @hidden */
  25238. _vertexBuffers: {
  25239. [key: string]: VertexBuffer;
  25240. };
  25241. private _isDisposed;
  25242. private _extend;
  25243. private _boundingBias;
  25244. /** @hidden */
  25245. _delayInfo: Array<string>;
  25246. private _indexBuffer;
  25247. private _indexBufferIsUpdatable;
  25248. /** @hidden */
  25249. _boundingInfo: Nullable<BoundingInfo>;
  25250. /** @hidden */
  25251. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25252. /** @hidden */
  25253. _softwareSkinningFrameId: number;
  25254. private _vertexArrayObjects;
  25255. private _updatable;
  25256. /** @hidden */
  25257. _positions: Nullable<Vector3[]>;
  25258. /**
  25259. * 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
  25260. */
  25261. /**
  25262. * 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
  25263. */
  25264. boundingBias: Vector2;
  25265. /**
  25266. * Static function used to attach a new empty geometry to a mesh
  25267. * @param mesh defines the mesh to attach the geometry to
  25268. * @returns the new Geometry
  25269. */
  25270. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25271. /**
  25272. * Creates a new geometry
  25273. * @param id defines the unique ID
  25274. * @param scene defines the hosting scene
  25275. * @param vertexData defines the VertexData used to get geometry data
  25276. * @param updatable defines if geometry must be updatable (false by default)
  25277. * @param mesh defines the mesh that will be associated with the geometry
  25278. */
  25279. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25280. /**
  25281. * Gets the current extend of the geometry
  25282. */
  25283. readonly extend: {
  25284. minimum: Vector3;
  25285. maximum: Vector3;
  25286. };
  25287. /**
  25288. * Gets the hosting scene
  25289. * @returns the hosting Scene
  25290. */
  25291. getScene(): Scene;
  25292. /**
  25293. * Gets the hosting engine
  25294. * @returns the hosting Engine
  25295. */
  25296. getEngine(): Engine;
  25297. /**
  25298. * Defines if the geometry is ready to use
  25299. * @returns true if the geometry is ready to be used
  25300. */
  25301. isReady(): boolean;
  25302. /**
  25303. * Gets a value indicating that the geometry should not be serialized
  25304. */
  25305. readonly doNotSerialize: boolean;
  25306. /** @hidden */
  25307. _rebuild(): void;
  25308. /**
  25309. * Affects all geometry data in one call
  25310. * @param vertexData defines the geometry data
  25311. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25312. */
  25313. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25314. /**
  25315. * Set specific vertex data
  25316. * @param kind defines the data kind (Position, normal, etc...)
  25317. * @param data defines the vertex data to use
  25318. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25319. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25320. */
  25321. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25322. /**
  25323. * Removes a specific vertex data
  25324. * @param kind defines the data kind (Position, normal, etc...)
  25325. */
  25326. removeVerticesData(kind: string): void;
  25327. /**
  25328. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25329. * @param buffer defines the vertex buffer to use
  25330. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25331. */
  25332. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25333. /**
  25334. * Update a specific vertex buffer
  25335. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25336. * It will do nothing if the buffer is not updatable
  25337. * @param kind defines the data kind (Position, normal, etc...)
  25338. * @param data defines the data to use
  25339. * @param offset defines the offset in the target buffer where to store the data
  25340. * @param useBytes set to true if the offset is in bytes
  25341. */
  25342. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25343. /**
  25344. * Update a specific vertex buffer
  25345. * This function will create a new buffer if the current one is not updatable
  25346. * @param kind defines the data kind (Position, normal, etc...)
  25347. * @param data defines the data to use
  25348. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25349. */
  25350. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25351. private _updateBoundingInfo;
  25352. /** @hidden */
  25353. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25354. /**
  25355. * Gets total number of vertices
  25356. * @returns the total number of vertices
  25357. */
  25358. getTotalVertices(): number;
  25359. /**
  25360. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25361. * @param kind defines the data kind (Position, normal, etc...)
  25362. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25363. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25364. * @returns a float array containing vertex data
  25365. */
  25366. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25367. /**
  25368. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25369. * @param kind defines the data kind (Position, normal, etc...)
  25370. * @returns true if the vertex buffer with the specified kind is updatable
  25371. */
  25372. isVertexBufferUpdatable(kind: string): boolean;
  25373. /**
  25374. * Gets a specific vertex buffer
  25375. * @param kind defines the data kind (Position, normal, etc...)
  25376. * @returns a VertexBuffer
  25377. */
  25378. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25379. /**
  25380. * Returns all vertex buffers
  25381. * @return an object holding all vertex buffers indexed by kind
  25382. */
  25383. getVertexBuffers(): Nullable<{
  25384. [key: string]: VertexBuffer;
  25385. }>;
  25386. /**
  25387. * Gets a boolean indicating if specific vertex buffer is present
  25388. * @param kind defines the data kind (Position, normal, etc...)
  25389. * @returns true if data is present
  25390. */
  25391. isVerticesDataPresent(kind: string): boolean;
  25392. /**
  25393. * Gets a list of all attached data kinds (Position, normal, etc...)
  25394. * @returns a list of string containing all kinds
  25395. */
  25396. getVerticesDataKinds(): string[];
  25397. /**
  25398. * Update index buffer
  25399. * @param indices defines the indices to store in the index buffer
  25400. * @param offset defines the offset in the target buffer where to store the data
  25401. */
  25402. updateIndices(indices: IndicesArray, offset?: number): void;
  25403. /**
  25404. * Creates a new index buffer
  25405. * @param indices defines the indices to store in the index buffer
  25406. * @param totalVertices defines the total number of vertices (could be null)
  25407. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25408. */
  25409. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25410. /**
  25411. * Return the total number of indices
  25412. * @returns the total number of indices
  25413. */
  25414. getTotalIndices(): number;
  25415. /**
  25416. * Gets the index buffer array
  25417. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25418. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25419. * @returns the index buffer array
  25420. */
  25421. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25422. /**
  25423. * Gets the index buffer
  25424. * @return the index buffer
  25425. */
  25426. getIndexBuffer(): Nullable<WebGLBuffer>;
  25427. /** @hidden */
  25428. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25429. /**
  25430. * Release the associated resources for a specific mesh
  25431. * @param mesh defines the source mesh
  25432. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25433. */
  25434. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25435. /**
  25436. * Apply current geometry to a given mesh
  25437. * @param mesh defines the mesh to apply geometry to
  25438. */
  25439. applyToMesh(mesh: Mesh): void;
  25440. private _updateExtend;
  25441. private _applyToMesh;
  25442. private notifyUpdate;
  25443. /**
  25444. * Load the geometry if it was flagged as delay loaded
  25445. * @param scene defines the hosting scene
  25446. * @param onLoaded defines a callback called when the geometry is loaded
  25447. */
  25448. load(scene: Scene, onLoaded?: () => void): void;
  25449. private _queueLoad;
  25450. /**
  25451. * Invert the geometry to move from a right handed system to a left handed one.
  25452. */
  25453. toLeftHanded(): void;
  25454. /** @hidden */
  25455. _resetPointsArrayCache(): void;
  25456. /** @hidden */
  25457. _generatePointsArray(): boolean;
  25458. /**
  25459. * Gets a value indicating if the geometry is disposed
  25460. * @returns true if the geometry was disposed
  25461. */
  25462. isDisposed(): boolean;
  25463. private _disposeVertexArrayObjects;
  25464. /**
  25465. * Free all associated resources
  25466. */
  25467. dispose(): void;
  25468. /**
  25469. * Clone the current geometry into a new geometry
  25470. * @param id defines the unique ID of the new geometry
  25471. * @returns a new geometry object
  25472. */
  25473. copy(id: string): Geometry;
  25474. /**
  25475. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25476. * @return a JSON representation of the current geometry data (without the vertices data)
  25477. */
  25478. serialize(): any;
  25479. private toNumberArray;
  25480. /**
  25481. * Serialize all vertices data into a JSON oject
  25482. * @returns a JSON representation of the current geometry data
  25483. */
  25484. serializeVerticeData(): any;
  25485. /**
  25486. * Extracts a clone of a mesh geometry
  25487. * @param mesh defines the source mesh
  25488. * @param id defines the unique ID of the new geometry object
  25489. * @returns the new geometry object
  25490. */
  25491. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25492. /**
  25493. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25494. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25495. * Be aware Math.random() could cause collisions, but:
  25496. * "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"
  25497. * @returns a string containing a new GUID
  25498. */
  25499. static RandomId(): string;
  25500. /** @hidden */
  25501. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25502. private static _CleanMatricesWeights;
  25503. /**
  25504. * Create a new geometry from persisted data (Using .babylon file format)
  25505. * @param parsedVertexData defines the persisted data
  25506. * @param scene defines the hosting scene
  25507. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25508. * @returns the new geometry object
  25509. */
  25510. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25511. }
  25512. /**
  25513. * Abstract class used to provide common services for all typed geometries
  25514. * @hidden
  25515. */
  25516. class _PrimitiveGeometry extends Geometry {
  25517. private _canBeRegenerated;
  25518. private _beingRegenerated;
  25519. /**
  25520. * Creates a new typed geometry
  25521. * @param id defines the unique ID of the geometry
  25522. * @param scene defines the hosting scene
  25523. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25524. * @param mesh defines the hosting mesh (can be null)
  25525. */
  25526. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25527. /**
  25528. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25529. * @returns true if the geometry can be regenerated
  25530. */
  25531. canBeRegenerated(): boolean;
  25532. /**
  25533. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25534. */
  25535. regenerate(): void;
  25536. /**
  25537. * Clone the geometry
  25538. * @param id defines the unique ID of the new geometry
  25539. * @returns the new geometry
  25540. */
  25541. asNewGeometry(id: string): Geometry;
  25542. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25543. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25544. /** @hidden */
  25545. _regenerateVertexData(): VertexData;
  25546. copy(id: string): Geometry;
  25547. serialize(): any;
  25548. }
  25549. /**
  25550. * Creates a ribbon geometry
  25551. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25552. */
  25553. class RibbonGeometry extends _PrimitiveGeometry {
  25554. /**
  25555. * Defines the array of paths to use
  25556. */
  25557. pathArray: Vector3[][];
  25558. /**
  25559. * Defines if the last and first points of each path in your pathArray must be joined
  25560. */
  25561. closeArray: boolean;
  25562. /**
  25563. * Defines if the last and first points of each path in your pathArray must be joined
  25564. */
  25565. closePath: boolean;
  25566. /**
  25567. * Defines the offset between points
  25568. */
  25569. offset: number;
  25570. /**
  25571. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25572. */
  25573. side: number;
  25574. /**
  25575. * Creates a ribbon geometry
  25576. * @param id defines the unique ID of the geometry
  25577. * @param scene defines the hosting scene
  25578. * @param pathArray defines the array of paths to use
  25579. * @param closeArray defines if the last path and the first path must be joined
  25580. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25581. * @param offset defines the offset between points
  25582. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25583. * @param mesh defines the hosting mesh (can be null)
  25584. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25585. */
  25586. constructor(id: string, scene: Scene,
  25587. /**
  25588. * Defines the array of paths to use
  25589. */
  25590. pathArray: Vector3[][],
  25591. /**
  25592. * Defines if the last and first points of each path in your pathArray must be joined
  25593. */
  25594. closeArray: boolean,
  25595. /**
  25596. * Defines if the last and first points of each path in your pathArray must be joined
  25597. */
  25598. closePath: boolean,
  25599. /**
  25600. * Defines the offset between points
  25601. */
  25602. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25603. /**
  25604. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25605. */
  25606. side?: number);
  25607. /** @hidden */
  25608. _regenerateVertexData(): VertexData;
  25609. copy(id: string): Geometry;
  25610. }
  25611. /**
  25612. * Creates a box geometry
  25613. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25614. */
  25615. class BoxGeometry extends _PrimitiveGeometry {
  25616. /**
  25617. * Defines the zise of the box (width, height and depth are the same)
  25618. */
  25619. size: number;
  25620. /**
  25621. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25622. */
  25623. side: number;
  25624. /**
  25625. * Creates a box geometry
  25626. * @param id defines the unique ID of the geometry
  25627. * @param scene defines the hosting scene
  25628. * @param size defines the zise of the box (width, height and depth are the same)
  25629. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25630. * @param mesh defines the hosting mesh (can be null)
  25631. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25632. */
  25633. constructor(id: string, scene: Scene,
  25634. /**
  25635. * Defines the zise of the box (width, height and depth are the same)
  25636. */
  25637. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25638. /**
  25639. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25640. */
  25641. side?: number);
  25642. /** @hidden */
  25643. _regenerateVertexData(): VertexData;
  25644. copy(id: string): Geometry;
  25645. serialize(): any;
  25646. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25647. }
  25648. /**
  25649. * Creates a sphere geometry
  25650. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25651. */
  25652. class SphereGeometry extends _PrimitiveGeometry {
  25653. /**
  25654. * Defines the number of segments to use to create the sphere
  25655. */
  25656. segments: number;
  25657. /**
  25658. * Defines the diameter of the sphere
  25659. */
  25660. diameter: number;
  25661. /**
  25662. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25663. */
  25664. side: number;
  25665. /**
  25666. * Create a new sphere geometry
  25667. * @param id defines the unique ID of the geometry
  25668. * @param scene defines the hosting scene
  25669. * @param segments defines the number of segments to use to create the sphere
  25670. * @param diameter defines the diameter of the sphere
  25671. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25672. * @param mesh defines the hosting mesh (can be null)
  25673. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25674. */
  25675. constructor(id: string, scene: Scene,
  25676. /**
  25677. * Defines the number of segments to use to create the sphere
  25678. */
  25679. segments: number,
  25680. /**
  25681. * Defines the diameter of the sphere
  25682. */
  25683. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25684. /**
  25685. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25686. */
  25687. side?: number);
  25688. /** @hidden */
  25689. _regenerateVertexData(): VertexData;
  25690. copy(id: string): Geometry;
  25691. serialize(): any;
  25692. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  25693. }
  25694. /**
  25695. * Creates a disc geometry
  25696. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25697. */
  25698. class DiscGeometry extends _PrimitiveGeometry {
  25699. /**
  25700. * Defines the radius of the disc
  25701. */
  25702. radius: number;
  25703. /**
  25704. * Defines the tesselation factor to apply to the disc
  25705. */
  25706. tessellation: number;
  25707. /**
  25708. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25709. */
  25710. side: number;
  25711. /**
  25712. * Creates a new disc geometry
  25713. * @param id defines the unique ID of the geometry
  25714. * @param scene defines the hosting scene
  25715. * @param radius defines the radius of the disc
  25716. * @param tessellation defines the tesselation factor to apply to the disc
  25717. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25718. * @param mesh defines the hosting mesh (can be null)
  25719. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25720. */
  25721. constructor(id: string, scene: Scene,
  25722. /**
  25723. * Defines the radius of the disc
  25724. */
  25725. radius: number,
  25726. /**
  25727. * Defines the tesselation factor to apply to the disc
  25728. */
  25729. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25730. /**
  25731. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25732. */
  25733. side?: number);
  25734. /** @hidden */
  25735. _regenerateVertexData(): VertexData;
  25736. copy(id: string): Geometry;
  25737. }
  25738. /**
  25739. * Creates a new cylinder geometry
  25740. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  25741. */
  25742. class CylinderGeometry extends _PrimitiveGeometry {
  25743. /**
  25744. * Defines the height of the cylinder
  25745. */
  25746. height: number;
  25747. /**
  25748. * Defines the diameter of the cylinder's top cap
  25749. */
  25750. diameterTop: number;
  25751. /**
  25752. * Defines the diameter of the cylinder's bottom cap
  25753. */
  25754. diameterBottom: number;
  25755. /**
  25756. * Defines the tessellation factor to apply to the cylinder
  25757. */
  25758. tessellation: number;
  25759. /**
  25760. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25761. */
  25762. subdivisions: number;
  25763. /**
  25764. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25765. */
  25766. side: number;
  25767. /**
  25768. * Creates a new cylinder geometry
  25769. * @param id defines the unique ID of the geometry
  25770. * @param scene defines the hosting scene
  25771. * @param height defines the height of the cylinder
  25772. * @param diameterTop defines the diameter of the cylinder's top cap
  25773. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  25774. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  25775. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  25776. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25777. * @param mesh defines the hosting mesh (can be null)
  25778. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25779. */
  25780. constructor(id: string, scene: Scene,
  25781. /**
  25782. * Defines the height of the cylinder
  25783. */
  25784. height: number,
  25785. /**
  25786. * Defines the diameter of the cylinder's top cap
  25787. */
  25788. diameterTop: number,
  25789. /**
  25790. * Defines the diameter of the cylinder's bottom cap
  25791. */
  25792. diameterBottom: number,
  25793. /**
  25794. * Defines the tessellation factor to apply to the cylinder
  25795. */
  25796. tessellation: number,
  25797. /**
  25798. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25799. */
  25800. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25801. /**
  25802. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25803. */
  25804. side?: number);
  25805. /** @hidden */
  25806. _regenerateVertexData(): VertexData;
  25807. copy(id: string): Geometry;
  25808. serialize(): any;
  25809. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25810. }
  25811. /**
  25812. * Creates a new torus geometry
  25813. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25814. */
  25815. class TorusGeometry extends _PrimitiveGeometry {
  25816. /**
  25817. * Defines the diameter of the torus
  25818. */
  25819. diameter: number;
  25820. /**
  25821. * Defines the thickness of the torus (ie. internal diameter)
  25822. */
  25823. thickness: number;
  25824. /**
  25825. * Defines the tesselation factor to apply to the torus
  25826. */
  25827. tessellation: number;
  25828. /**
  25829. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25830. */
  25831. side: number;
  25832. /**
  25833. * Creates a new torus geometry
  25834. * @param id defines the unique ID of the geometry
  25835. * @param scene defines the hosting scene
  25836. * @param diameter defines the diameter of the torus
  25837. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25838. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25839. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25840. * @param mesh defines the hosting mesh (can be null)
  25841. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25842. */
  25843. constructor(id: string, scene: Scene,
  25844. /**
  25845. * Defines the diameter of the torus
  25846. */
  25847. diameter: number,
  25848. /**
  25849. * Defines the thickness of the torus (ie. internal diameter)
  25850. */
  25851. thickness: number,
  25852. /**
  25853. * Defines the tesselation factor to apply to the torus
  25854. */
  25855. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25856. /**
  25857. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25858. */
  25859. side?: number);
  25860. /** @hidden */
  25861. _regenerateVertexData(): VertexData;
  25862. copy(id: string): Geometry;
  25863. serialize(): any;
  25864. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25865. }
  25866. /**
  25867. * Creates a new ground geometry
  25868. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25869. */
  25870. class GroundGeometry extends _PrimitiveGeometry {
  25871. /**
  25872. * Defines the width of the ground
  25873. */
  25874. width: number;
  25875. /**
  25876. * Defines the height of the ground
  25877. */
  25878. height: number;
  25879. /**
  25880. * Defines the subdivisions to apply to the ground
  25881. */
  25882. subdivisions: number;
  25883. /**
  25884. * Creates a new ground geometry
  25885. * @param id defines the unique ID of the geometry
  25886. * @param scene defines the hosting scene
  25887. * @param width defines the width of the ground
  25888. * @param height defines the height of the ground
  25889. * @param subdivisions defines the subdivisions to apply to the ground
  25890. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25891. * @param mesh defines the hosting mesh (can be null)
  25892. */
  25893. constructor(id: string, scene: Scene,
  25894. /**
  25895. * Defines the width of the ground
  25896. */
  25897. width: number,
  25898. /**
  25899. * Defines the height of the ground
  25900. */
  25901. height: number,
  25902. /**
  25903. * Defines the subdivisions to apply to the ground
  25904. */
  25905. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25906. /** @hidden */
  25907. _regenerateVertexData(): VertexData;
  25908. copy(id: string): Geometry;
  25909. serialize(): any;
  25910. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  25911. }
  25912. /**
  25913. * Creates a tiled ground geometry
  25914. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  25915. */
  25916. class TiledGroundGeometry extends _PrimitiveGeometry {
  25917. /**
  25918. * Defines the minimum value on X axis
  25919. */
  25920. xmin: number;
  25921. /**
  25922. * Defines the minimum value on Z axis
  25923. */
  25924. zmin: number;
  25925. /**
  25926. * Defines the maximum value on X axis
  25927. */
  25928. xmax: number;
  25929. /**
  25930. * Defines the maximum value on Z axis
  25931. */
  25932. zmax: number;
  25933. /**
  25934. * Defines the subdivisions to apply to the ground
  25935. */
  25936. subdivisions: {
  25937. w: number;
  25938. h: number;
  25939. };
  25940. /**
  25941. * Defines the precision to use when computing the tiles
  25942. */
  25943. precision: {
  25944. w: number;
  25945. h: number;
  25946. };
  25947. /**
  25948. * Creates a tiled ground geometry
  25949. * @param id defines the unique ID of the geometry
  25950. * @param scene defines the hosting scene
  25951. * @param xmin defines the minimum value on X axis
  25952. * @param zmin defines the minimum value on Z axis
  25953. * @param xmax defines the maximum value on X axis
  25954. * @param zmax defines the maximum value on Z axis
  25955. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  25956. * @param precision defines the precision to use when computing the tiles
  25957. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25958. * @param mesh defines the hosting mesh (can be null)
  25959. */
  25960. constructor(id: string, scene: Scene,
  25961. /**
  25962. * Defines the minimum value on X axis
  25963. */
  25964. xmin: number,
  25965. /**
  25966. * Defines the minimum value on Z axis
  25967. */
  25968. zmin: number,
  25969. /**
  25970. * Defines the maximum value on X axis
  25971. */
  25972. xmax: number,
  25973. /**
  25974. * Defines the maximum value on Z axis
  25975. */
  25976. zmax: number,
  25977. /**
  25978. * Defines the subdivisions to apply to the ground
  25979. */
  25980. subdivisions: {
  25981. w: number;
  25982. h: number;
  25983. },
  25984. /**
  25985. * Defines the precision to use when computing the tiles
  25986. */
  25987. precision: {
  25988. w: number;
  25989. h: number;
  25990. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25991. /** @hidden */
  25992. _regenerateVertexData(): VertexData;
  25993. copy(id: string): Geometry;
  25994. }
  25995. /**
  25996. * Creates a plane geometry
  25997. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  25998. */
  25999. class PlaneGeometry extends _PrimitiveGeometry {
  26000. /**
  26001. * Defines the size of the plane (width === height)
  26002. */
  26003. size: number;
  26004. /**
  26005. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26006. */
  26007. side: number;
  26008. /**
  26009. * Creates a plane geometry
  26010. * @param id defines the unique ID of the geometry
  26011. * @param scene defines the hosting scene
  26012. * @param size defines the size of the plane (width === height)
  26013. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26014. * @param mesh defines the hosting mesh (can be null)
  26015. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26016. */
  26017. constructor(id: string, scene: Scene,
  26018. /**
  26019. * Defines the size of the plane (width === height)
  26020. */
  26021. size: 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(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  26031. }
  26032. /**
  26033. * Creates a torus knot geometry
  26034. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  26035. */
  26036. class TorusKnotGeometry extends _PrimitiveGeometry {
  26037. /**
  26038. * Defines the radius of the torus knot
  26039. */
  26040. radius: number;
  26041. /**
  26042. * Defines the thickness of the torus knot tube
  26043. */
  26044. tube: number;
  26045. /**
  26046. * Defines the number of radial segments
  26047. */
  26048. radialSegments: number;
  26049. /**
  26050. * Defines the number of tubular segments
  26051. */
  26052. tubularSegments: number;
  26053. /**
  26054. * Defines the first number of windings
  26055. */
  26056. p: number;
  26057. /**
  26058. * Defines the second number of windings
  26059. */
  26060. q: number;
  26061. /**
  26062. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26063. */
  26064. side: number;
  26065. /**
  26066. * Creates a torus knot geometry
  26067. * @param id defines the unique ID of the geometry
  26068. * @param scene defines the hosting scene
  26069. * @param radius defines the radius of the torus knot
  26070. * @param tube defines the thickness of the torus knot tube
  26071. * @param radialSegments defines the number of radial segments
  26072. * @param tubularSegments defines the number of tubular segments
  26073. * @param p defines the first number of windings
  26074. * @param q defines the second number of windings
  26075. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26076. * @param mesh defines the hosting mesh (can be null)
  26077. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26078. */
  26079. constructor(id: string, scene: Scene,
  26080. /**
  26081. * Defines the radius of the torus knot
  26082. */
  26083. radius: number,
  26084. /**
  26085. * Defines the thickness of the torus knot tube
  26086. */
  26087. tube: number,
  26088. /**
  26089. * Defines the number of radial segments
  26090. */
  26091. radialSegments: number,
  26092. /**
  26093. * Defines the number of tubular segments
  26094. */
  26095. tubularSegments: number,
  26096. /**
  26097. * Defines the first number of windings
  26098. */
  26099. p: number,
  26100. /**
  26101. * Defines the second number of windings
  26102. */
  26103. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26104. /**
  26105. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26106. */
  26107. side?: number);
  26108. /** @hidden */
  26109. _regenerateVertexData(): VertexData;
  26110. copy(id: string): Geometry;
  26111. serialize(): any;
  26112. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  26113. }
  26114. }
  26115. declare module BABYLON {
  26116. /**
  26117. * Mesh representing the gorund
  26118. */
  26119. class GroundMesh extends Mesh {
  26120. /** If octree should be generated */
  26121. generateOctree: boolean;
  26122. private _heightQuads;
  26123. /** @hidden */
  26124. _subdivisionsX: number;
  26125. /** @hidden */
  26126. _subdivisionsY: number;
  26127. /** @hidden */
  26128. _width: number;
  26129. /** @hidden */
  26130. _height: number;
  26131. /** @hidden */
  26132. _minX: number;
  26133. /** @hidden */
  26134. _maxX: number;
  26135. /** @hidden */
  26136. _minZ: number;
  26137. /** @hidden */
  26138. _maxZ: number;
  26139. constructor(name: string, scene: Scene);
  26140. /**
  26141. * "GroundMesh"
  26142. * @returns "GroundMesh"
  26143. */
  26144. getClassName(): string;
  26145. /**
  26146. * The minimum of x and y subdivisions
  26147. */
  26148. readonly subdivisions: number;
  26149. /**
  26150. * X subdivisions
  26151. */
  26152. readonly subdivisionsX: number;
  26153. /**
  26154. * Y subdivisions
  26155. */
  26156. readonly subdivisionsY: number;
  26157. /**
  26158. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26159. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26160. * @param chunksCount the number of subdivisions for x and y
  26161. * @param octreeBlocksSize (Default: 32)
  26162. */
  26163. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26164. /**
  26165. * Returns a height (y) value in the Worl system :
  26166. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26167. * @param x x coordinate
  26168. * @param z z coordinate
  26169. * @returns the ground y position if (x, z) are outside the ground surface.
  26170. */
  26171. getHeightAtCoordinates(x: number, z: number): number;
  26172. /**
  26173. * Returns a normalized vector (Vector3) orthogonal to the ground
  26174. * at the ground coordinates (x, z) expressed in the World system.
  26175. * @param x x coordinate
  26176. * @param z z coordinate
  26177. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26178. */
  26179. getNormalAtCoordinates(x: number, z: number): Vector3;
  26180. /**
  26181. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26182. * at the ground coordinates (x, z) expressed in the World system.
  26183. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26184. * @param x x coordinate
  26185. * @param z z coordinate
  26186. * @param ref vector to store the result
  26187. * @returns the GroundMesh.
  26188. */
  26189. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26190. /**
  26191. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26192. * if the ground has been updated.
  26193. * This can be used in the render loop.
  26194. * @returns the GroundMesh.
  26195. */
  26196. updateCoordinateHeights(): GroundMesh;
  26197. private _getFacetAt;
  26198. private _initHeightQuads;
  26199. private _computeHeightQuads;
  26200. /**
  26201. * Serializes this ground mesh
  26202. * @param serializationObject object to write serialization to
  26203. */
  26204. serialize(serializationObject: any): void;
  26205. /**
  26206. * Parses a serialized ground mesh
  26207. * @param parsedMesh the serialized mesh
  26208. * @param scene the scene to create the ground mesh in
  26209. * @returns the created ground mesh
  26210. */
  26211. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26212. }
  26213. }
  26214. declare module BABYLON {
  26215. /**
  26216. * Creates an instance based on a source mesh.
  26217. */
  26218. class InstancedMesh extends AbstractMesh {
  26219. private _sourceMesh;
  26220. private _currentLOD;
  26221. /** @hidden */
  26222. _indexInSourceMeshInstanceArray: number;
  26223. constructor(name: string, source: Mesh);
  26224. /**
  26225. * Returns the string "InstancedMesh".
  26226. */
  26227. getClassName(): string;
  26228. /**
  26229. * If the source mesh receives shadows
  26230. */
  26231. readonly receiveShadows: boolean;
  26232. /**
  26233. * The material of the source mesh
  26234. */
  26235. readonly material: Nullable<Material>;
  26236. /**
  26237. * Visibility of the source mesh
  26238. */
  26239. readonly visibility: number;
  26240. /**
  26241. * Skeleton of the source mesh
  26242. */
  26243. readonly skeleton: Nullable<Skeleton>;
  26244. /**
  26245. * Rendering ground id of the source mesh
  26246. */
  26247. renderingGroupId: number;
  26248. /**
  26249. * Returns the total number of vertices (integer).
  26250. */
  26251. getTotalVertices(): number;
  26252. /**
  26253. * Returns a positive integer : the total number of indices in this mesh geometry.
  26254. * @returns the numner of indices or zero if the mesh has no geometry.
  26255. */
  26256. getTotalIndices(): number;
  26257. /**
  26258. * The source mesh of the instance
  26259. */
  26260. readonly sourceMesh: Mesh;
  26261. /**
  26262. * Is this node ready to be used/rendered
  26263. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26264. * @return {boolean} is it ready
  26265. */
  26266. isReady(completeCheck?: boolean): boolean;
  26267. /**
  26268. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26269. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  26270. * @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.
  26271. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  26272. */
  26273. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  26274. /**
  26275. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26276. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26277. * The `data` are either a numeric array either a Float32Array.
  26278. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  26279. * 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).
  26280. * Note that a new underlying VertexBuffer object is created each call.
  26281. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26282. *
  26283. * Possible `kind` values :
  26284. * - BABYLON.VertexBuffer.PositionKind
  26285. * - BABYLON.VertexBuffer.UVKind
  26286. * - BABYLON.VertexBuffer.UV2Kind
  26287. * - BABYLON.VertexBuffer.UV3Kind
  26288. * - BABYLON.VertexBuffer.UV4Kind
  26289. * - BABYLON.VertexBuffer.UV5Kind
  26290. * - BABYLON.VertexBuffer.UV6Kind
  26291. * - BABYLON.VertexBuffer.ColorKind
  26292. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26293. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26294. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26295. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26296. *
  26297. * Returns the Mesh.
  26298. */
  26299. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26300. /**
  26301. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26302. * If the mesh has no geometry, it is simply returned as it is.
  26303. * The `data` are either a numeric array either a Float32Array.
  26304. * No new underlying VertexBuffer object is created.
  26305. * 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.
  26306. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  26307. *
  26308. * Possible `kind` values :
  26309. * - BABYLON.VertexBuffer.PositionKind
  26310. * - BABYLON.VertexBuffer.UVKind
  26311. * - BABYLON.VertexBuffer.UV2Kind
  26312. * - BABYLON.VertexBuffer.UV3Kind
  26313. * - BABYLON.VertexBuffer.UV4Kind
  26314. * - BABYLON.VertexBuffer.UV5Kind
  26315. * - BABYLON.VertexBuffer.UV6Kind
  26316. * - BABYLON.VertexBuffer.ColorKind
  26317. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26318. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26319. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26320. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26321. *
  26322. * Returns the Mesh.
  26323. */
  26324. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26325. /**
  26326. * Sets the mesh indices.
  26327. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26328. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26329. * This method creates a new index buffer each call.
  26330. * Returns the Mesh.
  26331. */
  26332. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26333. /**
  26334. * Boolean : True if the mesh owns the requested kind of data.
  26335. */
  26336. isVerticesDataPresent(kind: string): boolean;
  26337. /**
  26338. * Returns an array of indices (IndicesArray).
  26339. */
  26340. getIndices(): Nullable<IndicesArray>;
  26341. readonly _positions: Nullable<Vector3[]>;
  26342. /**
  26343. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26344. * This means the mesh underlying bounding box and sphere are recomputed.
  26345. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26346. * @returns the current mesh
  26347. */
  26348. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  26349. /** @hidden */
  26350. _preActivate(): InstancedMesh;
  26351. /** @hidden */
  26352. _activate(renderId: number): InstancedMesh;
  26353. /**
  26354. * Returns the current associated LOD AbstractMesh.
  26355. */
  26356. getLOD(camera: Camera): AbstractMesh;
  26357. /** @hidden */
  26358. _syncSubMeshes(): InstancedMesh;
  26359. /** @hidden */
  26360. _generatePointsArray(): boolean;
  26361. /**
  26362. * Creates a new InstancedMesh from the current mesh.
  26363. * - name (string) : the cloned mesh name
  26364. * - newParent (optional Node) : the optional Node to parent the clone to.
  26365. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26366. *
  26367. * Returns the clone.
  26368. */
  26369. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26370. /**
  26371. * Disposes the InstancedMesh.
  26372. * Returns nothing.
  26373. */
  26374. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26375. }
  26376. }
  26377. declare module BABYLON {
  26378. /**
  26379. * Line mesh
  26380. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26381. */
  26382. class LinesMesh extends Mesh {
  26383. /**
  26384. * If vertex color should be applied to the mesh
  26385. */
  26386. useVertexColor?: boolean | undefined;
  26387. /**
  26388. * If vertex alpha should be applied to the mesh
  26389. */
  26390. useVertexAlpha?: boolean | undefined;
  26391. /**
  26392. * Color of the line (Default: White)
  26393. */
  26394. color: Color3;
  26395. /**
  26396. * Alpha of the line (Default: 1)
  26397. */
  26398. alpha: number;
  26399. /**
  26400. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26401. * This margin is expressed in world space coordinates, so its value may vary.
  26402. * Default value is 0.1
  26403. */
  26404. intersectionThreshold: number;
  26405. private _colorShader;
  26406. /**
  26407. * Creates a new LinesMesh
  26408. * @param name defines the name
  26409. * @param scene defines the hosting scene
  26410. * @param parent defines the parent mesh if any
  26411. * @param source defines the optional source LinesMesh used to clone data from
  26412. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26413. * When false, achieved by calling a clone(), also passing False.
  26414. * This will make creation of children, recursive.
  26415. * @param useVertexColor defines if this LinesMesh supports vertex color
  26416. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26417. */
  26418. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26419. /**
  26420. * If vertex color should be applied to the mesh
  26421. */
  26422. useVertexColor?: boolean | undefined,
  26423. /**
  26424. * If vertex alpha should be applied to the mesh
  26425. */
  26426. useVertexAlpha?: boolean | undefined);
  26427. /**
  26428. * Returns the string "LineMesh"
  26429. */
  26430. getClassName(): string;
  26431. /**
  26432. * @hidden
  26433. */
  26434. /**
  26435. * @hidden
  26436. */
  26437. material: Material;
  26438. /**
  26439. * @hidden
  26440. */
  26441. readonly checkCollisions: boolean;
  26442. /** @hidden */
  26443. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26444. /** @hidden */
  26445. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26446. /**
  26447. * Disposes of the line mesh
  26448. * @param doNotRecurse If children should be disposed
  26449. */
  26450. dispose(doNotRecurse?: boolean): void;
  26451. /**
  26452. * Returns a new LineMesh object cloned from the current one.
  26453. */
  26454. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26455. /**
  26456. * Creates a new InstancedLinesMesh object from the mesh model.
  26457. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26458. * @param name defines the name of the new instance
  26459. * @returns a new InstancedLinesMesh
  26460. */
  26461. createInstance(name: string): InstancedLinesMesh;
  26462. }
  26463. /**
  26464. * Creates an instance based on a source LinesMesh
  26465. */
  26466. class InstancedLinesMesh extends InstancedMesh {
  26467. /**
  26468. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26469. * This margin is expressed in world space coordinates, so its value may vary.
  26470. * Initilized with the intersectionThreshold value of the source LinesMesh
  26471. */
  26472. intersectionThreshold: number;
  26473. constructor(name: string, source: LinesMesh);
  26474. /**
  26475. * Returns the string "InstancedLinesMesh".
  26476. */
  26477. getClassName(): string;
  26478. }
  26479. }
  26480. declare module BABYLON {
  26481. /**
  26482. * @hidden
  26483. **/
  26484. class _CreationDataStorage {
  26485. closePath?: boolean;
  26486. closeArray?: boolean;
  26487. idx: number[];
  26488. dashSize: number;
  26489. gapSize: number;
  26490. path3D: Path3D;
  26491. pathArray: Vector3[][];
  26492. arc: number;
  26493. radius: number;
  26494. cap: number;
  26495. tessellation: number;
  26496. }
  26497. /**
  26498. * @hidden
  26499. **/
  26500. class _InstanceDataStorage {
  26501. visibleInstances: any;
  26502. renderIdForInstances: number[];
  26503. batchCache: _InstancesBatch;
  26504. instancesBufferSize: number;
  26505. instancesBuffer: Nullable<Buffer>;
  26506. instancesData: Float32Array;
  26507. overridenInstanceCount: number;
  26508. }
  26509. /**
  26510. * @hidden
  26511. **/
  26512. class _InstancesBatch {
  26513. mustReturn: boolean;
  26514. visibleInstances: Nullable<InstancedMesh[]>[];
  26515. renderSelf: boolean[];
  26516. }
  26517. /**
  26518. * Class used to represent renderable models
  26519. */
  26520. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26521. /**
  26522. * Mesh side orientation : usually the external or front surface
  26523. */
  26524. static readonly FRONTSIDE: number;
  26525. /**
  26526. * Mesh side orientation : usually the internal or back surface
  26527. */
  26528. static readonly BACKSIDE: number;
  26529. /**
  26530. * Mesh side orientation : both internal and external or front and back surfaces
  26531. */
  26532. static readonly DOUBLESIDE: number;
  26533. /**
  26534. * Mesh side orientation : by default, `FRONTSIDE`
  26535. */
  26536. static readonly DEFAULTSIDE: number;
  26537. /**
  26538. * Mesh cap setting : no cap
  26539. */
  26540. static readonly NO_CAP: number;
  26541. /**
  26542. * Mesh cap setting : one cap at the beginning of the mesh
  26543. */
  26544. static readonly CAP_START: number;
  26545. /**
  26546. * Mesh cap setting : one cap at the end of the mesh
  26547. */
  26548. static readonly CAP_END: number;
  26549. /**
  26550. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26551. */
  26552. static readonly CAP_ALL: number;
  26553. private _onBeforeRenderObservable;
  26554. private _onAfterRenderObservable;
  26555. private _onBeforeDrawObservable;
  26556. /**
  26557. * An event triggered before rendering the mesh
  26558. */
  26559. readonly onBeforeRenderObservable: Observable<Mesh>;
  26560. /**
  26561. * An event triggered after rendering the mesh
  26562. */
  26563. readonly onAfterRenderObservable: Observable<Mesh>;
  26564. /**
  26565. * An event triggered before drawing the mesh
  26566. */
  26567. readonly onBeforeDrawObservable: Observable<Mesh>;
  26568. private _onBeforeDrawObserver;
  26569. /**
  26570. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26571. */
  26572. onBeforeDraw: () => void;
  26573. /**
  26574. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26575. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26576. */
  26577. delayLoadState: number;
  26578. /**
  26579. * Gets the list of instances created from this mesh
  26580. * it is not supposed to be modified manually.
  26581. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26582. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26583. */
  26584. instances: InstancedMesh[];
  26585. /**
  26586. * Gets the file containing delay loading data for this mesh
  26587. */
  26588. delayLoadingFile: string;
  26589. /** @hidden */
  26590. _binaryInfo: any;
  26591. private _LODLevels;
  26592. /**
  26593. * User defined function used to change how LOD level selection is done
  26594. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26595. */
  26596. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26597. private _morphTargetManager;
  26598. /**
  26599. * Gets or sets the morph target manager
  26600. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26601. */
  26602. morphTargetManager: Nullable<MorphTargetManager>;
  26603. /** @hidden */
  26604. _creationDataStorage: Nullable<_CreationDataStorage>;
  26605. /** @hidden */
  26606. _geometry: Nullable<Geometry>;
  26607. /** @hidden */
  26608. _delayInfo: Array<string>;
  26609. /** @hidden */
  26610. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26611. /** @hidden */
  26612. _instanceDataStorage: _InstanceDataStorage;
  26613. private _effectiveMaterial;
  26614. /** @hidden */
  26615. _shouldGenerateFlatShading: boolean;
  26616. private _preActivateId;
  26617. /** @hidden */
  26618. _originalBuilderSideOrientation: number;
  26619. /**
  26620. * Use this property to change the original side orientation defined at construction time
  26621. */
  26622. overrideMaterialSideOrientation: Nullable<number>;
  26623. private _areNormalsFrozen;
  26624. private _sourcePositions;
  26625. private _sourceNormals;
  26626. private _source;
  26627. private meshMap;
  26628. /**
  26629. * Gets the source mesh (the one used to clone this one from)
  26630. */
  26631. readonly source: Nullable<Mesh>;
  26632. /**
  26633. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26634. */
  26635. isUnIndexed: boolean;
  26636. /**
  26637. * @constructor
  26638. * @param name The value used by scene.getMeshByName() to do a lookup.
  26639. * @param scene The scene to add this mesh to.
  26640. * @param parent The parent of this mesh, if it has one
  26641. * @param source An optional Mesh from which geometry is shared, cloned.
  26642. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26643. * When false, achieved by calling a clone(), also passing False.
  26644. * This will make creation of children, recursive.
  26645. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26646. */
  26647. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26648. /**
  26649. * Gets the class name
  26650. * @returns the string "Mesh".
  26651. */
  26652. getClassName(): string;
  26653. /**
  26654. * Returns a description of this mesh
  26655. * @param fullDetails define if full details about this mesh must be used
  26656. * @returns a descriptive string representing this mesh
  26657. */
  26658. toString(fullDetails?: boolean): string;
  26659. /** @hidden */
  26660. _unBindEffect(): void;
  26661. /**
  26662. * Gets a boolean indicating if this mesh has LOD
  26663. */
  26664. readonly hasLODLevels: boolean;
  26665. /**
  26666. * Gets the list of MeshLODLevel associated with the current mesh
  26667. * @returns an array of MeshLODLevel
  26668. */
  26669. getLODLevels(): MeshLODLevel[];
  26670. private _sortLODLevels;
  26671. /**
  26672. * Add a mesh as LOD level triggered at the given distance.
  26673. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26674. * @param distance The distance from the center of the object to show this level
  26675. * @param mesh The mesh to be added as LOD level (can be null)
  26676. * @return This mesh (for chaining)
  26677. */
  26678. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26679. /**
  26680. * Returns the LOD level mesh at the passed distance or null if not found.
  26681. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26682. * @param distance The distance from the center of the object to show this level
  26683. * @returns a Mesh or `null`
  26684. */
  26685. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  26686. /**
  26687. * Remove a mesh from the LOD array
  26688. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26689. * @param mesh defines the mesh to be removed
  26690. * @return This mesh (for chaining)
  26691. */
  26692. removeLODLevel(mesh: Mesh): Mesh;
  26693. /**
  26694. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  26695. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26696. * @param camera defines the camera to use to compute distance
  26697. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  26698. * @return This mesh (for chaining)
  26699. */
  26700. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  26701. /**
  26702. * Gets the mesh internal Geometry object
  26703. */
  26704. readonly geometry: Nullable<Geometry>;
  26705. /**
  26706. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  26707. * @returns the total number of vertices
  26708. */
  26709. getTotalVertices(): number;
  26710. /**
  26711. * Returns the content of an associated vertex buffer
  26712. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26713. * - BABYLON.VertexBuffer.PositionKind
  26714. * - BABYLON.VertexBuffer.UVKind
  26715. * - BABYLON.VertexBuffer.UV2Kind
  26716. * - BABYLON.VertexBuffer.UV3Kind
  26717. * - BABYLON.VertexBuffer.UV4Kind
  26718. * - BABYLON.VertexBuffer.UV5Kind
  26719. * - BABYLON.VertexBuffer.UV6Kind
  26720. * - BABYLON.VertexBuffer.ColorKind
  26721. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26722. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26723. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26724. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26725. * @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
  26726. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  26727. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  26728. */
  26729. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26730. /**
  26731. * Returns the mesh VertexBuffer object from the requested `kind`
  26732. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26733. * - BABYLON.VertexBuffer.PositionKind
  26734. * - BABYLON.VertexBuffer.UVKind
  26735. * - BABYLON.VertexBuffer.UV2Kind
  26736. * - BABYLON.VertexBuffer.UV3Kind
  26737. * - BABYLON.VertexBuffer.UV4Kind
  26738. * - BABYLON.VertexBuffer.UV5Kind
  26739. * - BABYLON.VertexBuffer.UV6Kind
  26740. * - BABYLON.VertexBuffer.ColorKind
  26741. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26742. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26743. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26744. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26745. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  26746. */
  26747. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26748. /**
  26749. * Tests if a specific vertex buffer is associated with this mesh
  26750. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26751. * - BABYLON.VertexBuffer.PositionKind
  26752. * - BABYLON.VertexBuffer.UVKind
  26753. * - BABYLON.VertexBuffer.UV2Kind
  26754. * - BABYLON.VertexBuffer.UV3Kind
  26755. * - BABYLON.VertexBuffer.UV4Kind
  26756. * - BABYLON.VertexBuffer.UV5Kind
  26757. * - BABYLON.VertexBuffer.UV6Kind
  26758. * - BABYLON.VertexBuffer.ColorKind
  26759. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26760. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26761. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26762. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26763. * @returns a boolean
  26764. */
  26765. isVerticesDataPresent(kind: string): boolean;
  26766. /**
  26767. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  26768. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26769. * - BABYLON.VertexBuffer.PositionKind
  26770. * - BABYLON.VertexBuffer.UVKind
  26771. * - BABYLON.VertexBuffer.UV2Kind
  26772. * - BABYLON.VertexBuffer.UV3Kind
  26773. * - BABYLON.VertexBuffer.UV4Kind
  26774. * - BABYLON.VertexBuffer.UV5Kind
  26775. * - BABYLON.VertexBuffer.UV6Kind
  26776. * - BABYLON.VertexBuffer.ColorKind
  26777. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26778. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26779. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26780. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26781. * @returns a boolean
  26782. */
  26783. isVertexBufferUpdatable(kind: string): boolean;
  26784. /**
  26785. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26786. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26787. * - BABYLON.VertexBuffer.PositionKind
  26788. * - BABYLON.VertexBuffer.UVKind
  26789. * - BABYLON.VertexBuffer.UV2Kind
  26790. * - BABYLON.VertexBuffer.UV3Kind
  26791. * - BABYLON.VertexBuffer.UV4Kind
  26792. * - BABYLON.VertexBuffer.UV5Kind
  26793. * - BABYLON.VertexBuffer.UV6Kind
  26794. * - BABYLON.VertexBuffer.ColorKind
  26795. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26796. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26797. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26798. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26799. * @returns an array of strings
  26800. */
  26801. getVerticesDataKinds(): string[];
  26802. /**
  26803. * Returns a positive integer : the total number of indices in this mesh geometry.
  26804. * @returns the numner of indices or zero if the mesh has no geometry.
  26805. */
  26806. getTotalIndices(): number;
  26807. /**
  26808. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26809. * @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.
  26810. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26811. * @returns the indices array or an empty array if the mesh has no geometry
  26812. */
  26813. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26814. readonly isBlocked: boolean;
  26815. /**
  26816. * Determine if the current mesh is ready to be rendered
  26817. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26818. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26819. * @returns true if all associated assets are ready (material, textures, shaders)
  26820. */
  26821. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26822. /**
  26823. * 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.
  26824. */
  26825. readonly areNormalsFrozen: boolean;
  26826. /**
  26827. * 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.
  26828. * @returns the current mesh
  26829. */
  26830. freezeNormals(): Mesh;
  26831. /**
  26832. * 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
  26833. * @returns the current mesh
  26834. */
  26835. unfreezeNormals(): Mesh;
  26836. /**
  26837. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26838. */
  26839. overridenInstanceCount: number;
  26840. /** @hidden */
  26841. _preActivate(): Mesh;
  26842. /** @hidden */
  26843. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26844. /** @hidden */
  26845. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26846. /**
  26847. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26848. * This means the mesh underlying bounding box and sphere are recomputed.
  26849. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26850. * @returns the current mesh
  26851. */
  26852. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  26853. /** @hidden */
  26854. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26855. /**
  26856. * This function will subdivide the mesh into multiple submeshes
  26857. * @param count defines the expected number of submeshes
  26858. */
  26859. subdivide(count: number): void;
  26860. /**
  26861. * Copy a FloatArray into a specific associated vertex buffer
  26862. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26863. * - BABYLON.VertexBuffer.PositionKind
  26864. * - BABYLON.VertexBuffer.UVKind
  26865. * - BABYLON.VertexBuffer.UV2Kind
  26866. * - BABYLON.VertexBuffer.UV3Kind
  26867. * - BABYLON.VertexBuffer.UV4Kind
  26868. * - BABYLON.VertexBuffer.UV5Kind
  26869. * - BABYLON.VertexBuffer.UV6Kind
  26870. * - BABYLON.VertexBuffer.ColorKind
  26871. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26872. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26873. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26874. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26875. * @param data defines the data source
  26876. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26877. * @param stride defines the data stride size (can be null)
  26878. * @returns the current mesh
  26879. */
  26880. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26881. /**
  26882. * Flags an associated vertex buffer as updatable
  26883. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  26884. * - BABYLON.VertexBuffer.PositionKind
  26885. * - BABYLON.VertexBuffer.UVKind
  26886. * - BABYLON.VertexBuffer.UV2Kind
  26887. * - BABYLON.VertexBuffer.UV3Kind
  26888. * - BABYLON.VertexBuffer.UV4Kind
  26889. * - BABYLON.VertexBuffer.UV5Kind
  26890. * - BABYLON.VertexBuffer.UV6Kind
  26891. * - BABYLON.VertexBuffer.ColorKind
  26892. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26893. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26894. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26895. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26896. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26897. */
  26898. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  26899. /**
  26900. * Sets the mesh global Vertex Buffer
  26901. * @param buffer defines the buffer to use
  26902. * @returns the current mesh
  26903. */
  26904. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  26905. /**
  26906. * Update a specific associated vertex buffer
  26907. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26908. * - BABYLON.VertexBuffer.PositionKind
  26909. * - BABYLON.VertexBuffer.UVKind
  26910. * - BABYLON.VertexBuffer.UV2Kind
  26911. * - BABYLON.VertexBuffer.UV3Kind
  26912. * - BABYLON.VertexBuffer.UV4Kind
  26913. * - BABYLON.VertexBuffer.UV5Kind
  26914. * - BABYLON.VertexBuffer.UV6Kind
  26915. * - BABYLON.VertexBuffer.ColorKind
  26916. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26917. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26918. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26919. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26920. * @param data defines the data source
  26921. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26922. * @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)
  26923. * @returns the current mesh
  26924. */
  26925. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26926. /**
  26927. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  26928. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  26929. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  26930. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  26931. * @returns the current mesh
  26932. */
  26933. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  26934. /**
  26935. * Creates a un-shared specific occurence of the geometry for the mesh.
  26936. * @returns the current mesh
  26937. */
  26938. makeGeometryUnique(): Mesh;
  26939. /**
  26940. * Set the index buffer of this mesh
  26941. * @param indices defines the source data
  26942. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  26943. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  26944. * @returns the current mesh
  26945. */
  26946. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  26947. /**
  26948. * Update the current index buffer
  26949. * @param indices defines the source data
  26950. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26951. * @returns the current mesh
  26952. */
  26953. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  26954. /**
  26955. * Invert the geometry to move from a right handed system to a left handed one.
  26956. * @returns the current mesh
  26957. */
  26958. toLeftHanded(): Mesh;
  26959. /** @hidden */
  26960. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  26961. /** @hidden */
  26962. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  26963. /**
  26964. * Registers for this mesh a javascript function called just before the rendering process
  26965. * @param func defines the function to call before rendering this mesh
  26966. * @returns the current mesh
  26967. */
  26968. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26969. /**
  26970. * Disposes a previously registered javascript function called before the rendering
  26971. * @param func defines the function to remove
  26972. * @returns the current mesh
  26973. */
  26974. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26975. /**
  26976. * Registers for this mesh a javascript function called just after the rendering is complete
  26977. * @param func defines the function to call after rendering this mesh
  26978. * @returns the current mesh
  26979. */
  26980. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26981. /**
  26982. * Disposes a previously registered javascript function called after the rendering.
  26983. * @param func defines the function to remove
  26984. * @returns the current mesh
  26985. */
  26986. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26987. /** @hidden */
  26988. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  26989. /** @hidden */
  26990. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  26991. /** @hidden */
  26992. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  26993. /**
  26994. * 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
  26995. * @param subMesh defines the subMesh to render
  26996. * @param enableAlphaMode defines if alpha mode can be changed
  26997. * @returns the current mesh
  26998. */
  26999. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  27000. private _onBeforeDraw;
  27001. /**
  27002. * Renormalize the mesh and patch it up if there are no weights
  27003. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27004. * However in the case of zero weights then we set just a single influence to 1.
  27005. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27006. */
  27007. cleanMatrixWeights(): void;
  27008. private normalizeSkinFourWeights;
  27009. private normalizeSkinWeightsAndExtra;
  27010. /**
  27011. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27012. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27013. * the user know there was an issue with importing the mesh
  27014. * @returns a validation object with skinned, valid and report string
  27015. */
  27016. validateSkinning(): {
  27017. skinned: boolean;
  27018. valid: boolean;
  27019. report: string;
  27020. };
  27021. /** @hidden */
  27022. _checkDelayState(): Mesh;
  27023. private _queueLoad;
  27024. /**
  27025. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27026. * A mesh is in the frustum if its bounding box intersects the frustum
  27027. * @param frustumPlanes defines the frustum to test
  27028. * @returns true if the mesh is in the frustum planes
  27029. */
  27030. isInFrustum(frustumPlanes: Plane[]): boolean;
  27031. /**
  27032. * Sets the mesh material by the material or multiMaterial `id` property
  27033. * @param id is a string identifying the material or the multiMaterial
  27034. * @returns the current mesh
  27035. */
  27036. setMaterialByID(id: string): Mesh;
  27037. /**
  27038. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27039. * @returns an array of IAnimatable
  27040. */
  27041. getAnimatables(): IAnimatable[];
  27042. /**
  27043. * Modifies the mesh geometry according to the passed transformation matrix.
  27044. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27045. * The mesh normals are modified using the same transformation.
  27046. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27047. * @param transform defines the transform matrix to use
  27048. * @see http://doc.babylonjs.com/resources/baking_transformations
  27049. * @returns the current mesh
  27050. */
  27051. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27052. /**
  27053. * Modifies the mesh geometry according to its own current World Matrix.
  27054. * The mesh World Matrix is then reset.
  27055. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27056. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27057. * @see http://doc.babylonjs.com/resources/baking_transformations
  27058. * @returns the current mesh
  27059. */
  27060. bakeCurrentTransformIntoVertices(): Mesh;
  27061. /** @hidden */
  27062. readonly _positions: Nullable<Vector3[]>;
  27063. /** @hidden */
  27064. _resetPointsArrayCache(): Mesh;
  27065. /** @hidden */
  27066. _generatePointsArray(): boolean;
  27067. /**
  27068. * Returns a new Mesh object generated from the current mesh properties.
  27069. * This method must not get confused with createInstance()
  27070. * @param name is a string, the name given to the new mesh
  27071. * @param newParent can be any Node object (default `null`)
  27072. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27073. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27074. * @returns a new mesh
  27075. */
  27076. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27077. /**
  27078. * Releases resources associated with this mesh.
  27079. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27080. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27081. */
  27082. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27083. /**
  27084. * Modifies the mesh geometry according to a displacement map.
  27085. * 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.
  27086. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27087. * @param url is a string, the URL from the image file is to be downloaded.
  27088. * @param minHeight is the lower limit of the displacement.
  27089. * @param maxHeight is the upper limit of the displacement.
  27090. * @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.
  27091. * @param uvOffset is an optional vector2 used to offset UV.
  27092. * @param uvScale is an optional vector2 used to scale UV.
  27093. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  27094. * @returns the Mesh.
  27095. */
  27096. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27097. /**
  27098. * Modifies the mesh geometry according to a displacementMap buffer.
  27099. * 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.
  27100. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27101. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27102. * @param heightMapWidth is the width of the buffer image.
  27103. * @param heightMapHeight is the height of the buffer image.
  27104. * @param minHeight is the lower limit of the displacement.
  27105. * @param maxHeight is the upper limit of the displacement.
  27106. * @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.
  27107. * @param uvOffset is an optional vector2 used to offset UV.
  27108. * @param uvScale is an optional vector2 used to scale UV.
  27109. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  27110. * @returns the Mesh.
  27111. */
  27112. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27113. /**
  27114. * Modify the mesh to get a flat shading rendering.
  27115. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27116. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27117. * @returns current mesh
  27118. */
  27119. convertToFlatShadedMesh(): Mesh;
  27120. /**
  27121. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27122. * In other words, more vertices, no more indices and a single bigger VBO.
  27123. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27124. * @returns current mesh
  27125. */
  27126. convertToUnIndexedMesh(): Mesh;
  27127. /**
  27128. * Inverses facet orientations.
  27129. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27130. * @param flipNormals will also inverts the normals
  27131. * @returns current mesh
  27132. */
  27133. flipFaces(flipNormals?: boolean): Mesh;
  27134. /**
  27135. * Creates a new InstancedMesh object from the mesh model.
  27136. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27137. * @param name defines the name of the new instance
  27138. * @returns a new InstancedMesh
  27139. */
  27140. createInstance(name: string): InstancedMesh;
  27141. /**
  27142. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27143. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27144. * @returns the current mesh
  27145. */
  27146. synchronizeInstances(): Mesh;
  27147. /**
  27148. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27149. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27150. * This should be used together with the simplification to avoid disappearing triangles.
  27151. * @param successCallback an optional success callback to be called after the optimization finished.
  27152. * @returns the current mesh
  27153. */
  27154. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27155. /**
  27156. * Serialize current mesh
  27157. * @param serializationObject defines the object which will receive the serialization data
  27158. */
  27159. serialize(serializationObject: any): void;
  27160. /** @hidden */
  27161. _syncGeometryWithMorphTargetManager(): void;
  27162. /**
  27163. * Returns a new Mesh object parsed from the source provided.
  27164. * @param parsedMesh is the source
  27165. * @param scene defines the hosting scene
  27166. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27167. * @returns a new Mesh
  27168. */
  27169. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27170. /**
  27171. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27172. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27173. * @param name defines the name of the mesh to create
  27174. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27175. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27176. * @param closePath creates a seam between the first and the last points of each path of the path array
  27177. * @param offset is taken in account only if the `pathArray` is containing a single path
  27178. * @param scene defines the hosting scene
  27179. * @param updatable defines if the mesh must be flagged as updatable
  27180. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27181. * @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)
  27182. * @returns a new Mesh
  27183. */
  27184. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27185. /**
  27186. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27187. * @param name defines the name of the mesh to create
  27188. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27189. * @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
  27190. * @param scene defines the hosting scene
  27191. * @param updatable defines if the mesh must be flagged as updatable
  27192. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27193. * @returns a new Mesh
  27194. */
  27195. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27196. /**
  27197. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27198. * @param name defines the name of the mesh to create
  27199. * @param size sets the size (float) of each box side (default 1)
  27200. * @param scene defines the hosting scene
  27201. * @param updatable defines if the mesh must be flagged as updatable
  27202. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27203. * @returns a new Mesh
  27204. */
  27205. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27206. /**
  27207. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27208. * @param name defines the name of the mesh to create
  27209. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27210. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27211. * @param scene defines the hosting scene
  27212. * @param updatable defines if the mesh must be flagged as updatable
  27213. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27214. * @returns a new Mesh
  27215. */
  27216. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27217. /**
  27218. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27219. * @param name defines the name of the mesh to create
  27220. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27221. * @param diameterTop set the top cap diameter (floats, default 1)
  27222. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27223. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27224. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27225. * @param scene defines the hosting scene
  27226. * @param updatable defines if the mesh must be flagged as updatable
  27227. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27228. * @returns a new Mesh
  27229. */
  27230. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27231. /**
  27232. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27233. * @param name defines the name of the mesh to create
  27234. * @param diameter sets the diameter size (float) of the torus (default 1)
  27235. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27236. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27237. * @param scene defines the hosting scene
  27238. * @param updatable defines if the mesh must be flagged as updatable
  27239. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27240. * @returns a new Mesh
  27241. */
  27242. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27243. /**
  27244. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27245. * @param name defines the name of the mesh to create
  27246. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27247. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  27248. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  27249. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  27250. * @param p the number of windings on X axis (positive integers, default 2)
  27251. * @param q the number of windings on Y axis (positive integers, default 3)
  27252. * @param scene defines the hosting scene
  27253. * @param updatable defines if the mesh must be flagged as updatable
  27254. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27255. * @returns a new Mesh
  27256. */
  27257. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27258. /**
  27259. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  27260. * @param name defines the name of the mesh to create
  27261. * @param points is an array successive Vector3
  27262. * @param scene defines the hosting scene
  27263. * @param updatable defines if the mesh must be flagged as updatable
  27264. * @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).
  27265. * @returns a new Mesh
  27266. */
  27267. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  27268. /**
  27269. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  27270. * @param name defines the name of the mesh to create
  27271. * @param points is an array successive Vector3
  27272. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27273. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27274. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27275. * @param scene defines the hosting scene
  27276. * @param updatable defines if the mesh must be flagged as updatable
  27277. * @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)
  27278. * @returns a new Mesh
  27279. */
  27280. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27281. /**
  27282. * Creates a polygon mesh.
  27283. * Please consider using the same method from the MeshBuilder class instead.
  27284. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27285. * 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.
  27286. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27287. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27288. * Remember you can only change the shape positions, not their number when updating a polygon.
  27289. */
  27290. /**
  27291. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27292. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27293. * @param name defines the name of the mesh to create
  27294. * @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
  27295. * @param scene defines the hosting scene
  27296. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27297. * @param updatable defines if the mesh must be flagged as updatable
  27298. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27299. * @returns a new Mesh
  27300. */
  27301. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27302. /**
  27303. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  27304. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  27305. * @param name defines the name of the mesh to create
  27306. * @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
  27307. * @param depth defines the height of extrusion
  27308. * @param scene defines the hosting scene
  27309. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27310. * @param updatable defines if the mesh must be flagged as updatable
  27311. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27312. * @returns a new Mesh
  27313. */
  27314. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27315. /**
  27316. * Creates an extruded shape mesh.
  27317. * 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
  27318. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27319. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27320. * @param name defines the name of the mesh to create
  27321. * @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
  27322. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27323. * @param scale is the value to scale the shape
  27324. * @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
  27325. * @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
  27326. * @param scene defines the hosting scene
  27327. * @param updatable defines if the mesh must be flagged as updatable
  27328. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27329. * @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)
  27330. * @returns a new Mesh
  27331. */
  27332. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27333. /**
  27334. * Creates an custom extruded shape mesh.
  27335. * The custom extrusion is a parametric shape.
  27336. * It has no predefined shape. Its final shape will depend on the input parameters.
  27337. * Please consider using the same method from the MeshBuilder class instead
  27338. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27339. * @param name defines the name of the mesh to create
  27340. * @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
  27341. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27342. * @param scaleFunction is a custom Javascript function called on each path point
  27343. * @param rotationFunction is a custom Javascript function called on each path point
  27344. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27345. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27346. * @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
  27347. * @param scene defines the hosting scene
  27348. * @param updatable defines if the mesh must be flagged as updatable
  27349. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27350. * @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)
  27351. * @returns a new Mesh
  27352. */
  27353. 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;
  27354. /**
  27355. * Creates lathe mesh.
  27356. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27357. * Please consider using the same method from the MeshBuilder class instead
  27358. * @param name defines the name of the mesh to create
  27359. * @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
  27360. * @param radius is the radius value of the lathe
  27361. * @param tessellation is the side number of the lathe.
  27362. * @param scene defines the hosting scene
  27363. * @param updatable defines if the mesh must be flagged as updatable
  27364. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27365. * @returns a new Mesh
  27366. */
  27367. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27368. /**
  27369. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27370. * @param name defines the name of the mesh to create
  27371. * @param size sets the size (float) of both sides of the plane at once (default 1)
  27372. * @param scene defines the hosting scene
  27373. * @param updatable defines if the mesh must be flagged as updatable
  27374. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27375. * @returns a new Mesh
  27376. */
  27377. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27378. /**
  27379. * Creates a ground mesh.
  27380. * Please consider using the same method from the MeshBuilder class instead
  27381. * @param name defines the name of the mesh to create
  27382. * @param width set the width of the ground
  27383. * @param height set the height of the ground
  27384. * @param subdivisions sets the number of subdivisions per side
  27385. * @param scene defines the hosting scene
  27386. * @param updatable defines if the mesh must be flagged as updatable
  27387. * @returns a new Mesh
  27388. */
  27389. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27390. /**
  27391. * Creates a tiled ground mesh.
  27392. * Please consider using the same method from the MeshBuilder class instead
  27393. * @param name defines the name of the mesh to create
  27394. * @param xmin set the ground minimum X coordinate
  27395. * @param zmin set the ground minimum Y coordinate
  27396. * @param xmax set the ground maximum X coordinate
  27397. * @param zmax set the ground maximum Z coordinate
  27398. * @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
  27399. * @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
  27400. * @param scene defines the hosting scene
  27401. * @param updatable defines if the mesh must be flagged as updatable
  27402. * @returns a new Mesh
  27403. */
  27404. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27405. w: number;
  27406. h: number;
  27407. }, precision: {
  27408. w: number;
  27409. h: number;
  27410. }, scene: Scene, updatable?: boolean): Mesh;
  27411. /**
  27412. * Creates a ground mesh from a height map.
  27413. * Please consider using the same method from the MeshBuilder class instead
  27414. * @see http://doc.babylonjs.com/babylon101/height_map
  27415. * @param name defines the name of the mesh to create
  27416. * @param url sets the URL of the height map image resource
  27417. * @param width set the ground width size
  27418. * @param height set the ground height size
  27419. * @param subdivisions sets the number of subdivision per side
  27420. * @param minHeight is the minimum altitude on the ground
  27421. * @param maxHeight is the maximum altitude on the ground
  27422. * @param scene defines the hosting scene
  27423. * @param updatable defines if the mesh must be flagged as updatable
  27424. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27425. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27426. * @returns a new Mesh
  27427. */
  27428. 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;
  27429. /**
  27430. * Creates a tube mesh.
  27431. * The tube is a parametric shape.
  27432. * It has no predefined shape. Its final shape will depend on the input parameters.
  27433. * Please consider using the same method from the MeshBuilder class instead
  27434. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27435. * @param name defines the name of the mesh to create
  27436. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27437. * @param radius sets the tube radius size
  27438. * @param tessellation is the number of sides on the tubular surface
  27439. * @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
  27440. * @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
  27441. * @param scene defines the hosting scene
  27442. * @param updatable defines if the mesh must be flagged as updatable
  27443. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27444. * @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)
  27445. * @returns a new Mesh
  27446. */
  27447. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27448. (i: number, distance: number): number;
  27449. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27450. /**
  27451. * Creates a polyhedron mesh.
  27452. * Please consider using the same method from the MeshBuilder class instead.
  27453. * * 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
  27454. * * The parameter `size` (positive float, default 1) sets the polygon size
  27455. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27456. * * 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`
  27457. * * 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
  27458. * * 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)`)
  27459. * * 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
  27460. * * 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
  27461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27462. * * 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
  27463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27464. * @param name defines the name of the mesh to create
  27465. * @param options defines the options used to create the mesh
  27466. * @param scene defines the hosting scene
  27467. * @returns a new Mesh
  27468. */
  27469. static CreatePolyhedron(name: string, options: {
  27470. type?: number;
  27471. size?: number;
  27472. sizeX?: number;
  27473. sizeY?: number;
  27474. sizeZ?: number;
  27475. custom?: any;
  27476. faceUV?: Vector4[];
  27477. faceColors?: Color4[];
  27478. updatable?: boolean;
  27479. sideOrientation?: number;
  27480. }, scene: Scene): Mesh;
  27481. /**
  27482. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27483. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27484. * * 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`)
  27485. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27486. * * 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
  27487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27488. * * 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
  27489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27490. * @param name defines the name of the mesh
  27491. * @param options defines the options used to create the mesh
  27492. * @param scene defines the hosting scene
  27493. * @returns a new Mesh
  27494. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27495. */
  27496. static CreateIcoSphere(name: string, options: {
  27497. radius?: number;
  27498. flat?: boolean;
  27499. subdivisions?: number;
  27500. sideOrientation?: number;
  27501. updatable?: boolean;
  27502. }, scene: Scene): Mesh;
  27503. /**
  27504. * Creates a decal mesh.
  27505. * Please consider using the same method from the MeshBuilder class instead.
  27506. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27507. * @param name defines the name of the mesh
  27508. * @param sourceMesh defines the mesh receiving the decal
  27509. * @param position sets the position of the decal in world coordinates
  27510. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27511. * @param size sets the decal scaling
  27512. * @param angle sets the angle to rotate the decal
  27513. * @returns a new Mesh
  27514. */
  27515. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27516. /**
  27517. * Prepare internal position array for software CPU skinning
  27518. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27519. */
  27520. setPositionsForCPUSkinning(): Float32Array;
  27521. /**
  27522. * Prepare internal normal array for software CPU skinning
  27523. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27524. */
  27525. setNormalsForCPUSkinning(): Float32Array;
  27526. /**
  27527. * Updates the vertex buffer by applying transformation from the bones
  27528. * @param skeleton defines the skeleton to apply to current mesh
  27529. * @returns the current mesh
  27530. */
  27531. applySkeleton(skeleton: Skeleton): Mesh;
  27532. /**
  27533. * 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
  27534. * @param meshes defines the list of meshes to scan
  27535. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27536. */
  27537. static MinMax(meshes: AbstractMesh[]): {
  27538. min: Vector3;
  27539. max: Vector3;
  27540. };
  27541. /**
  27542. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27543. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27544. * @returns a vector3
  27545. */
  27546. static Center(meshesOrMinMaxVector: {
  27547. min: Vector3;
  27548. max: Vector3;
  27549. } | AbstractMesh[]): Vector3;
  27550. /**
  27551. * Merge the array of meshes into a single mesh for performance reasons.
  27552. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27553. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27554. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27555. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27556. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27557. * @returns a new mesh
  27558. */
  27559. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27560. /** @hidden */
  27561. addInstance(instance: InstancedMesh): void;
  27562. /** @hidden */
  27563. removeInstance(instance: InstancedMesh): void;
  27564. }
  27565. }
  27566. declare module BABYLON {
  27567. /**
  27568. * Define an interface for all classes that will get and set the data on vertices
  27569. */
  27570. interface IGetSetVerticesData {
  27571. /**
  27572. * Gets a boolean indicating if specific vertex data is present
  27573. * @param kind defines the vertex data kind to use
  27574. * @returns true is data kind is present
  27575. */
  27576. isVerticesDataPresent(kind: string): boolean;
  27577. /**
  27578. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27579. * @param kind defines the data kind (Position, normal, etc...)
  27580. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27581. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27582. * @returns a float array containing vertex data
  27583. */
  27584. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27585. /**
  27586. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27587. * @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.
  27588. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27589. * @returns the indices array or an empty array if the mesh has no geometry
  27590. */
  27591. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27592. /**
  27593. * Set specific vertex data
  27594. * @param kind defines the data kind (Position, normal, etc...)
  27595. * @param data defines the vertex data to use
  27596. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27597. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27598. */
  27599. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27600. /**
  27601. * Update a specific associated vertex buffer
  27602. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27603. * - BABYLON.VertexBuffer.PositionKind
  27604. * - BABYLON.VertexBuffer.UVKind
  27605. * - BABYLON.VertexBuffer.UV2Kind
  27606. * - BABYLON.VertexBuffer.UV3Kind
  27607. * - BABYLON.VertexBuffer.UV4Kind
  27608. * - BABYLON.VertexBuffer.UV5Kind
  27609. * - BABYLON.VertexBuffer.UV6Kind
  27610. * - BABYLON.VertexBuffer.ColorKind
  27611. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27612. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27613. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27614. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27615. * @param data defines the data source
  27616. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27617. * @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)
  27618. */
  27619. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27620. /**
  27621. * Creates a new index buffer
  27622. * @param indices defines the indices to store in the index buffer
  27623. * @param totalVertices defines the total number of vertices (could be null)
  27624. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27625. */
  27626. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27627. }
  27628. /**
  27629. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27630. */
  27631. class VertexData {
  27632. /**
  27633. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27634. */
  27635. positions: Nullable<FloatArray>;
  27636. /**
  27637. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27638. */
  27639. normals: Nullable<FloatArray>;
  27640. /**
  27641. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27642. */
  27643. tangents: Nullable<FloatArray>;
  27644. /**
  27645. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27646. */
  27647. uvs: Nullable<FloatArray>;
  27648. /**
  27649. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27650. */
  27651. uvs2: Nullable<FloatArray>;
  27652. /**
  27653. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27654. */
  27655. uvs3: Nullable<FloatArray>;
  27656. /**
  27657. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27658. */
  27659. uvs4: Nullable<FloatArray>;
  27660. /**
  27661. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27662. */
  27663. uvs5: Nullable<FloatArray>;
  27664. /**
  27665. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27666. */
  27667. uvs6: Nullable<FloatArray>;
  27668. /**
  27669. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27670. */
  27671. colors: Nullable<FloatArray>;
  27672. /**
  27673. * 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).
  27674. */
  27675. matricesIndices: Nullable<FloatArray>;
  27676. /**
  27677. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27678. */
  27679. matricesWeights: Nullable<FloatArray>;
  27680. /**
  27681. * An array extending the number of possible indices
  27682. */
  27683. matricesIndicesExtra: Nullable<FloatArray>;
  27684. /**
  27685. * An array extending the number of possible weights when the number of indices is extended
  27686. */
  27687. matricesWeightsExtra: Nullable<FloatArray>;
  27688. /**
  27689. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27690. */
  27691. indices: Nullable<IndicesArray>;
  27692. /**
  27693. * Uses the passed data array to set the set the values for the specified kind of data
  27694. * @param data a linear array of floating numbers
  27695. * @param kind the type of data that is being set, eg positions, colors etc
  27696. */
  27697. set(data: FloatArray, kind: string): void;
  27698. /**
  27699. * Associates the vertexData to the passed Mesh.
  27700. * Sets it as updatable or not (default `false`)
  27701. * @param mesh the mesh the vertexData is applied to
  27702. * @param updatable when used and having the value true allows new data to update the vertexData
  27703. * @returns the VertexData
  27704. */
  27705. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27706. /**
  27707. * Associates the vertexData to the passed Geometry.
  27708. * Sets it as updatable or not (default `false`)
  27709. * @param geometry the geometry the vertexData is applied to
  27710. * @param updatable when used and having the value true allows new data to update the vertexData
  27711. * @returns VertexData
  27712. */
  27713. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27714. /**
  27715. * Updates the associated mesh
  27716. * @param mesh the mesh to be updated
  27717. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27718. * @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
  27719. * @returns VertexData
  27720. */
  27721. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27722. /**
  27723. * Updates the associated geometry
  27724. * @param geometry the geometry to be updated
  27725. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27726. * @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
  27727. * @returns VertexData.
  27728. */
  27729. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27730. private _applyTo;
  27731. private _update;
  27732. /**
  27733. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27734. * @param matrix the transforming matrix
  27735. * @returns the VertexData
  27736. */
  27737. transform(matrix: Matrix): VertexData;
  27738. /**
  27739. * Merges the passed VertexData into the current one
  27740. * @param other the VertexData to be merged into the current one
  27741. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27742. * @returns the modified VertexData
  27743. */
  27744. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27745. private _mergeElement;
  27746. private _validate;
  27747. /**
  27748. * Serializes the VertexData
  27749. * @returns a serialized object
  27750. */
  27751. serialize(): any;
  27752. /**
  27753. * Extracts the vertexData from a mesh
  27754. * @param mesh the mesh from which to extract the VertexData
  27755. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27756. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27757. * @returns the object VertexData associated to the passed mesh
  27758. */
  27759. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27760. /**
  27761. * Extracts the vertexData from the geometry
  27762. * @param geometry the geometry from which to extract the VertexData
  27763. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27764. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27765. * @returns the object VertexData associated to the passed mesh
  27766. */
  27767. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27768. private static _ExtractFrom;
  27769. /**
  27770. * Creates the VertexData for a Ribbon
  27771. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27772. * * pathArray array of paths, each of which an array of successive Vector3
  27773. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27774. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27775. * * 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
  27776. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27777. * * 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)
  27778. * * 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)
  27779. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27780. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27781. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27782. * @returns the VertexData of the ribbon
  27783. */
  27784. static CreateRibbon(options: {
  27785. pathArray: Vector3[][];
  27786. closeArray?: boolean;
  27787. closePath?: boolean;
  27788. offset?: number;
  27789. sideOrientation?: number;
  27790. frontUVs?: Vector4;
  27791. backUVs?: Vector4;
  27792. invertUV?: boolean;
  27793. uvs?: Vector2[];
  27794. colors?: Color4[];
  27795. }): VertexData;
  27796. /**
  27797. * Creates the VertexData for a box
  27798. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27799. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27800. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27801. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27802. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27803. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27804. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27805. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27806. * * 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)
  27807. * * 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)
  27808. * @returns the VertexData of the box
  27809. */
  27810. static CreateBox(options: {
  27811. size?: number;
  27812. width?: number;
  27813. height?: number;
  27814. depth?: number;
  27815. faceUV?: Vector4[];
  27816. faceColors?: Color4[];
  27817. sideOrientation?: number;
  27818. frontUVs?: Vector4;
  27819. backUVs?: Vector4;
  27820. }): VertexData;
  27821. /**
  27822. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27823. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27824. * * segments sets the number of horizontal strips optional, default 32
  27825. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27826. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27827. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27828. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27829. * * 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
  27830. * * 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
  27831. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27832. * * 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)
  27833. * * 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)
  27834. * @returns the VertexData of the ellipsoid
  27835. */
  27836. static CreateSphere(options: {
  27837. segments?: number;
  27838. diameter?: number;
  27839. diameterX?: number;
  27840. diameterY?: number;
  27841. diameterZ?: number;
  27842. arc?: number;
  27843. slice?: number;
  27844. sideOrientation?: number;
  27845. frontUVs?: Vector4;
  27846. backUVs?: Vector4;
  27847. }): VertexData;
  27848. /**
  27849. * Creates the VertexData for a cylinder, cone or prism
  27850. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27851. * * height sets the height (y direction) of the cylinder, optional, default 2
  27852. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27853. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27854. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27855. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27856. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27857. * * 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
  27858. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27859. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27860. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27861. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27862. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27863. * * 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)
  27864. * * 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)
  27865. * @returns the VertexData of the cylinder, cone or prism
  27866. */
  27867. static CreateCylinder(options: {
  27868. height?: number;
  27869. diameterTop?: number;
  27870. diameterBottom?: number;
  27871. diameter?: number;
  27872. tessellation?: number;
  27873. subdivisions?: number;
  27874. arc?: number;
  27875. faceColors?: Color4[];
  27876. faceUV?: Vector4[];
  27877. hasRings?: boolean;
  27878. enclose?: boolean;
  27879. sideOrientation?: number;
  27880. frontUVs?: Vector4;
  27881. backUVs?: Vector4;
  27882. }): VertexData;
  27883. /**
  27884. * Creates the VertexData for a torus
  27885. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27886. * * diameter the diameter of the torus, optional default 1
  27887. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27888. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27889. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27890. * * 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)
  27891. * * 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)
  27892. * @returns the VertexData of the torus
  27893. */
  27894. static CreateTorus(options: {
  27895. diameter?: number;
  27896. thickness?: number;
  27897. tessellation?: number;
  27898. sideOrientation?: number;
  27899. frontUVs?: Vector4;
  27900. backUVs?: Vector4;
  27901. }): VertexData;
  27902. /**
  27903. * Creates the VertexData of the LineSystem
  27904. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27905. * - lines an array of lines, each line being an array of successive Vector3
  27906. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27907. * @returns the VertexData of the LineSystem
  27908. */
  27909. static CreateLineSystem(options: {
  27910. lines: Vector3[][];
  27911. colors?: Nullable<Color4[][]>;
  27912. }): VertexData;
  27913. /**
  27914. * Create the VertexData for a DashedLines
  27915. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27916. * - points an array successive Vector3
  27917. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27918. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27919. * - dashNb the intended total number of dashes, optional, default 200
  27920. * @returns the VertexData for the DashedLines
  27921. */
  27922. static CreateDashedLines(options: {
  27923. points: Vector3[];
  27924. dashSize?: number;
  27925. gapSize?: number;
  27926. dashNb?: number;
  27927. }): VertexData;
  27928. /**
  27929. * Creates the VertexData for a Ground
  27930. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27931. * - width the width (x direction) of the ground, optional, default 1
  27932. * - height the height (z direction) of the ground, optional, default 1
  27933. * - subdivisions the number of subdivisions per side, optional, default 1
  27934. * @returns the VertexData of the Ground
  27935. */
  27936. static CreateGround(options: {
  27937. width?: number;
  27938. height?: number;
  27939. subdivisions?: number;
  27940. subdivisionsX?: number;
  27941. subdivisionsY?: number;
  27942. }): VertexData;
  27943. /**
  27944. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27945. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27946. * * xmin the ground minimum X coordinate, optional, default -1
  27947. * * zmin the ground minimum Z coordinate, optional, default -1
  27948. * * xmax the ground maximum X coordinate, optional, default 1
  27949. * * zmax the ground maximum Z coordinate, optional, default 1
  27950. * * 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}
  27951. * * 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}
  27952. * @returns the VertexData of the TiledGround
  27953. */
  27954. static CreateTiledGround(options: {
  27955. xmin: number;
  27956. zmin: number;
  27957. xmax: number;
  27958. zmax: number;
  27959. subdivisions?: {
  27960. w: number;
  27961. h: number;
  27962. };
  27963. precision?: {
  27964. w: number;
  27965. h: number;
  27966. };
  27967. }): VertexData;
  27968. /**
  27969. * Creates the VertexData of the Ground designed from a heightmap
  27970. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27971. * * width the width (x direction) of the ground
  27972. * * height the height (z direction) of the ground
  27973. * * subdivisions the number of subdivisions per side
  27974. * * minHeight the minimum altitude on the ground, optional, default 0
  27975. * * maxHeight the maximum altitude on the ground, optional default 1
  27976. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27977. * * buffer the array holding the image color data
  27978. * * bufferWidth the width of image
  27979. * * bufferHeight the height of image
  27980. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27981. * @returns the VertexData of the Ground designed from a heightmap
  27982. */
  27983. static CreateGroundFromHeightMap(options: {
  27984. width: number;
  27985. height: number;
  27986. subdivisions: number;
  27987. minHeight: number;
  27988. maxHeight: number;
  27989. colorFilter: Color3;
  27990. buffer: Uint8Array;
  27991. bufferWidth: number;
  27992. bufferHeight: number;
  27993. alphaFilter: number;
  27994. }): VertexData;
  27995. /**
  27996. * Creates the VertexData for a Plane
  27997. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27998. * * size sets the width and height of the plane to the value of size, optional default 1
  27999. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  28000. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  28001. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28002. * * 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)
  28003. * * 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)
  28004. * @returns the VertexData of the box
  28005. */
  28006. static CreatePlane(options: {
  28007. size?: number;
  28008. width?: number;
  28009. height?: number;
  28010. sideOrientation?: number;
  28011. frontUVs?: Vector4;
  28012. backUVs?: Vector4;
  28013. }): VertexData;
  28014. /**
  28015. * Creates the VertexData of the Disc or regular Polygon
  28016. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  28017. * * radius the radius of the disc, optional default 0.5
  28018. * * tessellation the number of polygon sides, optional, default 64
  28019. * * 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
  28020. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28021. * * 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)
  28022. * * 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)
  28023. * @returns the VertexData of the box
  28024. */
  28025. static CreateDisc(options: {
  28026. radius?: number;
  28027. tessellation?: number;
  28028. arc?: number;
  28029. sideOrientation?: number;
  28030. frontUVs?: Vector4;
  28031. backUVs?: Vector4;
  28032. }): VertexData;
  28033. /**
  28034. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  28035. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  28036. * @param polygon a mesh built from polygonTriangulation.build()
  28037. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28038. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28039. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28040. * @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)
  28041. * @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)
  28042. * @returns the VertexData of the Polygon
  28043. */
  28044. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  28045. /**
  28046. * Creates the VertexData of the IcoSphere
  28047. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  28048. * * radius the radius of the IcoSphere, optional default 1
  28049. * * radiusX allows stretching in the x direction, optional, default radius
  28050. * * radiusY allows stretching in the y direction, optional, default radius
  28051. * * radiusZ allows stretching in the z direction, optional, default radius
  28052. * * flat when true creates a flat shaded mesh, optional, default true
  28053. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28054. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28055. * * 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)
  28056. * * 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)
  28057. * @returns the VertexData of the IcoSphere
  28058. */
  28059. static CreateIcoSphere(options: {
  28060. radius?: number;
  28061. radiusX?: number;
  28062. radiusY?: number;
  28063. radiusZ?: number;
  28064. flat?: boolean;
  28065. subdivisions?: number;
  28066. sideOrientation?: number;
  28067. frontUVs?: Vector4;
  28068. backUVs?: Vector4;
  28069. }): VertexData;
  28070. /**
  28071. * Creates the VertexData for a Polyhedron
  28072. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  28073. * * type provided types are:
  28074. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  28075. * * 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)
  28076. * * size the size of the IcoSphere, optional default 1
  28077. * * sizeX allows stretching in the x direction, optional, default size
  28078. * * sizeY allows stretching in the y direction, optional, default size
  28079. * * sizeZ allows stretching in the z direction, optional, default size
  28080. * * 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
  28081. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28082. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28083. * * flat when true creates a flat shaded mesh, optional, default true
  28084. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28085. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28086. * * 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)
  28087. * * 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)
  28088. * @returns the VertexData of the Polyhedron
  28089. */
  28090. static CreatePolyhedron(options: {
  28091. type?: number;
  28092. size?: number;
  28093. sizeX?: number;
  28094. sizeY?: number;
  28095. sizeZ?: number;
  28096. custom?: any;
  28097. faceUV?: Vector4[];
  28098. faceColors?: Color4[];
  28099. flat?: boolean;
  28100. sideOrientation?: number;
  28101. frontUVs?: Vector4;
  28102. backUVs?: Vector4;
  28103. }): VertexData;
  28104. /**
  28105. * Creates the VertexData for a TorusKnot
  28106. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  28107. * * radius the radius of the torus knot, optional, default 2
  28108. * * tube the thickness of the tube, optional, default 0.5
  28109. * * radialSegments the number of sides on each tube segments, optional, default 32
  28110. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  28111. * * p the number of windings around the z axis, optional, default 2
  28112. * * q the number of windings around the x axis, optional, default 3
  28113. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28114. * * 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)
  28115. * * 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)
  28116. * @returns the VertexData of the Torus Knot
  28117. */
  28118. static CreateTorusKnot(options: {
  28119. radius?: number;
  28120. tube?: number;
  28121. radialSegments?: number;
  28122. tubularSegments?: number;
  28123. p?: number;
  28124. q?: number;
  28125. sideOrientation?: number;
  28126. frontUVs?: Vector4;
  28127. backUVs?: Vector4;
  28128. }): VertexData;
  28129. /**
  28130. * Compute normals for given positions and indices
  28131. * @param positions an array of vertex positions, [...., x, y, z, ......]
  28132. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  28133. * @param normals an array of vertex normals, [...., x, y, z, ......]
  28134. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  28135. * * facetNormals : optional array of facet normals (vector3)
  28136. * * facetPositions : optional array of facet positions (vector3)
  28137. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  28138. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  28139. * * bInfo : optional bounding info, required for facetPartitioning computation
  28140. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  28141. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  28142. * * useRightHandedSystem: optional boolean to for right handed system computation
  28143. * * depthSort : optional boolean to enable the facet depth sort computation
  28144. * * distanceTo : optional Vector3 to compute the facet depth from this location
  28145. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  28146. */
  28147. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  28148. facetNormals?: any;
  28149. facetPositions?: any;
  28150. facetPartitioning?: any;
  28151. ratio?: number;
  28152. bInfo?: any;
  28153. bbSize?: Vector3;
  28154. subDiv?: any;
  28155. useRightHandedSystem?: boolean;
  28156. depthSort?: boolean;
  28157. distanceTo?: Vector3;
  28158. depthSortedFacets?: any;
  28159. }): void;
  28160. private static _ComputeSides;
  28161. /**
  28162. * Applies VertexData created from the imported parameters to the geometry
  28163. * @param parsedVertexData the parsed data from an imported file
  28164. * @param geometry the geometry to apply the VertexData to
  28165. */
  28166. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  28167. }
  28168. }
  28169. declare module BABYLON {
  28170. /**
  28171. * Class containing static functions to help procedurally build meshes
  28172. */
  28173. class MeshBuilder {
  28174. private static updateSideOrientation;
  28175. /**
  28176. * Creates a box mesh
  28177. * * The parameter `size` sets the size (float) of each box side (default 1)
  28178. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  28179. * * 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)
  28180. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28182. * * 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
  28183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28184. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  28185. * @param name defines the name of the mesh
  28186. * @param options defines the options used to create the mesh
  28187. * @param scene defines the hosting scene
  28188. * @returns the box mesh
  28189. */
  28190. static CreateBox(name: string, options: {
  28191. size?: number;
  28192. width?: number;
  28193. height?: number;
  28194. depth?: number;
  28195. faceUV?: Vector4[];
  28196. faceColors?: Color4[];
  28197. sideOrientation?: number;
  28198. frontUVs?: Vector4;
  28199. backUVs?: Vector4;
  28200. updatable?: boolean;
  28201. }, scene?: Nullable<Scene>): Mesh;
  28202. /**
  28203. * Creates a sphere mesh
  28204. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  28205. * * 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`)
  28206. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  28207. * * 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
  28208. * * 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)
  28209. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28210. * * 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
  28211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28212. * @param name defines the name of the mesh
  28213. * @param options defines the options used to create the mesh
  28214. * @param scene defines the hosting scene
  28215. * @returns the sphere mesh
  28216. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  28217. */
  28218. static CreateSphere(name: string, options: {
  28219. segments?: number;
  28220. diameter?: number;
  28221. diameterX?: number;
  28222. diameterY?: number;
  28223. diameterZ?: number;
  28224. arc?: number;
  28225. slice?: number;
  28226. sideOrientation?: number;
  28227. frontUVs?: Vector4;
  28228. backUVs?: Vector4;
  28229. updatable?: boolean;
  28230. }, scene: any): Mesh;
  28231. /**
  28232. * Creates a plane polygonal mesh. By default, this is a disc
  28233. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28234. * * 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
  28235. * * 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
  28236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28237. * * 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
  28238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28239. * @param name defines the name of the mesh
  28240. * @param options defines the options used to create the mesh
  28241. * @param scene defines the hosting scene
  28242. * @returns the plane polygonal mesh
  28243. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28244. */
  28245. static CreateDisc(name: string, options: {
  28246. radius?: number;
  28247. tessellation?: number;
  28248. arc?: number;
  28249. updatable?: boolean;
  28250. sideOrientation?: number;
  28251. frontUVs?: Vector4;
  28252. backUVs?: Vector4;
  28253. }, scene?: Nullable<Scene>): Mesh;
  28254. /**
  28255. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28256. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28257. * * 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`)
  28258. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28259. * * 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
  28260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28261. * * 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
  28262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28263. * @param name defines the name of the mesh
  28264. * @param options defines the options used to create the mesh
  28265. * @param scene defines the hosting scene
  28266. * @returns the icosahedron mesh
  28267. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28268. */
  28269. static CreateIcoSphere(name: string, options: {
  28270. radius?: number;
  28271. radiusX?: number;
  28272. radiusY?: number;
  28273. radiusZ?: number;
  28274. flat?: boolean;
  28275. subdivisions?: number;
  28276. sideOrientation?: number;
  28277. frontUVs?: Vector4;
  28278. backUVs?: Vector4;
  28279. updatable?: boolean;
  28280. }, scene: Scene): Mesh;
  28281. /**
  28282. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28283. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  28284. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  28285. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  28286. * * 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
  28287. * * 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
  28288. * * 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
  28289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28290. * * 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
  28291. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28292. * * 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
  28293. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  28294. * * 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
  28295. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  28296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28297. * @param name defines the name of the mesh
  28298. * @param options defines the options used to create the mesh
  28299. * @param scene defines the hosting scene
  28300. * @returns the ribbon mesh
  28301. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  28302. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28303. */
  28304. static CreateRibbon(name: string, options: {
  28305. pathArray: Vector3[][];
  28306. closeArray?: boolean;
  28307. closePath?: boolean;
  28308. offset?: number;
  28309. updatable?: boolean;
  28310. sideOrientation?: number;
  28311. frontUVs?: Vector4;
  28312. backUVs?: Vector4;
  28313. instance?: Mesh;
  28314. invertUV?: boolean;
  28315. uvs?: Vector2[];
  28316. colors?: Color4[];
  28317. }, scene?: Nullable<Scene>): Mesh;
  28318. /**
  28319. * Creates a cylinder or a cone mesh
  28320. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  28321. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  28322. * * 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.
  28323. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  28324. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  28325. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  28326. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  28327. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  28328. * * 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).
  28329. * * 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
  28330. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  28331. * * 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
  28332. * * 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.
  28333. * * If `enclose` is false, a ring surface is one element.
  28334. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  28335. * * 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
  28336. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28337. * * 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
  28338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28339. * @param name defines the name of the mesh
  28340. * @param options defines the options used to create the mesh
  28341. * @param scene defines the hosting scene
  28342. * @returns the cylinder mesh
  28343. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  28344. */
  28345. static CreateCylinder(name: string, options: {
  28346. height?: number;
  28347. diameterTop?: number;
  28348. diameterBottom?: number;
  28349. diameter?: number;
  28350. tessellation?: number;
  28351. subdivisions?: number;
  28352. arc?: number;
  28353. faceColors?: Color4[];
  28354. faceUV?: Vector4[];
  28355. updatable?: boolean;
  28356. hasRings?: boolean;
  28357. enclose?: boolean;
  28358. sideOrientation?: number;
  28359. frontUVs?: Vector4;
  28360. backUVs?: Vector4;
  28361. }, scene: any): Mesh;
  28362. /**
  28363. * Creates a torus mesh
  28364. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28365. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28366. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28368. * * 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
  28369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28370. * @param name defines the name of the mesh
  28371. * @param options defines the options used to create the mesh
  28372. * @param scene defines the hosting scene
  28373. * @returns the torus mesh
  28374. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  28375. */
  28376. static CreateTorus(name: string, options: {
  28377. diameter?: number;
  28378. thickness?: number;
  28379. tessellation?: number;
  28380. updatable?: boolean;
  28381. sideOrientation?: number;
  28382. frontUVs?: Vector4;
  28383. backUVs?: Vector4;
  28384. }, scene: any): Mesh;
  28385. /**
  28386. * Creates a torus knot mesh
  28387. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28388. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28389. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28390. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28392. * * 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
  28393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28394. * @param name defines the name of the mesh
  28395. * @param options defines the options used to create the mesh
  28396. * @param scene defines the hosting scene
  28397. * @returns the torus knot mesh
  28398. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  28399. */
  28400. static CreateTorusKnot(name: string, options: {
  28401. radius?: number;
  28402. tube?: number;
  28403. radialSegments?: number;
  28404. tubularSegments?: number;
  28405. p?: number;
  28406. q?: number;
  28407. updatable?: boolean;
  28408. sideOrientation?: number;
  28409. frontUVs?: Vector4;
  28410. backUVs?: Vector4;
  28411. }, scene: any): Mesh;
  28412. /**
  28413. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28414. * * 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
  28415. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28416. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28417. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28418. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28419. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28420. * * 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
  28421. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28423. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28424. * @param name defines the name of the new line system
  28425. * @param options defines the options used to create the line system
  28426. * @param scene defines the hosting scene
  28427. * @returns a new line system mesh
  28428. */
  28429. static CreateLineSystem(name: string, options: {
  28430. lines: Vector3[][];
  28431. updatable?: boolean;
  28432. instance?: Nullable<LinesMesh>;
  28433. colors?: Nullable<Color4[][]>;
  28434. useVertexAlpha?: boolean;
  28435. }, scene: Nullable<Scene>): LinesMesh;
  28436. /**
  28437. * Creates a line mesh
  28438. * 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
  28439. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28440. * * The parameter `points` is an array successive Vector3
  28441. * * 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
  28442. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28443. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28444. * * When updating an instance, remember that only point positions can change, not the number of points
  28445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  28447. * @param name defines the name of the new line system
  28448. * @param options defines the options used to create the line system
  28449. * @param scene defines the hosting scene
  28450. * @returns a new line mesh
  28451. */
  28452. static CreateLines(name: string, options: {
  28453. points: Vector3[];
  28454. updatable?: boolean;
  28455. instance?: Nullable<LinesMesh>;
  28456. colors?: Color4[];
  28457. useVertexAlpha?: boolean;
  28458. }, scene?: Nullable<Scene>): LinesMesh;
  28459. /**
  28460. * Creates a dashed line mesh
  28461. * * 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
  28462. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28463. * * The parameter `points` is an array successive Vector3
  28464. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28465. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28466. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28467. * * 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
  28468. * * When updating an instance, remember that only point positions can change, not the number of points
  28469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28470. * @param name defines the name of the mesh
  28471. * @param options defines the options used to create the mesh
  28472. * @param scene defines the hosting scene
  28473. * @returns the dashed line mesh
  28474. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28475. */
  28476. static CreateDashedLines(name: string, options: {
  28477. points: Vector3[];
  28478. dashSize?: number;
  28479. gapSize?: number;
  28480. dashNb?: number;
  28481. updatable?: boolean;
  28482. instance?: LinesMesh;
  28483. }, scene?: Nullable<Scene>): LinesMesh;
  28484. /**
  28485. * 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.
  28486. * * 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.
  28487. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28488. * * 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.
  28489. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28490. * * 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
  28491. * * 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
  28492. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28494. * * 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
  28495. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28497. * @param name defines the name of the mesh
  28498. * @param options defines the options used to create the mesh
  28499. * @param scene defines the hosting scene
  28500. * @returns the extruded shape mesh
  28501. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28502. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28503. */
  28504. static ExtrudeShape(name: string, options: {
  28505. shape: Vector3[];
  28506. path: Vector3[];
  28507. scale?: number;
  28508. rotation?: number;
  28509. cap?: number;
  28510. updatable?: boolean;
  28511. sideOrientation?: number;
  28512. frontUVs?: Vector4;
  28513. backUVs?: Vector4;
  28514. instance?: Mesh;
  28515. invertUV?: boolean;
  28516. }, scene?: Nullable<Scene>): Mesh;
  28517. /**
  28518. * Creates an custom extruded shape mesh.
  28519. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28520. * * 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.
  28521. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28522. * * 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
  28523. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28524. * * 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
  28525. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28526. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28527. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28528. * * 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
  28529. * * 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
  28530. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28532. * * 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
  28533. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28535. * @param name defines the name of the mesh
  28536. * @param options defines the options used to create the mesh
  28537. * @param scene defines the hosting scene
  28538. * @returns the custom extruded shape mesh
  28539. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28540. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28541. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28542. */
  28543. static ExtrudeShapeCustom(name: string, options: {
  28544. shape: Vector3[];
  28545. path: Vector3[];
  28546. scaleFunction?: any;
  28547. rotationFunction?: any;
  28548. ribbonCloseArray?: boolean;
  28549. ribbonClosePath?: boolean;
  28550. cap?: number;
  28551. updatable?: boolean;
  28552. sideOrientation?: number;
  28553. frontUVs?: Vector4;
  28554. backUVs?: Vector4;
  28555. instance?: Mesh;
  28556. invertUV?: boolean;
  28557. }, scene: Scene): Mesh;
  28558. /**
  28559. * Creates lathe mesh.
  28560. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28561. * * 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
  28562. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28563. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28564. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28565. * * 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
  28566. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28567. * * 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
  28568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28569. * * 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
  28570. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28572. * @param name defines the name of the mesh
  28573. * @param options defines the options used to create the mesh
  28574. * @param scene defines the hosting scene
  28575. * @returns the lathe mesh
  28576. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28577. */
  28578. static CreateLathe(name: string, options: {
  28579. shape: Vector3[];
  28580. radius?: number;
  28581. tessellation?: number;
  28582. clip?: number;
  28583. arc?: number;
  28584. closed?: boolean;
  28585. updatable?: boolean;
  28586. sideOrientation?: number;
  28587. frontUVs?: Vector4;
  28588. backUVs?: Vector4;
  28589. cap?: number;
  28590. invertUV?: boolean;
  28591. }, scene: Scene): Mesh;
  28592. /**
  28593. * Creates a plane mesh
  28594. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28595. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28596. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28597. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28598. * * 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
  28599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28600. * @param name defines the name of the mesh
  28601. * @param options defines the options used to create the mesh
  28602. * @param scene defines the hosting scene
  28603. * @returns the plane mesh
  28604. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  28605. */
  28606. static CreatePlane(name: string, options: {
  28607. size?: number;
  28608. width?: number;
  28609. height?: number;
  28610. sideOrientation?: number;
  28611. frontUVs?: Vector4;
  28612. backUVs?: Vector4;
  28613. updatable?: boolean;
  28614. sourcePlane?: Plane;
  28615. }, scene: Scene): Mesh;
  28616. /**
  28617. * Creates a ground mesh
  28618. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28619. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28621. * @param name defines the name of the mesh
  28622. * @param options defines the options used to create the mesh
  28623. * @param scene defines the hosting scene
  28624. * @returns the ground mesh
  28625. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  28626. */
  28627. static CreateGround(name: string, options: {
  28628. width?: number;
  28629. height?: number;
  28630. subdivisions?: number;
  28631. subdivisionsX?: number;
  28632. subdivisionsY?: number;
  28633. updatable?: boolean;
  28634. }, scene: any): Mesh;
  28635. /**
  28636. * Creates a tiled ground mesh
  28637. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28638. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28639. * * 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
  28640. * * 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
  28641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28642. * @param name defines the name of the mesh
  28643. * @param options defines the options used to create the mesh
  28644. * @param scene defines the hosting scene
  28645. * @returns the tiled ground mesh
  28646. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  28647. */
  28648. static CreateTiledGround(name: string, options: {
  28649. xmin: number;
  28650. zmin: number;
  28651. xmax: number;
  28652. zmax: number;
  28653. subdivisions?: {
  28654. w: number;
  28655. h: number;
  28656. };
  28657. precision?: {
  28658. w: number;
  28659. h: number;
  28660. };
  28661. updatable?: boolean;
  28662. }, scene: Scene): Mesh;
  28663. /**
  28664. * Creates a ground mesh from a height map
  28665. * * The parameter `url` sets the URL of the height map image resource.
  28666. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28667. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28668. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28669. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28670. * * 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.
  28671. * * 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).
  28672. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28674. * @param name defines the name of the mesh
  28675. * @param url defines the url to the height map
  28676. * @param options defines the options used to create the mesh
  28677. * @param scene defines the hosting scene
  28678. * @returns the ground mesh
  28679. * @see https://doc.babylonjs.com/babylon101/height_map
  28680. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  28681. */
  28682. static CreateGroundFromHeightMap(name: string, url: string, options: {
  28683. width?: number;
  28684. height?: number;
  28685. subdivisions?: number;
  28686. minHeight?: number;
  28687. maxHeight?: number;
  28688. colorFilter?: Color3;
  28689. alphaFilter?: number;
  28690. updatable?: boolean;
  28691. onReady?: (mesh: GroundMesh) => void;
  28692. }, scene: Scene): GroundMesh;
  28693. /**
  28694. * Creates a polygon mesh
  28695. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  28696. * * 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
  28697. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28699. * * 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)
  28700. * * Remember you can only change the shape positions, not their number when updating a polygon
  28701. * @param name defines the name of the mesh
  28702. * @param options defines the options used to create the mesh
  28703. * @param scene defines the hosting scene
  28704. * @returns the polygon mesh
  28705. */
  28706. static CreatePolygon(name: string, options: {
  28707. shape: Vector3[];
  28708. holes?: Vector3[][];
  28709. depth?: number;
  28710. faceUV?: Vector4[];
  28711. faceColors?: Color4[];
  28712. updatable?: boolean;
  28713. sideOrientation?: number;
  28714. frontUVs?: Vector4;
  28715. backUVs?: Vector4;
  28716. }, scene: Scene): Mesh;
  28717. /**
  28718. * Creates an extruded polygon mesh, with depth in the Y direction.
  28719. * * 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)
  28720. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28721. * @param name defines the name of the mesh
  28722. * @param options defines the options used to create the mesh
  28723. * @param scene defines the hosting scene
  28724. * @returns the polygon mesh
  28725. */
  28726. static ExtrudePolygon(name: string, options: {
  28727. shape: Vector3[];
  28728. holes?: Vector3[][];
  28729. depth?: number;
  28730. faceUV?: Vector4[];
  28731. faceColors?: Color4[];
  28732. updatable?: boolean;
  28733. sideOrientation?: number;
  28734. frontUVs?: Vector4;
  28735. backUVs?: Vector4;
  28736. }, scene: Scene): Mesh;
  28737. /**
  28738. * Creates a tube mesh.
  28739. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28740. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  28741. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  28742. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  28743. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  28744. * * 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)
  28745. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  28746. * * 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
  28747. * * 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
  28748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28749. * * 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
  28750. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28752. * @param name defines the name of the mesh
  28753. * @param options defines the options used to create the mesh
  28754. * @param scene defines the hosting scene
  28755. * @returns the tube mesh
  28756. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28757. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  28758. */
  28759. static CreateTube(name: string, options: {
  28760. path: Vector3[];
  28761. radius?: number;
  28762. tessellation?: number;
  28763. radiusFunction?: {
  28764. (i: number, distance: number): number;
  28765. };
  28766. cap?: number;
  28767. arc?: number;
  28768. updatable?: boolean;
  28769. sideOrientation?: number;
  28770. frontUVs?: Vector4;
  28771. backUVs?: Vector4;
  28772. instance?: Mesh;
  28773. invertUV?: boolean;
  28774. }, scene: Scene): Mesh;
  28775. /**
  28776. * Creates a polyhedron mesh
  28777. * * 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
  28778. * * The parameter `size` (positive float, default 1) sets the polygon size
  28779. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28780. * * 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`
  28781. * * 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
  28782. * * 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)`)
  28783. * * 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
  28784. * * 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
  28785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28786. * * 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
  28787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28788. * @param name defines the name of the mesh
  28789. * @param options defines the options used to create the mesh
  28790. * @param scene defines the hosting scene
  28791. * @returns the polyhedron mesh
  28792. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  28793. */
  28794. static CreatePolyhedron(name: string, options: {
  28795. type?: number;
  28796. size?: number;
  28797. sizeX?: number;
  28798. sizeY?: number;
  28799. sizeZ?: number;
  28800. custom?: any;
  28801. faceUV?: Vector4[];
  28802. faceColors?: Color4[];
  28803. flat?: boolean;
  28804. updatable?: boolean;
  28805. sideOrientation?: number;
  28806. frontUVs?: Vector4;
  28807. backUVs?: Vector4;
  28808. }, scene: Scene): Mesh;
  28809. /**
  28810. * Creates a decal mesh.
  28811. * 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
  28812. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  28813. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  28814. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  28815. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  28816. * @param name defines the name of the mesh
  28817. * @param sourceMesh defines the mesh where the decal must be applied
  28818. * @param options defines the options used to create the mesh
  28819. * @param scene defines the hosting scene
  28820. * @returns the decal mesh
  28821. * @see https://doc.babylonjs.com/how_to/decals
  28822. */
  28823. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28824. position?: Vector3;
  28825. normal?: Vector3;
  28826. size?: Vector3;
  28827. angle?: number;
  28828. }): Mesh;
  28829. private static _ExtrudeShapeGeneric;
  28830. }
  28831. }
  28832. declare module BABYLON {
  28833. /**
  28834. * Class used to represent a specific level of detail of a mesh
  28835. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28836. */
  28837. class MeshLODLevel {
  28838. /** Defines the distance where this level should star being displayed */
  28839. distance: number;
  28840. /** Defines the mesh to use to render this level */
  28841. mesh: Nullable<Mesh>;
  28842. /**
  28843. * Creates a new LOD level
  28844. * @param distance defines the distance where this level should star being displayed
  28845. * @param mesh defines the mesh to use to render this level
  28846. */
  28847. constructor(
  28848. /** Defines the distance where this level should star being displayed */
  28849. distance: number,
  28850. /** Defines the mesh to use to render this level */
  28851. mesh: Nullable<Mesh>);
  28852. }
  28853. }
  28854. declare module BABYLON {
  28855. /**
  28856. * A simplifier interface for future simplification implementations
  28857. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28858. */
  28859. interface ISimplifier {
  28860. /**
  28861. * Simplification of a given mesh according to the given settings.
  28862. * Since this requires computation, it is assumed that the function runs async.
  28863. * @param settings The settings of the simplification, including quality and distance
  28864. * @param successCallback A callback that will be called after the mesh was simplified.
  28865. * @param errorCallback in case of an error, this callback will be called. optional.
  28866. */
  28867. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28868. }
  28869. /**
  28870. * Expected simplification settings.
  28871. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28872. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28873. */
  28874. interface ISimplificationSettings {
  28875. /**
  28876. * Gets or sets the expected quality
  28877. */
  28878. quality: number;
  28879. /**
  28880. * Gets or sets the distance when this optimized version should be used
  28881. */
  28882. distance: number;
  28883. /**
  28884. * Gets an already optimized mesh
  28885. */
  28886. optimizeMesh?: boolean;
  28887. }
  28888. /**
  28889. * Class used to specify simplification options
  28890. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28891. */
  28892. class SimplificationSettings implements ISimplificationSettings {
  28893. /** expected quality */
  28894. quality: number;
  28895. /** distance when this optimized version should be used */
  28896. distance: number;
  28897. /** already optimized mesh */
  28898. optimizeMesh?: boolean | undefined;
  28899. /**
  28900. * Creates a SimplificationSettings
  28901. * @param quality expected quality
  28902. * @param distance distance when this optimized version should be used
  28903. * @param optimizeMesh already optimized mesh
  28904. */
  28905. constructor(
  28906. /** expected quality */
  28907. quality: number,
  28908. /** distance when this optimized version should be used */
  28909. distance: number,
  28910. /** already optimized mesh */
  28911. optimizeMesh?: boolean | undefined);
  28912. }
  28913. /**
  28914. * Interface used to define a simplification task
  28915. */
  28916. interface ISimplificationTask {
  28917. /**
  28918. * Array of settings
  28919. */
  28920. settings: Array<ISimplificationSettings>;
  28921. /**
  28922. * Simplification type
  28923. */
  28924. simplificationType: SimplificationType;
  28925. /**
  28926. * Mesh to simplify
  28927. */
  28928. mesh: Mesh;
  28929. /**
  28930. * Callback called on success
  28931. */
  28932. successCallback?: () => void;
  28933. /**
  28934. * Defines if parallel processing can be used
  28935. */
  28936. parallelProcessing: boolean;
  28937. }
  28938. /**
  28939. * Queue used to order the simplification tasks
  28940. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28941. */
  28942. class SimplificationQueue {
  28943. private _simplificationArray;
  28944. /**
  28945. * Gets a boolean indicating that the process is still running
  28946. */
  28947. running: boolean;
  28948. /**
  28949. * Creates a new queue
  28950. */
  28951. constructor();
  28952. /**
  28953. * Adds a new simplification task
  28954. * @param task defines a task to add
  28955. */
  28956. addTask(task: ISimplificationTask): void;
  28957. /**
  28958. * Execute next task
  28959. */
  28960. executeNext(): void;
  28961. /**
  28962. * Execute a simplification task
  28963. * @param task defines the task to run
  28964. */
  28965. runSimplification(task: ISimplificationTask): void;
  28966. private getSimplifier;
  28967. }
  28968. /**
  28969. * The implemented types of simplification
  28970. * At the moment only Quadratic Error Decimation is implemented
  28971. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28972. */
  28973. enum SimplificationType {
  28974. /** Quadratic error decimation */
  28975. QUADRATIC = 0
  28976. }
  28977. }
  28978. declare module BABYLON {
  28979. interface Scene {
  28980. /** @hidden (Backing field) */
  28981. _simplificationQueue: SimplificationQueue;
  28982. /**
  28983. * Gets or sets the simplification queue attached to the scene
  28984. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28985. */
  28986. simplificationQueue: SimplificationQueue;
  28987. }
  28988. interface Mesh {
  28989. /**
  28990. * Simplify the mesh according to the given array of settings.
  28991. * Function will return immediately and will simplify async
  28992. * @param settings a collection of simplification settings
  28993. * @param parallelProcessing should all levels calculate parallel or one after the other
  28994. * @param simplificationType the type of simplification to run
  28995. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  28996. * @returns the current mesh
  28997. */
  28998. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  28999. }
  29000. /**
  29001. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  29002. * created in a scene
  29003. */
  29004. class SimplicationQueueSceneComponent implements ISceneComponent {
  29005. /**
  29006. * The component name helpfull to identify the component in the list of scene components.
  29007. */
  29008. readonly name: string;
  29009. /**
  29010. * The scene the component belongs to.
  29011. */
  29012. scene: Scene;
  29013. /**
  29014. * Creates a new instance of the component for the given scene
  29015. * @param scene Defines the scene to register the component in
  29016. */
  29017. constructor(scene: Scene);
  29018. /**
  29019. * Registers the component in a given scene
  29020. */
  29021. register(): void;
  29022. /**
  29023. * Rebuilds the elements related to this component in case of
  29024. * context lost for instance.
  29025. */
  29026. rebuild(): void;
  29027. /**
  29028. * Disposes the component and the associated ressources
  29029. */
  29030. dispose(): void;
  29031. private _beforeCameraUpdate;
  29032. }
  29033. }
  29034. declare module BABYLON {
  29035. /**
  29036. * Polygon
  29037. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29038. */
  29039. class Polygon {
  29040. /**
  29041. * Creates a rectangle
  29042. * @param xmin bottom X coord
  29043. * @param ymin bottom Y coord
  29044. * @param xmax top X coord
  29045. * @param ymax top Y coord
  29046. * @returns points that make the resulting rectation
  29047. */
  29048. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  29049. /**
  29050. * Creates a circle
  29051. * @param radius radius of circle
  29052. * @param cx scale in x
  29053. * @param cy scale in y
  29054. * @param numberOfSides number of sides that make up the circle
  29055. * @returns points that make the resulting circle
  29056. */
  29057. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  29058. /**
  29059. * Creates a polygon from input string
  29060. * @param input Input polygon data
  29061. * @returns the parsed points
  29062. */
  29063. static Parse(input: string): Vector2[];
  29064. /**
  29065. * Starts building a polygon from x and y coordinates
  29066. * @param x x coordinate
  29067. * @param y y coordinate
  29068. * @returns the started path2
  29069. */
  29070. static StartingAt(x: number, y: number): Path2;
  29071. }
  29072. /**
  29073. * Builds a polygon
  29074. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  29075. */
  29076. class PolygonMeshBuilder {
  29077. private _points;
  29078. private _outlinepoints;
  29079. private _holes;
  29080. private _name;
  29081. private _scene;
  29082. private _epoints;
  29083. private _eholes;
  29084. private _addToepoint;
  29085. /**
  29086. * Creates a PolygonMeshBuilder
  29087. * @param name name of the builder
  29088. * @param contours Path of the polygon
  29089. * @param scene scene to add to
  29090. */
  29091. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  29092. /**
  29093. * Adds a whole within the polygon
  29094. * @param hole Array of points defining the hole
  29095. * @returns this
  29096. */
  29097. addHole(hole: Vector2[]): PolygonMeshBuilder;
  29098. /**
  29099. * Creates the polygon
  29100. * @param updatable If the mesh should be updatable
  29101. * @param depth The depth of the mesh created
  29102. * @returns the created mesh
  29103. */
  29104. build(updatable?: boolean, depth?: number): Mesh;
  29105. /**
  29106. * Adds a side to the polygon
  29107. * @param positions points that make the polygon
  29108. * @param normals normals of the polygon
  29109. * @param uvs uvs of the polygon
  29110. * @param indices indices of the polygon
  29111. * @param bounds bounds of the polygon
  29112. * @param points points of the polygon
  29113. * @param depth depth of the polygon
  29114. * @param flip flip of the polygon
  29115. */
  29116. private addSide;
  29117. }
  29118. }
  29119. declare module BABYLON {
  29120. /**
  29121. * Base class for submeshes
  29122. */
  29123. class BaseSubMesh {
  29124. /** @hidden */
  29125. _materialDefines: Nullable<MaterialDefines>;
  29126. /** @hidden */
  29127. _materialEffect: Nullable<Effect>;
  29128. /**
  29129. * Gets associated effect
  29130. */
  29131. readonly effect: Nullable<Effect>;
  29132. /**
  29133. * Sets associated effect (effect used to render this submesh)
  29134. * @param effect defines the effect to associate with
  29135. * @param defines defines the set of defines used to compile this effect
  29136. */
  29137. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29138. }
  29139. /**
  29140. * Defines a subdivision inside a mesh
  29141. */
  29142. class SubMesh extends BaseSubMesh implements ICullable {
  29143. /** the material index to use */
  29144. materialIndex: number;
  29145. /** vertex index start */
  29146. verticesStart: number;
  29147. /** vertices count */
  29148. verticesCount: number;
  29149. /** index start */
  29150. indexStart: number;
  29151. /** indices count */
  29152. indexCount: number;
  29153. /** @hidden */
  29154. _linesIndexCount: number;
  29155. private _mesh;
  29156. private _renderingMesh;
  29157. private _boundingInfo;
  29158. private _linesIndexBuffer;
  29159. /** @hidden */
  29160. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29161. /** @hidden */
  29162. _trianglePlanes: Plane[];
  29163. /** @hidden */
  29164. _lastColliderTransformMatrix: Matrix;
  29165. /** @hidden */
  29166. _renderId: number;
  29167. /** @hidden */
  29168. _alphaIndex: number;
  29169. /** @hidden */
  29170. _distanceToCamera: number;
  29171. /** @hidden */
  29172. _id: number;
  29173. private _currentMaterial;
  29174. /**
  29175. * Add a new submesh to a mesh
  29176. * @param materialIndex defines the material index to use
  29177. * @param verticesStart defines vertex index start
  29178. * @param verticesCount defines vertices count
  29179. * @param indexStart defines index start
  29180. * @param indexCount defines indices count
  29181. * @param mesh defines the parent mesh
  29182. * @param renderingMesh defines an optional rendering mesh
  29183. * @param createBoundingBox defines if bounding box should be created for this submesh
  29184. * @returns the new submesh
  29185. */
  29186. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29187. /**
  29188. * Creates a new submesh
  29189. * @param materialIndex defines the material index to use
  29190. * @param verticesStart defines vertex index start
  29191. * @param verticesCount defines vertices count
  29192. * @param indexStart defines index start
  29193. * @param indexCount defines indices count
  29194. * @param mesh defines the parent mesh
  29195. * @param renderingMesh defines an optional rendering mesh
  29196. * @param createBoundingBox defines if bounding box should be created for this submesh
  29197. */
  29198. constructor(
  29199. /** the material index to use */
  29200. materialIndex: number,
  29201. /** vertex index start */
  29202. verticesStart: number,
  29203. /** vertices count */
  29204. verticesCount: number,
  29205. /** index start */
  29206. indexStart: number,
  29207. /** indices count */
  29208. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  29209. /**
  29210. * Returns true if this submesh covers the entire parent mesh
  29211. * @ignorenaming
  29212. */
  29213. readonly IsGlobal: boolean;
  29214. /**
  29215. * Returns the submesh BoudingInfo object
  29216. * @returns current bounding info (or mesh's one if the submesh is global)
  29217. */
  29218. getBoundingInfo(): BoundingInfo;
  29219. /**
  29220. * Sets the submesh BoundingInfo
  29221. * @param boundingInfo defines the new bounding info to use
  29222. * @returns the SubMesh
  29223. */
  29224. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29225. /**
  29226. * Returns the mesh of the current submesh
  29227. * @return the parent mesh
  29228. */
  29229. getMesh(): AbstractMesh;
  29230. /**
  29231. * Returns the rendering mesh of the submesh
  29232. * @returns the rendering mesh (could be different from parent mesh)
  29233. */
  29234. getRenderingMesh(): Mesh;
  29235. /**
  29236. * Returns the submesh material
  29237. * @returns null or the current material
  29238. */
  29239. getMaterial(): Nullable<Material>;
  29240. /**
  29241. * Sets a new updated BoundingInfo object to the submesh
  29242. * @returns the SubMesh
  29243. */
  29244. refreshBoundingInfo(): SubMesh;
  29245. /** @hidden */
  29246. _checkCollision(collider: Collider): boolean;
  29247. /**
  29248. * Updates the submesh BoundingInfo
  29249. * @param world defines the world matrix to use to update the bounding info
  29250. * @returns the submesh
  29251. */
  29252. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  29253. /**
  29254. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29255. * @param frustumPlanes defines the frustum planes
  29256. * @returns true if the submesh is intersecting with the frustum
  29257. */
  29258. isInFrustum(frustumPlanes: Plane[]): boolean;
  29259. /**
  29260. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29261. * @param frustumPlanes defines the frustum planes
  29262. * @returns true if the submesh is inside the frustum
  29263. */
  29264. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29265. /**
  29266. * Renders the submesh
  29267. * @param enableAlphaMode defines if alpha needs to be used
  29268. * @returns the submesh
  29269. */
  29270. render(enableAlphaMode: boolean): SubMesh;
  29271. /**
  29272. * @hidden
  29273. */
  29274. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  29275. /**
  29276. * Checks if the submesh intersects with a ray
  29277. * @param ray defines the ray to test
  29278. * @returns true is the passed ray intersects the submesh bounding box
  29279. */
  29280. canIntersects(ray: Ray): boolean;
  29281. /**
  29282. * Intersects current submesh with a ray
  29283. * @param ray defines the ray to test
  29284. * @param positions defines mesh's positions array
  29285. * @param indices defines mesh's indices array
  29286. * @param fastCheck defines if only bounding info should be used
  29287. * @returns intersection info or null if no intersection
  29288. */
  29289. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  29290. /** @hidden */
  29291. private _intersectLines;
  29292. /** @hidden */
  29293. private _intersectTriangles;
  29294. /** @hidden */
  29295. _rebuild(): void;
  29296. /**
  29297. * Creates a new submesh from the passed mesh
  29298. * @param newMesh defines the new hosting mesh
  29299. * @param newRenderingMesh defines an optional rendering mesh
  29300. * @returns the new submesh
  29301. */
  29302. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29303. /**
  29304. * Release associated resources
  29305. */
  29306. dispose(): void;
  29307. /**
  29308. * Creates a new submesh from indices data
  29309. * @param materialIndex the index of the main mesh material
  29310. * @param startIndex the index where to start the copy in the mesh indices array
  29311. * @param indexCount the number of indices to copy then from the startIndex
  29312. * @param mesh the main mesh to create the submesh from
  29313. * @param renderingMesh the optional rendering mesh
  29314. * @returns a new submesh
  29315. */
  29316. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29317. }
  29318. }
  29319. declare module BABYLON {
  29320. /**
  29321. * 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.
  29322. * @see https://doc.babylonjs.com/how_to/transformnode
  29323. */
  29324. class TransformNode extends Node {
  29325. /**
  29326. * Object will not rotate to face the camera
  29327. */
  29328. static BILLBOARDMODE_NONE: number;
  29329. /**
  29330. * Object will rotate to face the camera but only on the x axis
  29331. */
  29332. static BILLBOARDMODE_X: number;
  29333. /**
  29334. * Object will rotate to face the camera but only on the y axis
  29335. */
  29336. static BILLBOARDMODE_Y: number;
  29337. /**
  29338. * Object will rotate to face the camera but only on the z axis
  29339. */
  29340. static BILLBOARDMODE_Z: number;
  29341. /**
  29342. * Object will rotate to face the camera
  29343. */
  29344. static BILLBOARDMODE_ALL: number;
  29345. private _forward;
  29346. private _forwardInverted;
  29347. private _up;
  29348. private _right;
  29349. private _rightInverted;
  29350. private _position;
  29351. private _rotation;
  29352. private _rotationQuaternion;
  29353. protected _scaling: Vector3;
  29354. protected _isDirty: boolean;
  29355. private _transformToBoneReferal;
  29356. /**
  29357. * Set the billboard mode. Default is 0.
  29358. *
  29359. * | Value | Type | Description |
  29360. * | --- | --- | --- |
  29361. * | 0 | BILLBOARDMODE_NONE | |
  29362. * | 1 | BILLBOARDMODE_X | |
  29363. * | 2 | BILLBOARDMODE_Y | |
  29364. * | 4 | BILLBOARDMODE_Z | |
  29365. * | 7 | BILLBOARDMODE_ALL | |
  29366. *
  29367. */
  29368. billboardMode: number;
  29369. /**
  29370. * 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
  29371. */
  29372. scalingDeterminant: number;
  29373. /**
  29374. * Sets the distance of the object to max, often used by skybox
  29375. */
  29376. infiniteDistance: boolean;
  29377. /**
  29378. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29379. * By default the system will update normals to compensate
  29380. */
  29381. ignoreNonUniformScaling: boolean;
  29382. /** @hidden */
  29383. _poseMatrix: Matrix;
  29384. /** @hidden */
  29385. _localMatrix: Matrix;
  29386. private _absolutePosition;
  29387. private _pivotMatrix;
  29388. private _pivotMatrixInverse;
  29389. protected _postMultiplyPivotMatrix: boolean;
  29390. protected _isWorldMatrixFrozen: boolean;
  29391. /** @hidden */
  29392. _indexInSceneTransformNodesArray: number;
  29393. /**
  29394. * An event triggered after the world matrix is updated
  29395. */
  29396. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29397. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29398. /**
  29399. * Gets a string identifying the name of the class
  29400. * @returns "TransformNode" string
  29401. */
  29402. getClassName(): string;
  29403. /**
  29404. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29405. */
  29406. position: Vector3;
  29407. /**
  29408. * 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)).
  29409. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29410. */
  29411. rotation: Vector3;
  29412. /**
  29413. * 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)).
  29414. */
  29415. scaling: Vector3;
  29416. /**
  29417. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  29418. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29419. */
  29420. rotationQuaternion: Nullable<Quaternion>;
  29421. /**
  29422. * The forward direction of that transform in world space.
  29423. */
  29424. readonly forward: Vector3;
  29425. /**
  29426. * The up direction of that transform in world space.
  29427. */
  29428. readonly up: Vector3;
  29429. /**
  29430. * The right direction of that transform in world space.
  29431. */
  29432. readonly right: Vector3;
  29433. /**
  29434. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29435. * @param matrix the matrix to copy the pose from
  29436. * @returns this TransformNode.
  29437. */
  29438. updatePoseMatrix(matrix: Matrix): TransformNode;
  29439. /**
  29440. * Returns the mesh Pose matrix.
  29441. * @returns the pose matrix
  29442. */
  29443. getPoseMatrix(): Matrix;
  29444. /** @hidden */
  29445. _isSynchronized(): boolean;
  29446. /** @hidden */
  29447. _initCache(): void;
  29448. /**
  29449. * Flag the transform node as dirty (Forcing it to update everything)
  29450. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29451. * @returns this transform node
  29452. */
  29453. markAsDirty(property: string): TransformNode;
  29454. /**
  29455. * Returns the current mesh absolute position.
  29456. * Returns a Vector3.
  29457. */
  29458. readonly absolutePosition: Vector3;
  29459. /**
  29460. * Sets a new matrix to apply before all other transformation
  29461. * @param matrix defines the transform matrix
  29462. * @returns the current TransformNode
  29463. */
  29464. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29465. /**
  29466. * Sets a new pivot matrix to the current node
  29467. * @param matrix defines the new pivot matrix to use
  29468. * @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
  29469. * @returns the current TransformNode
  29470. */
  29471. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  29472. /**
  29473. * Returns the mesh pivot matrix.
  29474. * Default : Identity.
  29475. * @returns the matrix
  29476. */
  29477. getPivotMatrix(): Matrix;
  29478. /**
  29479. * Prevents the World matrix to be computed any longer.
  29480. * @returns the TransformNode.
  29481. */
  29482. freezeWorldMatrix(): TransformNode;
  29483. /**
  29484. * Allows back the World matrix computation.
  29485. * @returns the TransformNode.
  29486. */
  29487. unfreezeWorldMatrix(): this;
  29488. /**
  29489. * True if the World matrix has been frozen.
  29490. */
  29491. readonly isWorldMatrixFrozen: boolean;
  29492. /**
  29493. * Retuns the mesh absolute position in the World.
  29494. * @returns a Vector3.
  29495. */
  29496. getAbsolutePosition(): Vector3;
  29497. /**
  29498. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29499. * @param absolutePosition the absolute position to set
  29500. * @returns the TransformNode.
  29501. */
  29502. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29503. /**
  29504. * Sets the mesh position in its local space.
  29505. * @param vector3 the position to set in localspace
  29506. * @returns the TransformNode.
  29507. */
  29508. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29509. /**
  29510. * Returns the mesh position in the local space from the current World matrix values.
  29511. * @returns a new Vector3.
  29512. */
  29513. getPositionExpressedInLocalSpace(): Vector3;
  29514. /**
  29515. * Translates the mesh along the passed Vector3 in its local space.
  29516. * @param vector3 the distance to translate in localspace
  29517. * @returns the TransformNode.
  29518. */
  29519. locallyTranslate(vector3: Vector3): TransformNode;
  29520. private static _lookAtVectorCache;
  29521. /**
  29522. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29523. * @param targetPoint the position (must be in same space as current mesh) to look at
  29524. * @param yawCor optional yaw (y-axis) correction in radians
  29525. * @param pitchCor optional pitch (x-axis) correction in radians
  29526. * @param rollCor optional roll (z-axis) correction in radians
  29527. * @param space the choosen space of the target
  29528. * @returns the TransformNode.
  29529. */
  29530. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29531. /**
  29532. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29533. * This Vector3 is expressed in the World space.
  29534. * @param localAxis axis to rotate
  29535. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29536. */
  29537. getDirection(localAxis: Vector3): Vector3;
  29538. /**
  29539. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29540. * localAxis is expressed in the mesh local space.
  29541. * result is computed in the Wordl space from the mesh World matrix.
  29542. * @param localAxis axis to rotate
  29543. * @param result the resulting transformnode
  29544. * @returns this TransformNode.
  29545. */
  29546. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29547. /**
  29548. * Sets a new pivot point to the current node
  29549. * @param point defines the new pivot point to use
  29550. * @param space defines if the point is in world or local space (local by default)
  29551. * @returns the current TransformNode
  29552. */
  29553. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29554. /**
  29555. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29556. * @returns the pivot point
  29557. */
  29558. getPivotPoint(): Vector3;
  29559. /**
  29560. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29561. * @param result the vector3 to store the result
  29562. * @returns this TransformNode.
  29563. */
  29564. getPivotPointToRef(result: Vector3): TransformNode;
  29565. /**
  29566. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29567. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29568. */
  29569. getAbsolutePivotPoint(): Vector3;
  29570. /**
  29571. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29572. * @param result vector3 to store the result
  29573. * @returns this TransformNode.
  29574. */
  29575. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29576. /**
  29577. * Defines the passed node as the parent of the current node.
  29578. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29579. * @param node the node ot set as the parent
  29580. * @returns this TransformNode.
  29581. */
  29582. setParent(node: Nullable<Node>): TransformNode;
  29583. private _nonUniformScaling;
  29584. /**
  29585. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29586. */
  29587. readonly nonUniformScaling: boolean;
  29588. /** @hidden */
  29589. _updateNonUniformScalingState(value: boolean): boolean;
  29590. /**
  29591. * Attach the current TransformNode to another TransformNode associated with a bone
  29592. * @param bone Bone affecting the TransformNode
  29593. * @param affectedTransformNode TransformNode associated with the bone
  29594. * @returns this object
  29595. */
  29596. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29597. /**
  29598. * Detach the transform node if its associated with a bone
  29599. * @returns this object
  29600. */
  29601. detachFromBone(): TransformNode;
  29602. private static _rotationAxisCache;
  29603. /**
  29604. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29605. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29606. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29607. * The passed axis is also normalized.
  29608. * @param axis the axis to rotate around
  29609. * @param amount the amount to rotate in radians
  29610. * @param space Space to rotate in (Default: local)
  29611. * @returns the TransformNode.
  29612. */
  29613. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29614. /**
  29615. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29616. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29617. * The passed axis is also normalized. .
  29618. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29619. * @param point the point to rotate around
  29620. * @param axis the axis to rotate around
  29621. * @param amount the amount to rotate in radians
  29622. * @returns the TransformNode
  29623. */
  29624. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29625. /**
  29626. * Translates the mesh along the axis vector for the passed distance in the given space.
  29627. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29628. * @param axis the axis to translate in
  29629. * @param distance the distance to translate
  29630. * @param space Space to rotate in (Default: local)
  29631. * @returns the TransformNode.
  29632. */
  29633. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29634. /**
  29635. * Adds a rotation step to the mesh current rotation.
  29636. * x, y, z are Euler angles expressed in radians.
  29637. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29638. * This means this rotation is made in the mesh local space only.
  29639. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29640. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29641. * ```javascript
  29642. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29643. * ```
  29644. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29645. * 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.
  29646. * @param x Rotation to add
  29647. * @param y Rotation to add
  29648. * @param z Rotation to add
  29649. * @returns the TransformNode.
  29650. */
  29651. addRotation(x: number, y: number, z: number): TransformNode;
  29652. /**
  29653. * Computes the world matrix of the node
  29654. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29655. * @returns the world matrix
  29656. */
  29657. computeWorldMatrix(force?: boolean): Matrix;
  29658. protected _afterComputeWorldMatrix(): void;
  29659. /**
  29660. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29661. * @param func callback function to add
  29662. *
  29663. * @returns the TransformNode.
  29664. */
  29665. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29666. /**
  29667. * Removes a registered callback function.
  29668. * @param func callback function to remove
  29669. * @returns the TransformNode.
  29670. */
  29671. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29672. /**
  29673. * Gets the position of the current mesh in camera space
  29674. * @param camera defines the camera to use
  29675. * @returns a position
  29676. */
  29677. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  29678. /**
  29679. * Returns the distance from the mesh to the active camera
  29680. * @param camera defines the camera to use
  29681. * @returns the distance
  29682. */
  29683. getDistanceToCamera(camera?: Nullable<Camera>): number;
  29684. /**
  29685. * Clone the current transform node
  29686. * @param name Name of the new clone
  29687. * @param newParent New parent for the clone
  29688. * @param doNotCloneChildren Do not clone children hierarchy
  29689. * @returns the new transform node
  29690. */
  29691. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  29692. /**
  29693. * Serializes the objects information.
  29694. * @param currentSerializationObject defines the object to serialize in
  29695. * @returns the serialized object
  29696. */
  29697. serialize(currentSerializationObject?: any): any;
  29698. /**
  29699. * Returns a new TransformNode object parsed from the source provided.
  29700. * @param parsedTransformNode is the source.
  29701. * @param scene the scne the object belongs to
  29702. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  29703. * @returns a new TransformNode object parsed from the source provided.
  29704. */
  29705. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  29706. /**
  29707. * Releases resources associated with this transform node.
  29708. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29709. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29710. */
  29711. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29712. }
  29713. }
  29714. declare module BABYLON {
  29715. /**
  29716. * Specialized buffer used to store vertex data
  29717. */
  29718. class VertexBuffer {
  29719. /** @hidden */
  29720. _buffer: Buffer;
  29721. private _kind;
  29722. private _size;
  29723. private _ownsBuffer;
  29724. private _instanced;
  29725. private _instanceDivisor;
  29726. /**
  29727. * The byte type.
  29728. */
  29729. static readonly BYTE: number;
  29730. /**
  29731. * The unsigned byte type.
  29732. */
  29733. static readonly UNSIGNED_BYTE: number;
  29734. /**
  29735. * The short type.
  29736. */
  29737. static readonly SHORT: number;
  29738. /**
  29739. * The unsigned short type.
  29740. */
  29741. static readonly UNSIGNED_SHORT: number;
  29742. /**
  29743. * The integer type.
  29744. */
  29745. static readonly INT: number;
  29746. /**
  29747. * The unsigned integer type.
  29748. */
  29749. static readonly UNSIGNED_INT: number;
  29750. /**
  29751. * The float type.
  29752. */
  29753. static readonly FLOAT: number;
  29754. /**
  29755. * Gets or sets the instance divisor when in instanced mode
  29756. */
  29757. instanceDivisor: number;
  29758. /**
  29759. * Gets the byte stride.
  29760. */
  29761. readonly byteStride: number;
  29762. /**
  29763. * Gets the byte offset.
  29764. */
  29765. readonly byteOffset: number;
  29766. /**
  29767. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  29768. */
  29769. readonly normalized: boolean;
  29770. /**
  29771. * Gets the data type of each component in the array.
  29772. */
  29773. readonly type: number;
  29774. /**
  29775. * Constructor
  29776. * @param engine the engine
  29777. * @param data the data to use for this vertex buffer
  29778. * @param kind the vertex buffer kind
  29779. * @param updatable whether the data is updatable
  29780. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  29781. * @param stride the stride (optional)
  29782. * @param instanced whether the buffer is instanced (optional)
  29783. * @param offset the offset of the data (optional)
  29784. * @param size the number of components (optional)
  29785. * @param type the type of the component (optional)
  29786. * @param normalized whether the data contains normalized data (optional)
  29787. * @param useBytes set to true if stride and offset are in bytes (optional)
  29788. */
  29789. 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);
  29790. /** @hidden */
  29791. _rebuild(): void;
  29792. /**
  29793. * Returns the kind of the VertexBuffer (string)
  29794. * @returns a string
  29795. */
  29796. getKind(): string;
  29797. /**
  29798. * Gets a boolean indicating if the VertexBuffer is updatable?
  29799. * @returns true if the buffer is updatable
  29800. */
  29801. isUpdatable(): boolean;
  29802. /**
  29803. * Gets current buffer's data
  29804. * @returns a DataArray or null
  29805. */
  29806. getData(): Nullable<DataArray>;
  29807. /**
  29808. * Gets underlying native buffer
  29809. * @returns underlying native buffer
  29810. */
  29811. getBuffer(): Nullable<WebGLBuffer>;
  29812. /**
  29813. * Gets the stride in float32 units (i.e. byte stride / 4).
  29814. * May not be an integer if the byte stride is not divisible by 4.
  29815. * DEPRECATED. Use byteStride instead.
  29816. * @returns the stride in float32 units
  29817. */
  29818. getStrideSize(): number;
  29819. /**
  29820. * Returns the offset as a multiple of the type byte length.
  29821. * DEPRECATED. Use byteOffset instead.
  29822. * @returns the offset in bytes
  29823. */
  29824. getOffset(): number;
  29825. /**
  29826. * Returns the number of components per vertex attribute (integer)
  29827. * @returns the size in float
  29828. */
  29829. getSize(): number;
  29830. /**
  29831. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  29832. * @returns true if this buffer is instanced
  29833. */
  29834. getIsInstanced(): boolean;
  29835. /**
  29836. * Returns the instancing divisor, zero for non-instanced (integer).
  29837. * @returns a number
  29838. */
  29839. getInstanceDivisor(): number;
  29840. /**
  29841. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29842. * @param data defines the data to store
  29843. */
  29844. create(data?: DataArray): void;
  29845. /**
  29846. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29847. * This function will create a new buffer if the current one is not updatable
  29848. * @param data defines the data to store
  29849. */
  29850. update(data: DataArray): void;
  29851. /**
  29852. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29853. * Returns the directly updated WebGLBuffer.
  29854. * @param data the new data
  29855. * @param offset the new offset
  29856. * @param useBytes set to true if the offset is in bytes
  29857. */
  29858. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29859. /**
  29860. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29861. */
  29862. dispose(): void;
  29863. /**
  29864. * Enumerates each value of this vertex buffer as numbers.
  29865. * @param count the number of values to enumerate
  29866. * @param callback the callback function called for each value
  29867. */
  29868. forEach(count: number, callback: (value: number, index: number) => void): void;
  29869. /**
  29870. * Positions
  29871. */
  29872. static readonly PositionKind: string;
  29873. /**
  29874. * Normals
  29875. */
  29876. static readonly NormalKind: string;
  29877. /**
  29878. * Tangents
  29879. */
  29880. static readonly TangentKind: string;
  29881. /**
  29882. * Texture coordinates
  29883. */
  29884. static readonly UVKind: string;
  29885. /**
  29886. * Texture coordinates 2
  29887. */
  29888. static readonly UV2Kind: string;
  29889. /**
  29890. * Texture coordinates 3
  29891. */
  29892. static readonly UV3Kind: string;
  29893. /**
  29894. * Texture coordinates 4
  29895. */
  29896. static readonly UV4Kind: string;
  29897. /**
  29898. * Texture coordinates 5
  29899. */
  29900. static readonly UV5Kind: string;
  29901. /**
  29902. * Texture coordinates 6
  29903. */
  29904. static readonly UV6Kind: string;
  29905. /**
  29906. * Colors
  29907. */
  29908. static readonly ColorKind: string;
  29909. /**
  29910. * Matrix indices (for bones)
  29911. */
  29912. static readonly MatricesIndicesKind: string;
  29913. /**
  29914. * Matrix weights (for bones)
  29915. */
  29916. static readonly MatricesWeightsKind: string;
  29917. /**
  29918. * Additional matrix indices (for bones)
  29919. */
  29920. static readonly MatricesIndicesExtraKind: string;
  29921. /**
  29922. * Additional matrix weights (for bones)
  29923. */
  29924. static readonly MatricesWeightsExtraKind: string;
  29925. /**
  29926. * Deduces the stride given a kind.
  29927. * @param kind The kind string to deduce
  29928. * @returns The deduced stride
  29929. */
  29930. static DeduceStride(kind: string): number;
  29931. /**
  29932. * Gets the byte length of the given type.
  29933. * @param type the type
  29934. * @returns the number of bytes
  29935. */
  29936. static GetTypeByteLength(type: number): number;
  29937. /**
  29938. * Enumerates each value of the given parameters as numbers.
  29939. * @param data the data to enumerate
  29940. * @param byteOffset the byte offset of the data
  29941. * @param byteStride the byte stride of the data
  29942. * @param componentCount the number of components per element
  29943. * @param componentType the type of the component
  29944. * @param count the total number of components
  29945. * @param normalized whether the data is normalized
  29946. * @param callback the callback function called for each value
  29947. */
  29948. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  29949. private static _GetFloatValue;
  29950. }
  29951. }
  29952. declare module BABYLON {
  29953. /**
  29954. * Defines a target to use with MorphTargetManager
  29955. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29956. */
  29957. class MorphTarget implements IAnimatable {
  29958. /** defines the name of the target */
  29959. name: string;
  29960. /**
  29961. * Gets or sets the list of animations
  29962. */
  29963. animations: Animation[];
  29964. private _scene;
  29965. private _positions;
  29966. private _normals;
  29967. private _tangents;
  29968. private _influence;
  29969. /**
  29970. * Observable raised when the influence changes
  29971. */
  29972. onInfluenceChanged: Observable<boolean>;
  29973. /** @hidden */
  29974. _onDataLayoutChanged: Observable<void>;
  29975. /**
  29976. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  29977. */
  29978. influence: number;
  29979. /**
  29980. * Gets or sets the id of the morph Target
  29981. */
  29982. id: string;
  29983. private _animationPropertiesOverride;
  29984. /**
  29985. * Gets or sets the animation properties override
  29986. */
  29987. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  29988. /**
  29989. * Creates a new MorphTarget
  29990. * @param name defines the name of the target
  29991. * @param influence defines the influence to use
  29992. */
  29993. constructor(
  29994. /** defines the name of the target */
  29995. name: string, influence?: number, scene?: Nullable<Scene>);
  29996. /**
  29997. * Gets a boolean defining if the target contains position data
  29998. */
  29999. readonly hasPositions: boolean;
  30000. /**
  30001. * Gets a boolean defining if the target contains normal data
  30002. */
  30003. readonly hasNormals: boolean;
  30004. /**
  30005. * Gets a boolean defining if the target contains tangent data
  30006. */
  30007. readonly hasTangents: boolean;
  30008. /**
  30009. * Affects position data to this target
  30010. * @param data defines the position data to use
  30011. */
  30012. setPositions(data: Nullable<FloatArray>): void;
  30013. /**
  30014. * Gets the position data stored in this target
  30015. * @returns a FloatArray containing the position data (or null if not present)
  30016. */
  30017. getPositions(): Nullable<FloatArray>;
  30018. /**
  30019. * Affects normal data to this target
  30020. * @param data defines the normal data to use
  30021. */
  30022. setNormals(data: Nullable<FloatArray>): void;
  30023. /**
  30024. * Gets the normal data stored in this target
  30025. * @returns a FloatArray containing the normal data (or null if not present)
  30026. */
  30027. getNormals(): Nullable<FloatArray>;
  30028. /**
  30029. * Affects tangent data to this target
  30030. * @param data defines the tangent data to use
  30031. */
  30032. setTangents(data: Nullable<FloatArray>): void;
  30033. /**
  30034. * Gets the tangent data stored in this target
  30035. * @returns a FloatArray containing the tangent data (or null if not present)
  30036. */
  30037. getTangents(): Nullable<FloatArray>;
  30038. /**
  30039. * Serializes the current target into a Serialization object
  30040. * @returns the serialized object
  30041. */
  30042. serialize(): any;
  30043. /**
  30044. * Returns the string "MorphTarget"
  30045. * @returns "MorphTarget"
  30046. */
  30047. getClassName(): string;
  30048. /**
  30049. * Creates a new target from serialized data
  30050. * @param serializationObject defines the serialized data to use
  30051. * @returns a new MorphTarget
  30052. */
  30053. static Parse(serializationObject: any): MorphTarget;
  30054. /**
  30055. * Creates a MorphTarget from mesh data
  30056. * @param mesh defines the source mesh
  30057. * @param name defines the name to use for the new target
  30058. * @param influence defines the influence to attach to the target
  30059. * @returns a new MorphTarget
  30060. */
  30061. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30062. }
  30063. }
  30064. declare module BABYLON {
  30065. /**
  30066. * This class is used to deform meshes using morphing between different targets
  30067. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30068. */
  30069. class MorphTargetManager {
  30070. private _targets;
  30071. private _targetInfluenceChangedObservers;
  30072. private _targetDataLayoutChangedObservers;
  30073. private _activeTargets;
  30074. private _scene;
  30075. private _influences;
  30076. private _supportsNormals;
  30077. private _supportsTangents;
  30078. private _vertexCount;
  30079. private _uniqueId;
  30080. private _tempInfluences;
  30081. /**
  30082. * Creates a new MorphTargetManager
  30083. * @param scene defines the current scene
  30084. */
  30085. constructor(scene?: Nullable<Scene>);
  30086. /**
  30087. * Gets the unique ID of this manager
  30088. */
  30089. readonly uniqueId: number;
  30090. /**
  30091. * Gets the number of vertices handled by this manager
  30092. */
  30093. readonly vertexCount: number;
  30094. /**
  30095. * Gets a boolean indicating if this manager supports morphing of normals
  30096. */
  30097. readonly supportsNormals: boolean;
  30098. /**
  30099. * Gets a boolean indicating if this manager supports morphing of tangents
  30100. */
  30101. readonly supportsTangents: boolean;
  30102. /**
  30103. * Gets the number of targets stored in this manager
  30104. */
  30105. readonly numTargets: number;
  30106. /**
  30107. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30108. */
  30109. readonly numInfluencers: number;
  30110. /**
  30111. * Gets the list of influences (one per target)
  30112. */
  30113. readonly influences: Float32Array;
  30114. /**
  30115. * Gets the active target at specified index. An active target is a target with an influence > 0
  30116. * @param index defines the index to check
  30117. * @returns the requested target
  30118. */
  30119. getActiveTarget(index: number): MorphTarget;
  30120. /**
  30121. * Gets the target at specified index
  30122. * @param index defines the index to check
  30123. * @returns the requested target
  30124. */
  30125. getTarget(index: number): MorphTarget;
  30126. /**
  30127. * Add a new target to this manager
  30128. * @param target defines the target to add
  30129. */
  30130. addTarget(target: MorphTarget): void;
  30131. /**
  30132. * Removes a target from the manager
  30133. * @param target defines the target to remove
  30134. */
  30135. removeTarget(target: MorphTarget): void;
  30136. /**
  30137. * Serializes the current manager into a Serialization object
  30138. * @returns the serialized object
  30139. */
  30140. serialize(): any;
  30141. private _syncActiveTargets;
  30142. /**
  30143. * Syncrhonize the targets with all the meshes using this morph target manager
  30144. */
  30145. synchronize(): void;
  30146. /**
  30147. * Creates a new MorphTargetManager from serialized data
  30148. * @param serializationObject defines the serialized data
  30149. * @param scene defines the hosting scene
  30150. * @returns the new MorphTargetManager
  30151. */
  30152. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  30153. }
  30154. }
  30155. declare module BABYLON {
  30156. /**
  30157. * Class used to enable access to IndexedDB
  30158. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30159. */
  30160. class Database implements IOfflineProvider {
  30161. private _callbackManifestChecked;
  30162. private _currentSceneUrl;
  30163. private _db;
  30164. private _enableSceneOffline;
  30165. private _enableTexturesOffline;
  30166. private _manifestVersionFound;
  30167. private _mustUpdateRessources;
  30168. private _hasReachedQuota;
  30169. private _isSupported;
  30170. private _idbFactory;
  30171. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  30172. private static IsUASupportingBlobStorage;
  30173. /**
  30174. * Gets a boolean indicating if Database storate is enabled (off by default)
  30175. */
  30176. static IDBStorageEnabled: boolean;
  30177. /**
  30178. * Gets a boolean indicating if scene must be saved in the database
  30179. */
  30180. readonly enableSceneOffline: boolean;
  30181. /**
  30182. * Gets a boolean indicating if textures must be saved in the database
  30183. */
  30184. readonly enableTexturesOffline: boolean;
  30185. /**
  30186. * Creates a new Database
  30187. * @param urlToScene defines the url to load the scene
  30188. * @param callbackManifestChecked defines the callback to use when manifest is checked
  30189. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  30190. */
  30191. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  30192. private static _ParseURL;
  30193. private static _ReturnFullUrlLocation;
  30194. private _checkManifestFile;
  30195. /**
  30196. * Open the database and make it available
  30197. * @param successCallback defines the callback to call on success
  30198. * @param errorCallback defines the callback to call on error
  30199. */
  30200. open(successCallback: () => void, errorCallback: () => void): void;
  30201. /**
  30202. * Loads an image from the database
  30203. * @param url defines the url to load from
  30204. * @param image defines the target DOM image
  30205. */
  30206. loadImage(url: string, image: HTMLImageElement): void;
  30207. private _loadImageFromDBAsync;
  30208. private _saveImageIntoDBAsync;
  30209. private _checkVersionFromDB;
  30210. private _loadVersionFromDBAsync;
  30211. private _saveVersionIntoDBAsync;
  30212. /**
  30213. * Loads a file from database
  30214. * @param url defines the URL to load from
  30215. * @param sceneLoaded defines a callback to call on success
  30216. * @param progressCallBack defines a callback to call when progress changed
  30217. * @param errorCallback defines a callback to call on error
  30218. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30219. */
  30220. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30221. private _loadFileAsync;
  30222. private _saveFileAsync;
  30223. }
  30224. }
  30225. declare module BABYLON {
  30226. /**
  30227. * Class used to enable access to offline support
  30228. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30229. */
  30230. interface IOfflineProvider {
  30231. /**
  30232. * Gets a boolean indicating if scene must be saved in the database
  30233. */
  30234. enableSceneOffline: boolean;
  30235. /**
  30236. * Gets a boolean indicating if textures must be saved in the database
  30237. */
  30238. enableTexturesOffline: boolean;
  30239. /**
  30240. * Open the offline support and make it available
  30241. * @param successCallback defines the callback to call on success
  30242. * @param errorCallback defines the callback to call on error
  30243. */
  30244. open(successCallback: () => void, errorCallback: () => void): void;
  30245. /**
  30246. * Loads an image from the offline support
  30247. * @param url defines the url to load from
  30248. * @param image defines the target DOM image
  30249. */
  30250. loadImage(url: string, image: HTMLImageElement): void;
  30251. /**
  30252. * Loads a file from offline support
  30253. * @param url defines the URL to load from
  30254. * @param sceneLoaded defines a callback to call on success
  30255. * @param progressCallBack defines a callback to call when progress changed
  30256. * @param errorCallback defines a callback to call on error
  30257. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30258. */
  30259. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30260. }
  30261. }
  30262. declare module BABYLON {
  30263. /**
  30264. * This represents the base class for particle system in Babylon.
  30265. * 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.
  30266. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  30267. * @example https://doc.babylonjs.com/babylon101/particles
  30268. */
  30269. class BaseParticleSystem {
  30270. /**
  30271. * Source color is added to the destination color without alpha affecting the result
  30272. */
  30273. static BLENDMODE_ONEONE: number;
  30274. /**
  30275. * Blend current color and particle color using particle’s alpha
  30276. */
  30277. static BLENDMODE_STANDARD: number;
  30278. /**
  30279. * Add current color and particle color multiplied by particle’s alpha
  30280. */
  30281. static BLENDMODE_ADD: number;
  30282. /**
  30283. * Multiply current color with particle color
  30284. */
  30285. static BLENDMODE_MULTIPLY: number;
  30286. /**
  30287. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  30288. */
  30289. static BLENDMODE_MULTIPLYADD: number;
  30290. /**
  30291. * List of animations used by the particle system.
  30292. */
  30293. animations: Animation[];
  30294. /**
  30295. * The id of the Particle system.
  30296. */
  30297. id: string;
  30298. /**
  30299. * The friendly name of the Particle system.
  30300. */
  30301. name: string;
  30302. /**
  30303. * The rendering group used by the Particle system to chose when to render.
  30304. */
  30305. renderingGroupId: number;
  30306. /**
  30307. * The emitter represents the Mesh or position we are attaching the particle system to.
  30308. */
  30309. emitter: Nullable<AbstractMesh | Vector3>;
  30310. /**
  30311. * The maximum number of particles to emit per frame
  30312. */
  30313. emitRate: number;
  30314. /**
  30315. * If you want to launch only a few particles at once, that can be done, as well.
  30316. */
  30317. manualEmitCount: number;
  30318. /**
  30319. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30320. */
  30321. updateSpeed: number;
  30322. /**
  30323. * The amount of time the particle system is running (depends of the overall update speed).
  30324. */
  30325. targetStopDuration: number;
  30326. /**
  30327. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  30328. */
  30329. disposeOnStop: boolean;
  30330. /**
  30331. * Minimum power of emitting particles.
  30332. */
  30333. minEmitPower: number;
  30334. /**
  30335. * Maximum power of emitting particles.
  30336. */
  30337. maxEmitPower: number;
  30338. /**
  30339. * Minimum life time of emitting particles.
  30340. */
  30341. minLifeTime: number;
  30342. /**
  30343. * Maximum life time of emitting particles.
  30344. */
  30345. maxLifeTime: number;
  30346. /**
  30347. * Minimum Size of emitting particles.
  30348. */
  30349. minSize: number;
  30350. /**
  30351. * Maximum Size of emitting particles.
  30352. */
  30353. maxSize: number;
  30354. /**
  30355. * Minimum scale of emitting particles on X axis.
  30356. */
  30357. minScaleX: number;
  30358. /**
  30359. * Maximum scale of emitting particles on X axis.
  30360. */
  30361. maxScaleX: number;
  30362. /**
  30363. * Minimum scale of emitting particles on Y axis.
  30364. */
  30365. minScaleY: number;
  30366. /**
  30367. * Maximum scale of emitting particles on Y axis.
  30368. */
  30369. maxScaleY: number;
  30370. /**
  30371. * Gets or sets the minimal initial rotation in radians.
  30372. */
  30373. minInitialRotation: number;
  30374. /**
  30375. * Gets or sets the maximal initial rotation in radians.
  30376. */
  30377. maxInitialRotation: number;
  30378. /**
  30379. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  30380. */
  30381. minAngularSpeed: number;
  30382. /**
  30383. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  30384. */
  30385. maxAngularSpeed: number;
  30386. /**
  30387. * The texture used to render each particle. (this can be a spritesheet)
  30388. */
  30389. particleTexture: Nullable<Texture>;
  30390. /**
  30391. * The layer mask we are rendering the particles through.
  30392. */
  30393. layerMask: number;
  30394. /**
  30395. * This can help using your own shader to render the particle system.
  30396. * The according effect will be created
  30397. */
  30398. customShader: any;
  30399. /**
  30400. * By default particle system starts as soon as they are created. This prevents the
  30401. * automatic start to happen and let you decide when to start emitting particles.
  30402. */
  30403. preventAutoStart: boolean;
  30404. private _noiseTexture;
  30405. /**
  30406. * Gets or sets a texture used to add random noise to particle positions
  30407. */
  30408. noiseTexture: Nullable<ProceduralTexture>;
  30409. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  30410. noiseStrength: Vector3;
  30411. /**
  30412. * Callback triggered when the particle animation is ending.
  30413. */
  30414. onAnimationEnd: Nullable<() => void>;
  30415. /**
  30416. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  30417. */
  30418. blendMode: number;
  30419. /**
  30420. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30421. * to override the particles.
  30422. */
  30423. forceDepthWrite: boolean;
  30424. /** 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 */
  30425. preWarmCycles: number;
  30426. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  30427. preWarmStepOffset: number;
  30428. /**
  30429. * 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)
  30430. */
  30431. spriteCellChangeSpeed: number;
  30432. /**
  30433. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  30434. */
  30435. startSpriteCellID: number;
  30436. /**
  30437. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  30438. */
  30439. endSpriteCellID: number;
  30440. /**
  30441. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  30442. */
  30443. spriteCellWidth: number;
  30444. /**
  30445. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  30446. */
  30447. spriteCellHeight: number;
  30448. /**
  30449. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  30450. */
  30451. spriteRandomStartCell: boolean;
  30452. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  30453. translationPivot: Vector2;
  30454. /** @hidden */
  30455. protected _isAnimationSheetEnabled: boolean;
  30456. /**
  30457. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  30458. */
  30459. beginAnimationOnStart: boolean;
  30460. /**
  30461. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  30462. */
  30463. beginAnimationFrom: number;
  30464. /**
  30465. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  30466. */
  30467. beginAnimationTo: number;
  30468. /**
  30469. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  30470. */
  30471. beginAnimationLoop: boolean;
  30472. /**
  30473. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  30474. */
  30475. isAnimationSheetEnabled: boolean;
  30476. /**
  30477. * Get hosting scene
  30478. * @returns the scene
  30479. */
  30480. getScene(): Scene;
  30481. /**
  30482. * You can use gravity if you want to give an orientation to your particles.
  30483. */
  30484. gravity: Vector3;
  30485. protected _colorGradients: Nullable<Array<ColorGradient>>;
  30486. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  30487. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  30488. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  30489. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  30490. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  30491. protected _dragGradients: Nullable<Array<FactorGradient>>;
  30492. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  30493. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  30494. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  30495. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  30496. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  30497. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  30498. /**
  30499. * Defines the delay in milliseconds before starting the system (0 by default)
  30500. */
  30501. startDelay: number;
  30502. /**
  30503. * Gets the current list of drag gradients.
  30504. * You must use addDragGradient and removeDragGradient to udpate this list
  30505. * @returns the list of drag gradients
  30506. */
  30507. getDragGradients(): Nullable<Array<FactorGradient>>;
  30508. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30509. limitVelocityDamping: number;
  30510. /**
  30511. * Gets the current list of limit velocity gradients.
  30512. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30513. * @returns the list of limit velocity gradients
  30514. */
  30515. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30516. /**
  30517. * Gets the current list of color gradients.
  30518. * You must use addColorGradient and removeColorGradient to udpate this list
  30519. * @returns the list of color gradients
  30520. */
  30521. getColorGradients(): Nullable<Array<ColorGradient>>;
  30522. /**
  30523. * Gets the current list of size gradients.
  30524. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30525. * @returns the list of size gradients
  30526. */
  30527. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30528. /**
  30529. * Gets the current list of color remap gradients.
  30530. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  30531. * @returns the list of color remap gradients
  30532. */
  30533. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  30534. /**
  30535. * Gets the current list of alpha remap gradients.
  30536. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  30537. * @returns the list of alpha remap gradients
  30538. */
  30539. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  30540. /**
  30541. * Gets the current list of life time gradients.
  30542. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  30543. * @returns the list of life time gradients
  30544. */
  30545. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  30546. /**
  30547. * Gets the current list of angular speed gradients.
  30548. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30549. * @returns the list of angular speed gradients
  30550. */
  30551. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30552. /**
  30553. * Gets the current list of velocity gradients.
  30554. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30555. * @returns the list of velocity gradients
  30556. */
  30557. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30558. /**
  30559. * Gets the current list of start size gradients.
  30560. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  30561. * @returns the list of start size gradients
  30562. */
  30563. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  30564. /**
  30565. * Gets the current list of emit rate gradients.
  30566. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  30567. * @returns the list of emit rate gradients
  30568. */
  30569. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  30570. /**
  30571. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30572. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30573. */
  30574. direction1: Vector3;
  30575. /**
  30576. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30577. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30578. */
  30579. direction2: Vector3;
  30580. /**
  30581. * 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.
  30582. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30583. */
  30584. minEmitBox: Vector3;
  30585. /**
  30586. * 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.
  30587. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30588. */
  30589. maxEmitBox: Vector3;
  30590. /**
  30591. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30592. */
  30593. color1: Color4;
  30594. /**
  30595. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30596. */
  30597. color2: Color4;
  30598. /**
  30599. * Color the particle will have at the end of its lifetime
  30600. */
  30601. colorDead: Color4;
  30602. /**
  30603. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  30604. */
  30605. textureMask: Color4;
  30606. /**
  30607. * The particle emitter type defines the emitter used by the particle system.
  30608. * It can be for example box, sphere, or cone...
  30609. */
  30610. particleEmitterType: IParticleEmitterType;
  30611. /** @hidden */
  30612. _isSubEmitter: boolean;
  30613. /**
  30614. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30615. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30616. */
  30617. billboardMode: number;
  30618. protected _isBillboardBased: boolean;
  30619. /**
  30620. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30621. */
  30622. isBillboardBased: boolean;
  30623. /**
  30624. * The scene the particle system belongs to.
  30625. */
  30626. protected _scene: Scene;
  30627. /**
  30628. * Local cache of defines for image processing.
  30629. */
  30630. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  30631. /**
  30632. * Default configuration related to image processing available in the standard Material.
  30633. */
  30634. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30635. /**
  30636. * Gets the image processing configuration used either in this material.
  30637. */
  30638. /**
  30639. * Sets the Default image processing configuration used either in the this material.
  30640. *
  30641. * If sets to null, the scene one is in use.
  30642. */
  30643. imageProcessingConfiguration: ImageProcessingConfiguration;
  30644. /**
  30645. * Attaches a new image processing configuration to the Standard Material.
  30646. * @param configuration
  30647. */
  30648. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30649. /** @hidden */
  30650. protected _reset(): void;
  30651. /** @hidden */
  30652. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  30653. /**
  30654. * Instantiates a particle system.
  30655. * 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.
  30656. * @param name The name of the particle system
  30657. */
  30658. constructor(name: string);
  30659. /**
  30660. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  30661. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30662. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30663. * @returns the emitter
  30664. */
  30665. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  30666. /**
  30667. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  30668. * @param radius The radius of the hemisphere to emit from
  30669. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30670. * @returns the emitter
  30671. */
  30672. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  30673. /**
  30674. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30675. * @param radius The radius of the sphere to emit from
  30676. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30677. * @returns the emitter
  30678. */
  30679. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  30680. /**
  30681. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  30682. * @param radius The radius of the sphere to emit from
  30683. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  30684. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  30685. * @returns the emitter
  30686. */
  30687. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  30688. /**
  30689. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  30690. * @param radius The radius of the emission cylinder
  30691. * @param height The height of the emission cylinder
  30692. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  30693. * @param directionRandomizer How much to randomize the particle direction [0-1]
  30694. * @returns the emitter
  30695. */
  30696. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  30697. /**
  30698. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  30699. * @param radius The radius of the cylinder to emit from
  30700. * @param height The height of the emission cylinder
  30701. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  30702. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  30703. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  30704. * @returns the emitter
  30705. */
  30706. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  30707. /**
  30708. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  30709. * @param radius The radius of the cone to emit from
  30710. * @param angle The base angle of the cone
  30711. * @returns the emitter
  30712. */
  30713. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  30714. /**
  30715. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  30716. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30717. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30718. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30719. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30720. * @returns the emitter
  30721. */
  30722. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  30723. }
  30724. }
  30725. declare module BABYLON {
  30726. /**
  30727. * This represents a GPU particle system in Babylon
  30728. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  30729. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  30730. */
  30731. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  30732. /**
  30733. * The layer mask we are rendering the particles through.
  30734. */
  30735. layerMask: number;
  30736. private _capacity;
  30737. private _activeCount;
  30738. private _currentActiveCount;
  30739. private _accumulatedCount;
  30740. private _renderEffect;
  30741. private _updateEffect;
  30742. private _buffer0;
  30743. private _buffer1;
  30744. private _spriteBuffer;
  30745. private _updateVAO;
  30746. private _renderVAO;
  30747. private _targetIndex;
  30748. private _sourceBuffer;
  30749. private _targetBuffer;
  30750. private _engine;
  30751. private _currentRenderId;
  30752. private _started;
  30753. private _stopped;
  30754. private _timeDelta;
  30755. private _randomTexture;
  30756. private _randomTexture2;
  30757. private _attributesStrideSize;
  30758. private _updateEffectOptions;
  30759. private _randomTextureSize;
  30760. private _actualFrame;
  30761. private readonly _rawTextureWidth;
  30762. /**
  30763. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  30764. */
  30765. static readonly IsSupported: boolean;
  30766. /**
  30767. * An event triggered when the system is disposed.
  30768. */
  30769. onDisposeObservable: Observable<GPUParticleSystem>;
  30770. /**
  30771. * Gets the maximum number of particles active at the same time.
  30772. * @returns The max number of active particles.
  30773. */
  30774. getCapacity(): number;
  30775. /**
  30776. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30777. * to override the particles.
  30778. */
  30779. forceDepthWrite: boolean;
  30780. /**
  30781. * Gets or set the number of active particles
  30782. */
  30783. activeParticleCount: number;
  30784. private _preWarmDone;
  30785. /**
  30786. * Is this system ready to be used/rendered
  30787. * @return true if the system is ready
  30788. */
  30789. isReady(): boolean;
  30790. /**
  30791. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30792. * @returns True if it has been started, otherwise false.
  30793. */
  30794. isStarted(): boolean;
  30795. /**
  30796. * Starts the particle system and begins to emit
  30797. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  30798. */
  30799. start(delay?: number): void;
  30800. /**
  30801. * Stops the particle system.
  30802. */
  30803. stop(): void;
  30804. /**
  30805. * Remove all active particles
  30806. */
  30807. reset(): void;
  30808. /**
  30809. * Returns the string "GPUParticleSystem"
  30810. * @returns a string containing the class name
  30811. */
  30812. getClassName(): string;
  30813. private _colorGradientsTexture;
  30814. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  30815. /**
  30816. * Adds a new color gradient
  30817. * @param gradient defines the gradient to use (between 0 and 1)
  30818. * @param color1 defines the color to affect to the specified gradient
  30819. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30820. * @returns the current particle system
  30821. */
  30822. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  30823. /**
  30824. * Remove a specific color gradient
  30825. * @param gradient defines the gradient to remove
  30826. * @returns the current particle system
  30827. */
  30828. removeColorGradient(gradient: number): GPUParticleSystem;
  30829. private _angularSpeedGradientsTexture;
  30830. private _sizeGradientsTexture;
  30831. private _velocityGradientsTexture;
  30832. private _limitVelocityGradientsTexture;
  30833. private _dragGradientsTexture;
  30834. private _addFactorGradient;
  30835. /**
  30836. * Adds a new size gradient
  30837. * @param gradient defines the gradient to use (between 0 and 1)
  30838. * @param factor defines the size factor to affect to the specified gradient
  30839. * @returns the current particle system
  30840. */
  30841. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  30842. /**
  30843. * Remove a specific size gradient
  30844. * @param gradient defines the gradient to remove
  30845. * @returns the current particle system
  30846. */
  30847. removeSizeGradient(gradient: number): GPUParticleSystem;
  30848. /**
  30849. * Adds a new angular speed gradient
  30850. * @param gradient defines the gradient to use (between 0 and 1)
  30851. * @param factor defines the angular speed to affect to the specified gradient
  30852. * @returns the current particle system
  30853. */
  30854. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  30855. /**
  30856. * Remove a specific angular speed gradient
  30857. * @param gradient defines the gradient to remove
  30858. * @returns the current particle system
  30859. */
  30860. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  30861. /**
  30862. * Adds a new velocity gradient
  30863. * @param gradient defines the gradient to use (between 0 and 1)
  30864. * @param factor defines the velocity to affect to the specified gradient
  30865. * @returns the current particle system
  30866. */
  30867. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30868. /**
  30869. * Remove a specific velocity gradient
  30870. * @param gradient defines the gradient to remove
  30871. * @returns the current particle system
  30872. */
  30873. removeVelocityGradient(gradient: number): GPUParticleSystem;
  30874. /**
  30875. * Adds a new limit velocity gradient
  30876. * @param gradient defines the gradient to use (between 0 and 1)
  30877. * @param factor defines the limit velocity value to affect to the specified gradient
  30878. * @returns the current particle system
  30879. */
  30880. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30881. /**
  30882. * Remove a specific limit velocity gradient
  30883. * @param gradient defines the gradient to remove
  30884. * @returns the current particle system
  30885. */
  30886. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  30887. /**
  30888. * Adds a new drag gradient
  30889. * @param gradient defines the gradient to use (between 0 and 1)
  30890. * @param factor defines the drag value to affect to the specified gradient
  30891. * @returns the current particle system
  30892. */
  30893. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  30894. /**
  30895. * Remove a specific drag gradient
  30896. * @param gradient defines the gradient to remove
  30897. * @returns the current particle system
  30898. */
  30899. removeDragGradient(gradient: number): GPUParticleSystem;
  30900. /**
  30901. * Not supported by GPUParticleSystem
  30902. * @param gradient defines the gradient to use (between 0 and 1)
  30903. * @param factor defines the emit rate value to affect to the specified gradient
  30904. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30905. * @returns the current particle system
  30906. */
  30907. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30908. /**
  30909. * Not supported by GPUParticleSystem
  30910. * @param gradient defines the gradient to remove
  30911. * @returns the current particle system
  30912. */
  30913. removeEmitRateGradient(gradient: number): IParticleSystem;
  30914. /**
  30915. * Not supported by GPUParticleSystem
  30916. * @param gradient defines the gradient to use (between 0 and 1)
  30917. * @param factor defines the start size value to affect to the specified gradient
  30918. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30919. * @returns the current particle system
  30920. */
  30921. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30922. /**
  30923. * Not supported by GPUParticleSystem
  30924. * @param gradient defines the gradient to remove
  30925. * @returns the current particle system
  30926. */
  30927. removeStartSizeGradient(gradient: number): IParticleSystem;
  30928. /**
  30929. * Not supported by GPUParticleSystem
  30930. * @param gradient defines the gradient to use (between 0 and 1)
  30931. * @param min defines the color remap minimal range
  30932. * @param max defines the color remap maximal range
  30933. * @returns the current particle system
  30934. */
  30935. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30936. /**
  30937. * Not supported by GPUParticleSystem
  30938. * @param gradient defines the gradient to remove
  30939. * @returns the current particle system
  30940. */
  30941. removeColorRemapGradient(gradient: number): IParticleSystem;
  30942. /**
  30943. * Not supported by GPUParticleSystem
  30944. * @param gradient defines the gradient to use (between 0 and 1)
  30945. * @param min defines the alpha remap minimal range
  30946. * @param max defines the alpha remap maximal range
  30947. * @returns the current particle system
  30948. */
  30949. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30950. /**
  30951. * Not supported by GPUParticleSystem
  30952. * @param gradient defines the gradient to remove
  30953. * @returns the current particle system
  30954. */
  30955. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  30956. /**
  30957. * Not supported by GPUParticleSystem
  30958. * @param gradient defines the gradient to use (between 0 and 1)
  30959. * @param color defines the color to affect to the specified gradient
  30960. * @returns the current particle system
  30961. */
  30962. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  30963. /**
  30964. * Not supported by GPUParticleSystem
  30965. * @param gradient defines the gradient to remove
  30966. * @returns the current particle system
  30967. */
  30968. removeRampGradient(gradient: number): IParticleSystem;
  30969. /**
  30970. * Not supported by GPUParticleSystem
  30971. * @returns the list of ramp gradients
  30972. */
  30973. getRampGradients(): Nullable<Array<Color3Gradient>>;
  30974. /**
  30975. * Not supported by GPUParticleSystem
  30976. * Gets or sets a boolean indicating that ramp gradients must be used
  30977. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  30978. */
  30979. useRampGradients: boolean;
  30980. /**
  30981. * Not supported by GPUParticleSystem
  30982. * @param gradient defines the gradient to use (between 0 and 1)
  30983. * @param factor defines the life time factor to affect to the specified gradient
  30984. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30985. * @returns the current particle system
  30986. */
  30987. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30988. /**
  30989. * Not supported by GPUParticleSystem
  30990. * @param gradient defines the gradient to remove
  30991. * @returns the current particle system
  30992. */
  30993. removeLifeTimeGradient(gradient: number): IParticleSystem;
  30994. /**
  30995. * Instantiates a GPU particle system.
  30996. * 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.
  30997. * @param name The name of the particle system
  30998. * @param options The options used to create the system
  30999. * @param scene The scene the particle system belongs to
  31000. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31001. */
  31002. constructor(name: string, options: Partial<{
  31003. capacity: number;
  31004. randomTextureSize: number;
  31005. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  31006. protected _reset(): void;
  31007. private _createUpdateVAO;
  31008. private _createRenderVAO;
  31009. private _initialize;
  31010. /** @hidden */
  31011. _recreateUpdateEffect(): void;
  31012. /** @hidden */
  31013. _recreateRenderEffect(): void;
  31014. /**
  31015. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  31016. * @param preWarm defines if we are in the pre-warmimg phase
  31017. */
  31018. animate(preWarm?: boolean): void;
  31019. private _createFactorGradientTexture;
  31020. private _createSizeGradientTexture;
  31021. private _createAngularSpeedGradientTexture;
  31022. private _createVelocityGradientTexture;
  31023. private _createLimitVelocityGradientTexture;
  31024. private _createDragGradientTexture;
  31025. private _createColorGradientTexture;
  31026. /**
  31027. * Renders the particle system in its current state
  31028. * @param preWarm defines if the system should only update the particles but not render them
  31029. * @returns the current number of particles
  31030. */
  31031. render(preWarm?: boolean): number;
  31032. /**
  31033. * Rebuilds the particle system
  31034. */
  31035. rebuild(): void;
  31036. private _releaseBuffers;
  31037. private _releaseVAOs;
  31038. /**
  31039. * Disposes the particle system and free the associated resources
  31040. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31041. */
  31042. dispose(disposeTexture?: boolean): void;
  31043. /**
  31044. * Clones the particle system.
  31045. * @param name The name of the cloned object
  31046. * @param newEmitter The new emitter to use
  31047. * @returns the cloned particle system
  31048. */
  31049. clone(name: string, newEmitter: any): GPUParticleSystem;
  31050. /**
  31051. * Serializes the particle system to a JSON object.
  31052. * @returns the JSON object
  31053. */
  31054. serialize(): any;
  31055. /**
  31056. * Parses a JSON object to create a GPU particle system.
  31057. * @param parsedParticleSystem The JSON object to parse
  31058. * @param scene The scene to create the particle system in
  31059. * @param rootUrl The root url to use to load external dependencies like texture
  31060. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  31061. * @returns the parsed GPU particle system
  31062. */
  31063. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  31064. }
  31065. }
  31066. declare module BABYLON {
  31067. /**
  31068. * Interface representing a particle system in Babylon.js.
  31069. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  31070. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  31071. */
  31072. interface IParticleSystem {
  31073. /**
  31074. * List of animations used by the particle system.
  31075. */
  31076. animations: Animation[];
  31077. /**
  31078. * The id of the Particle system.
  31079. */
  31080. id: string;
  31081. /**
  31082. * The name of the Particle system.
  31083. */
  31084. name: string;
  31085. /**
  31086. * The emitter represents the Mesh or position we are attaching the particle system to.
  31087. */
  31088. emitter: Nullable<AbstractMesh | Vector3>;
  31089. /**
  31090. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  31091. */
  31092. isBillboardBased: boolean;
  31093. /**
  31094. * The rendering group used by the Particle system to chose when to render.
  31095. */
  31096. renderingGroupId: number;
  31097. /**
  31098. * The layer mask we are rendering the particles through.
  31099. */
  31100. layerMask: number;
  31101. /**
  31102. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  31103. */
  31104. updateSpeed: number;
  31105. /**
  31106. * The amount of time the particle system is running (depends of the overall update speed).
  31107. */
  31108. targetStopDuration: number;
  31109. /**
  31110. * The texture used to render each particle. (this can be a spritesheet)
  31111. */
  31112. particleTexture: Nullable<Texture>;
  31113. /**
  31114. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  31115. */
  31116. blendMode: number;
  31117. /**
  31118. * Minimum life time of emitting particles.
  31119. */
  31120. minLifeTime: number;
  31121. /**
  31122. * Maximum life time of emitting particles.
  31123. */
  31124. maxLifeTime: number;
  31125. /**
  31126. * Minimum Size of emitting particles.
  31127. */
  31128. minSize: number;
  31129. /**
  31130. * Maximum Size of emitting particles.
  31131. */
  31132. maxSize: number;
  31133. /**
  31134. * Minimum scale of emitting particles on X axis.
  31135. */
  31136. minScaleX: number;
  31137. /**
  31138. * Maximum scale of emitting particles on X axis.
  31139. */
  31140. maxScaleX: number;
  31141. /**
  31142. * Minimum scale of emitting particles on Y axis.
  31143. */
  31144. minScaleY: number;
  31145. /**
  31146. * Maximum scale of emitting particles on Y axis.
  31147. */
  31148. maxScaleY: number;
  31149. /**
  31150. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31151. */
  31152. color1: Color4;
  31153. /**
  31154. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31155. */
  31156. color2: Color4;
  31157. /**
  31158. * Color the particle will have at the end of its lifetime.
  31159. */
  31160. colorDead: Color4;
  31161. /**
  31162. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  31163. */
  31164. emitRate: number;
  31165. /**
  31166. * You can use gravity if you want to give an orientation to your particles.
  31167. */
  31168. gravity: Vector3;
  31169. /**
  31170. * Minimum power of emitting particles.
  31171. */
  31172. minEmitPower: number;
  31173. /**
  31174. * Maximum power of emitting particles.
  31175. */
  31176. maxEmitPower: number;
  31177. /**
  31178. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  31179. */
  31180. minAngularSpeed: number;
  31181. /**
  31182. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  31183. */
  31184. maxAngularSpeed: number;
  31185. /**
  31186. * Gets or sets the minimal initial rotation in radians.
  31187. */
  31188. minInitialRotation: number;
  31189. /**
  31190. * Gets or sets the maximal initial rotation in radians.
  31191. */
  31192. maxInitialRotation: number;
  31193. /**
  31194. * The particle emitter type defines the emitter used by the particle system.
  31195. * It can be for example box, sphere, or cone...
  31196. */
  31197. particleEmitterType: Nullable<IParticleEmitterType>;
  31198. /**
  31199. * Defines the delay in milliseconds before starting the system (0 by default)
  31200. */
  31201. startDelay: number;
  31202. /**
  31203. * 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
  31204. */
  31205. preWarmCycles: number;
  31206. /**
  31207. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  31208. */
  31209. preWarmStepOffset: number;
  31210. /**
  31211. * 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)
  31212. */
  31213. spriteCellChangeSpeed: number;
  31214. /**
  31215. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  31216. */
  31217. startSpriteCellID: number;
  31218. /**
  31219. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  31220. */
  31221. endSpriteCellID: number;
  31222. /**
  31223. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  31224. */
  31225. spriteCellWidth: number;
  31226. /**
  31227. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  31228. */
  31229. spriteCellHeight: number;
  31230. /**
  31231. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  31232. */
  31233. spriteRandomStartCell: boolean;
  31234. /**
  31235. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  31236. */
  31237. isAnimationSheetEnabled: boolean;
  31238. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  31239. translationPivot: Vector2;
  31240. /**
  31241. * Gets or sets a texture used to add random noise to particle positions
  31242. */
  31243. noiseTexture: Nullable<BaseTexture>;
  31244. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  31245. noiseStrength: Vector3;
  31246. /**
  31247. * Gets or sets the billboard mode to use when isBillboardBased = true.
  31248. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  31249. */
  31250. billboardMode: number;
  31251. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  31252. limitVelocityDamping: number;
  31253. /**
  31254. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  31255. */
  31256. beginAnimationOnStart: boolean;
  31257. /**
  31258. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  31259. */
  31260. beginAnimationFrom: number;
  31261. /**
  31262. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  31263. */
  31264. beginAnimationTo: number;
  31265. /**
  31266. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  31267. */
  31268. beginAnimationLoop: boolean;
  31269. /**
  31270. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  31271. */
  31272. disposeOnStop: boolean;
  31273. /**
  31274. * Gets the maximum number of particles active at the same time.
  31275. * @returns The max number of active particles.
  31276. */
  31277. getCapacity(): number;
  31278. /**
  31279. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31280. * @returns True if it has been started, otherwise false.
  31281. */
  31282. isStarted(): boolean;
  31283. /**
  31284. * Animates the particle system for this frame.
  31285. */
  31286. animate(): void;
  31287. /**
  31288. * Renders the particle system in its current state.
  31289. * @returns the current number of particles
  31290. */
  31291. render(): number;
  31292. /**
  31293. * Dispose the particle system and frees its associated resources.
  31294. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31295. */
  31296. dispose(disposeTexture?: boolean): void;
  31297. /**
  31298. * Clones the particle system.
  31299. * @param name The name of the cloned object
  31300. * @param newEmitter The new emitter to use
  31301. * @returns the cloned particle system
  31302. */
  31303. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  31304. /**
  31305. * Serializes the particle system to a JSON object.
  31306. * @returns the JSON object
  31307. */
  31308. serialize(): any;
  31309. /**
  31310. * Rebuild the particle system
  31311. */
  31312. rebuild(): void;
  31313. /**
  31314. * Starts the particle system and begins to emit
  31315. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  31316. */
  31317. start(delay?: number): void;
  31318. /**
  31319. * Stops the particle system.
  31320. */
  31321. stop(): void;
  31322. /**
  31323. * Remove all active particles
  31324. */
  31325. reset(): void;
  31326. /**
  31327. * Is this system ready to be used/rendered
  31328. * @return true if the system is ready
  31329. */
  31330. isReady(): boolean;
  31331. /**
  31332. * Adds a new color gradient
  31333. * @param gradient defines the gradient to use (between 0 and 1)
  31334. * @param color1 defines the color to affect to the specified gradient
  31335. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31336. * @returns the current particle system
  31337. */
  31338. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31339. /**
  31340. * Remove a specific color gradient
  31341. * @param gradient defines the gradient to remove
  31342. * @returns the current particle system
  31343. */
  31344. removeColorGradient(gradient: number): IParticleSystem;
  31345. /**
  31346. * Adds a new size gradient
  31347. * @param gradient defines the gradient to use (between 0 and 1)
  31348. * @param factor defines the size factor to affect to the specified gradient
  31349. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31350. * @returns the current particle system
  31351. */
  31352. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31353. /**
  31354. * Remove a specific size gradient
  31355. * @param gradient defines the gradient to remove
  31356. * @returns the current particle system
  31357. */
  31358. removeSizeGradient(gradient: number): IParticleSystem;
  31359. /**
  31360. * Gets the current list of color gradients.
  31361. * You must use addColorGradient and removeColorGradient to udpate this list
  31362. * @returns the list of color gradients
  31363. */
  31364. getColorGradients(): Nullable<Array<ColorGradient>>;
  31365. /**
  31366. * Gets the current list of size gradients.
  31367. * You must use addSizeGradient and removeSizeGradient to udpate this list
  31368. * @returns the list of size gradients
  31369. */
  31370. getSizeGradients(): Nullable<Array<FactorGradient>>;
  31371. /**
  31372. * Gets the current list of angular speed gradients.
  31373. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  31374. * @returns the list of angular speed gradients
  31375. */
  31376. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  31377. /**
  31378. * Adds a new angular speed gradient
  31379. * @param gradient defines the gradient to use (between 0 and 1)
  31380. * @param factor defines the angular speed to affect to the specified gradient
  31381. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31382. * @returns the current particle system
  31383. */
  31384. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31385. /**
  31386. * Remove a specific angular speed gradient
  31387. * @param gradient defines the gradient to remove
  31388. * @returns the current particle system
  31389. */
  31390. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31391. /**
  31392. * Gets the current list of velocity gradients.
  31393. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  31394. * @returns the list of velocity gradients
  31395. */
  31396. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  31397. /**
  31398. * Adds a new velocity gradient
  31399. * @param gradient defines the gradient to use (between 0 and 1)
  31400. * @param factor defines the velocity to affect to the specified gradient
  31401. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31402. * @returns the current particle system
  31403. */
  31404. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31405. /**
  31406. * Remove a specific velocity gradient
  31407. * @param gradient defines the gradient to remove
  31408. * @returns the current particle system
  31409. */
  31410. removeVelocityGradient(gradient: number): IParticleSystem;
  31411. /**
  31412. * Gets the current list of limit velocity gradients.
  31413. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  31414. * @returns the list of limit velocity gradients
  31415. */
  31416. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  31417. /**
  31418. * Adds a new limit velocity gradient
  31419. * @param gradient defines the gradient to use (between 0 and 1)
  31420. * @param factor defines the limit velocity to affect to the specified gradient
  31421. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31422. * @returns the current particle system
  31423. */
  31424. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31425. /**
  31426. * Remove a specific limit velocity gradient
  31427. * @param gradient defines the gradient to remove
  31428. * @returns the current particle system
  31429. */
  31430. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31431. /**
  31432. * Adds a new drag gradient
  31433. * @param gradient defines the gradient to use (between 0 and 1)
  31434. * @param factor defines the drag to affect to the specified gradient
  31435. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31436. * @returns the current particle system
  31437. */
  31438. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31439. /**
  31440. * Remove a specific drag gradient
  31441. * @param gradient defines the gradient to remove
  31442. * @returns the current particle system
  31443. */
  31444. removeDragGradient(gradient: number): IParticleSystem;
  31445. /**
  31446. * Gets the current list of drag gradients.
  31447. * You must use addDragGradient and removeDragGradient to udpate this list
  31448. * @returns the list of drag gradients
  31449. */
  31450. getDragGradients(): Nullable<Array<FactorGradient>>;
  31451. /**
  31452. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31453. * @param gradient defines the gradient to use (between 0 and 1)
  31454. * @param factor defines the emit rate to affect to the specified gradient
  31455. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31456. * @returns the current particle system
  31457. */
  31458. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31459. /**
  31460. * Remove a specific emit rate gradient
  31461. * @param gradient defines the gradient to remove
  31462. * @returns the current particle system
  31463. */
  31464. removeEmitRateGradient(gradient: number): IParticleSystem;
  31465. /**
  31466. * Gets the current list of emit rate gradients.
  31467. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  31468. * @returns the list of emit rate gradients
  31469. */
  31470. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  31471. /**
  31472. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31473. * @param gradient defines the gradient to use (between 0 and 1)
  31474. * @param factor defines the start size to affect to the specified gradient
  31475. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31476. * @returns the current particle system
  31477. */
  31478. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31479. /**
  31480. * Remove a specific start size gradient
  31481. * @param gradient defines the gradient to remove
  31482. * @returns the current particle system
  31483. */
  31484. removeStartSizeGradient(gradient: number): IParticleSystem;
  31485. /**
  31486. * Gets the current list of start size gradients.
  31487. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  31488. * @returns the list of start size gradients
  31489. */
  31490. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  31491. /**
  31492. * Adds a new life time gradient
  31493. * @param gradient defines the gradient to use (between 0 and 1)
  31494. * @param factor defines the life time factor to affect to the specified gradient
  31495. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31496. * @returns the current particle system
  31497. */
  31498. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31499. /**
  31500. * Remove a specific life time gradient
  31501. * @param gradient defines the gradient to remove
  31502. * @returns the current particle system
  31503. */
  31504. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31505. /**
  31506. * Gets the current list of life time gradients.
  31507. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  31508. * @returns the list of life time gradients
  31509. */
  31510. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  31511. /**
  31512. * Gets the current list of color gradients.
  31513. * You must use addColorGradient and removeColorGradient to udpate this list
  31514. * @returns the list of color gradients
  31515. */
  31516. getColorGradients(): Nullable<Array<ColorGradient>>;
  31517. /**
  31518. * Adds a new ramp gradient used to remap particle colors
  31519. * @param gradient defines the gradient to use (between 0 and 1)
  31520. * @param color defines the color to affect to the specified gradient
  31521. * @returns the current particle system
  31522. */
  31523. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31524. /**
  31525. * Gets the current list of ramp gradients.
  31526. * You must use addRampGradient and removeRampGradient to udpate this list
  31527. * @returns the list of ramp gradients
  31528. */
  31529. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31530. /** Gets or sets a boolean indicating that ramp gradients must be used
  31531. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31532. */
  31533. useRampGradients: boolean;
  31534. /**
  31535. * Adds a new color remap gradient
  31536. * @param gradient defines the gradient to use (between 0 and 1)
  31537. * @param min defines the color remap minimal range
  31538. * @param max defines the color remap maximal range
  31539. * @returns the current particle system
  31540. */
  31541. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31542. /**
  31543. * Gets the current list of color remap gradients.
  31544. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  31545. * @returns the list of color remap gradients
  31546. */
  31547. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  31548. /**
  31549. * Adds a new alpha remap gradient
  31550. * @param gradient defines the gradient to use (between 0 and 1)
  31551. * @param min defines the alpha remap minimal range
  31552. * @param max defines the alpha remap maximal range
  31553. * @returns the current particle system
  31554. */
  31555. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31556. /**
  31557. * Gets the current list of alpha remap gradients.
  31558. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  31559. * @returns the list of alpha remap gradients
  31560. */
  31561. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  31562. /**
  31563. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  31564. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31565. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31566. * @returns the emitter
  31567. */
  31568. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  31569. /**
  31570. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  31571. * @param radius The radius of the hemisphere to emit from
  31572. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31573. * @returns the emitter
  31574. */
  31575. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  31576. /**
  31577. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  31578. * @param radius The radius of the sphere to emit from
  31579. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31580. * @returns the emitter
  31581. */
  31582. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  31583. /**
  31584. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  31585. * @param radius The radius of the sphere to emit from
  31586. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  31587. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  31588. * @returns the emitter
  31589. */
  31590. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31591. /**
  31592. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  31593. * @param radius The radius of the emission cylinder
  31594. * @param height The height of the emission cylinder
  31595. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  31596. * @param directionRandomizer How much to randomize the particle direction [0-1]
  31597. * @returns the emitter
  31598. */
  31599. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  31600. /**
  31601. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  31602. * @param radius The radius of the cylinder to emit from
  31603. * @param height The height of the emission cylinder
  31604. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  31605. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  31606. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  31607. * @returns the emitter
  31608. */
  31609. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31610. /**
  31611. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  31612. * @param radius The radius of the cone to emit from
  31613. * @param angle The base angle of the cone
  31614. * @returns the emitter
  31615. */
  31616. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  31617. /**
  31618. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  31619. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31620. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31621. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31622. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31623. * @returns the emitter
  31624. */
  31625. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  31626. /**
  31627. * Get hosting scene
  31628. * @returns the scene
  31629. */
  31630. getScene(): Scene;
  31631. }
  31632. }
  31633. declare module BABYLON {
  31634. /**
  31635. * A particle represents one of the element emitted by a particle system.
  31636. * This is mainly define by its coordinates, direction, velocity and age.
  31637. */
  31638. class Particle {
  31639. /**
  31640. * The particle system the particle belongs to.
  31641. */
  31642. particleSystem: ParticleSystem;
  31643. private static _Count;
  31644. /**
  31645. * Unique ID of the particle
  31646. */
  31647. id: number;
  31648. /**
  31649. * The world position of the particle in the scene.
  31650. */
  31651. position: Vector3;
  31652. /**
  31653. * The world direction of the particle in the scene.
  31654. */
  31655. direction: Vector3;
  31656. /**
  31657. * The color of the particle.
  31658. */
  31659. color: Color4;
  31660. /**
  31661. * The color change of the particle per step.
  31662. */
  31663. colorStep: Color4;
  31664. /**
  31665. * Defines how long will the life of the particle be.
  31666. */
  31667. lifeTime: number;
  31668. /**
  31669. * The current age of the particle.
  31670. */
  31671. age: number;
  31672. /**
  31673. * The current size of the particle.
  31674. */
  31675. size: number;
  31676. /**
  31677. * The current scale of the particle.
  31678. */
  31679. scale: Vector2;
  31680. /**
  31681. * The current angle of the particle.
  31682. */
  31683. angle: number;
  31684. /**
  31685. * Defines how fast is the angle changing.
  31686. */
  31687. angularSpeed: number;
  31688. /**
  31689. * Defines the cell index used by the particle to be rendered from a sprite.
  31690. */
  31691. cellIndex: number;
  31692. /**
  31693. * The information required to support color remapping
  31694. */
  31695. remapData: Vector4;
  31696. /** @hidden */
  31697. _randomCellOffset?: number;
  31698. /** @hidden */
  31699. _initialDirection: Nullable<Vector3>;
  31700. /** @hidden */
  31701. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  31702. /** @hidden */
  31703. _initialStartSpriteCellID: number;
  31704. /** @hidden */
  31705. _initialEndSpriteCellID: number;
  31706. /** @hidden */
  31707. _currentColorGradient: Nullable<ColorGradient>;
  31708. /** @hidden */
  31709. _currentColor1: Color4;
  31710. /** @hidden */
  31711. _currentColor2: Color4;
  31712. /** @hidden */
  31713. _currentSizeGradient: Nullable<FactorGradient>;
  31714. /** @hidden */
  31715. _currentSize1: number;
  31716. /** @hidden */
  31717. _currentSize2: number;
  31718. /** @hidden */
  31719. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  31720. /** @hidden */
  31721. _currentAngularSpeed1: number;
  31722. /** @hidden */
  31723. _currentAngularSpeed2: number;
  31724. /** @hidden */
  31725. _currentVelocityGradient: Nullable<FactorGradient>;
  31726. /** @hidden */
  31727. _currentVelocity1: number;
  31728. /** @hidden */
  31729. _currentVelocity2: number;
  31730. /** @hidden */
  31731. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  31732. /** @hidden */
  31733. _currentLimitVelocity1: number;
  31734. /** @hidden */
  31735. _currentLimitVelocity2: number;
  31736. /** @hidden */
  31737. _currentDragGradient: Nullable<FactorGradient>;
  31738. /** @hidden */
  31739. _currentDrag1: number;
  31740. /** @hidden */
  31741. _currentDrag2: number;
  31742. /** @hidden */
  31743. _randomNoiseCoordinates1: Vector3;
  31744. /** @hidden */
  31745. _randomNoiseCoordinates2: Vector3;
  31746. /**
  31747. * Creates a new instance Particle
  31748. * @param particleSystem the particle system the particle belongs to
  31749. */
  31750. constructor(
  31751. /**
  31752. * The particle system the particle belongs to.
  31753. */
  31754. particleSystem: ParticleSystem);
  31755. private updateCellInfoFromSystem;
  31756. /**
  31757. * Defines how the sprite cell index is updated for the particle
  31758. */
  31759. updateCellIndex(): void;
  31760. /** @hidden */
  31761. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  31762. /** @hidden */
  31763. _inheritParticleInfoToSubEmitters(): void;
  31764. /** @hidden */
  31765. _reset(): void;
  31766. /**
  31767. * Copy the properties of particle to another one.
  31768. * @param other the particle to copy the information to.
  31769. */
  31770. copyTo(other: Particle): void;
  31771. }
  31772. }
  31773. declare module BABYLON {
  31774. /**
  31775. * This class is made for on one-liner static method to help creating particle system set.
  31776. */
  31777. class ParticleHelper {
  31778. /**
  31779. * Gets or sets base Assets URL
  31780. */
  31781. static BaseAssetsUrl: string;
  31782. /**
  31783. * Create a default particle system that you can tweak
  31784. * @param emitter defines the emitter to use
  31785. * @param capacity defines the system capacity (default is 500 particles)
  31786. * @param scene defines the hosting scene
  31787. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  31788. * @returns the new Particle system
  31789. */
  31790. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  31791. /**
  31792. * This is the main static method (one-liner) of this helper to create different particle systems
  31793. * @param type This string represents the type to the particle system to create
  31794. * @param scene The scene where the particle system should live
  31795. * @param gpu If the system will use gpu
  31796. * @returns the ParticleSystemSet created
  31797. */
  31798. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  31799. /**
  31800. * Static function used to export a particle system to a ParticleSystemSet variable.
  31801. * Please note that the emitter shape is not exported
  31802. * @param systems defines the particle systems to export
  31803. * @returns the created particle system set
  31804. */
  31805. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  31806. }
  31807. }
  31808. declare module BABYLON {
  31809. /**
  31810. * This represents a particle system in Babylon.
  31811. * 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.
  31812. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31813. * @example https://doc.babylonjs.com/babylon101/particles
  31814. */
  31815. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  31816. /**
  31817. * Billboard mode will only apply to Y axis
  31818. */
  31819. static readonly BILLBOARDMODE_Y: number;
  31820. /**
  31821. * Billboard mode will apply to all axes
  31822. */
  31823. static readonly BILLBOARDMODE_ALL: number;
  31824. /**
  31825. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  31826. */
  31827. static readonly BILLBOARDMODE_STRETCHED: number;
  31828. /**
  31829. * This function can be defined to provide custom update for active particles.
  31830. * This function will be called instead of regular update (age, position, color, etc.).
  31831. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  31832. */
  31833. updateFunction: (particles: Particle[]) => void;
  31834. private _emitterWorldMatrix;
  31835. /**
  31836. * This function can be defined to specify initial direction for every new particle.
  31837. * It by default use the emitterType defined function
  31838. */
  31839. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  31840. /**
  31841. * This function can be defined to specify initial position for every new particle.
  31842. * It by default use the emitterType defined function
  31843. */
  31844. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  31845. /**
  31846. * @hidden
  31847. */
  31848. _inheritedVelocityOffset: Vector3;
  31849. /**
  31850. * An event triggered when the system is disposed
  31851. */
  31852. onDisposeObservable: Observable<ParticleSystem>;
  31853. private _onDisposeObserver;
  31854. /**
  31855. * Sets a callback that will be triggered when the system is disposed
  31856. */
  31857. onDispose: () => void;
  31858. private _particles;
  31859. private _epsilon;
  31860. private _capacity;
  31861. private _stockParticles;
  31862. private _newPartsExcess;
  31863. private _vertexData;
  31864. private _vertexBuffer;
  31865. private _vertexBuffers;
  31866. private _spriteBuffer;
  31867. private _indexBuffer;
  31868. private _effect;
  31869. private _customEffect;
  31870. private _cachedDefines;
  31871. private _scaledColorStep;
  31872. private _colorDiff;
  31873. private _scaledDirection;
  31874. private _scaledGravity;
  31875. private _currentRenderId;
  31876. private _alive;
  31877. private _useInstancing;
  31878. private _started;
  31879. private _stopped;
  31880. private _actualFrame;
  31881. private _scaledUpdateSpeed;
  31882. private _vertexBufferSize;
  31883. /** @hidden */
  31884. _currentEmitRateGradient: Nullable<FactorGradient>;
  31885. /** @hidden */
  31886. _currentEmitRate1: number;
  31887. /** @hidden */
  31888. _currentEmitRate2: number;
  31889. /** @hidden */
  31890. _currentStartSizeGradient: Nullable<FactorGradient>;
  31891. /** @hidden */
  31892. _currentStartSize1: number;
  31893. /** @hidden */
  31894. _currentStartSize2: number;
  31895. private readonly _rawTextureWidth;
  31896. private _rampGradientsTexture;
  31897. private _useRampGradients;
  31898. /** Gets or sets a boolean indicating that ramp gradients must be used
  31899. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31900. */
  31901. useRampGradients: boolean;
  31902. /**
  31903. * 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.
  31904. * 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: [])
  31905. */
  31906. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  31907. private _subEmitters;
  31908. /**
  31909. * @hidden
  31910. * If the particle systems emitter should be disposed when the particle system is disposed
  31911. */
  31912. _disposeEmitterOnDispose: boolean;
  31913. /**
  31914. * The current active Sub-systems, this property is used by the root particle system only.
  31915. */
  31916. activeSubSystems: Array<ParticleSystem>;
  31917. private _rootParticleSystem;
  31918. /**
  31919. * Gets the current list of active particles
  31920. */
  31921. readonly particles: Particle[];
  31922. /**
  31923. * Returns the string "ParticleSystem"
  31924. * @returns a string containing the class name
  31925. */
  31926. getClassName(): string;
  31927. /**
  31928. * Instantiates a particle system.
  31929. * 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.
  31930. * @param name The name of the particle system
  31931. * @param capacity The max number of particles alive at the same time
  31932. * @param scene The scene the particle system belongs to
  31933. * @param customEffect a custom effect used to change the way particles are rendered by default
  31934. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31935. * @param epsilon Offset used to render the particles
  31936. */
  31937. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  31938. private _addFactorGradient;
  31939. private _removeFactorGradient;
  31940. /**
  31941. * Adds a new life time gradient
  31942. * @param gradient defines the gradient to use (between 0 and 1)
  31943. * @param factor defines the life time factor 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. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31948. /**
  31949. * Remove a specific life time gradient
  31950. * @param gradient defines the gradient to remove
  31951. * @returns the current particle system
  31952. */
  31953. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31954. /**
  31955. * Adds a new size gradient
  31956. * @param gradient defines the gradient to use (between 0 and 1)
  31957. * @param factor defines the size factor 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. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31962. /**
  31963. * Remove a specific size gradient
  31964. * @param gradient defines the gradient to remove
  31965. * @returns the current particle system
  31966. */
  31967. removeSizeGradient(gradient: number): IParticleSystem;
  31968. /**
  31969. * Adds a new color remap gradient
  31970. * @param gradient defines the gradient to use (between 0 and 1)
  31971. * @param min defines the color remap minimal range
  31972. * @param max defines the color remap maximal range
  31973. * @returns the current particle system
  31974. */
  31975. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31976. /**
  31977. * Remove a specific color remap gradient
  31978. * @param gradient defines the gradient to remove
  31979. * @returns the current particle system
  31980. */
  31981. removeColorRemapGradient(gradient: number): IParticleSystem;
  31982. /**
  31983. * Adds a new alpha remap gradient
  31984. * @param gradient defines the gradient to use (between 0 and 1)
  31985. * @param min defines the alpha remap minimal range
  31986. * @param max defines the alpha remap maximal range
  31987. * @returns the current particle system
  31988. */
  31989. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31990. /**
  31991. * Remove a specific alpha remap gradient
  31992. * @param gradient defines the gradient to remove
  31993. * @returns the current particle system
  31994. */
  31995. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  31996. /**
  31997. * Adds a new angular speed gradient
  31998. * @param gradient defines the gradient to use (between 0 and 1)
  31999. * @param factor defines the angular speed to affect to the specified gradient
  32000. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32001. * @returns the current particle system
  32002. */
  32003. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32004. /**
  32005. * Remove a specific angular speed gradient
  32006. * @param gradient defines the gradient to remove
  32007. * @returns the current particle system
  32008. */
  32009. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  32010. /**
  32011. * Adds a new velocity gradient
  32012. * @param gradient defines the gradient to use (between 0 and 1)
  32013. * @param factor defines the velocity to affect to the specified gradient
  32014. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32015. * @returns the current particle system
  32016. */
  32017. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32018. /**
  32019. * Remove a specific velocity gradient
  32020. * @param gradient defines the gradient to remove
  32021. * @returns the current particle system
  32022. */
  32023. removeVelocityGradient(gradient: number): IParticleSystem;
  32024. /**
  32025. * Adds a new limit velocity gradient
  32026. * @param gradient defines the gradient to use (between 0 and 1)
  32027. * @param factor defines the limit velocity value to affect to the specified gradient
  32028. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32029. * @returns the current particle system
  32030. */
  32031. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32032. /**
  32033. * Remove a specific limit velocity gradient
  32034. * @param gradient defines the gradient to remove
  32035. * @returns the current particle system
  32036. */
  32037. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  32038. /**
  32039. * Adds a new drag gradient
  32040. * @param gradient defines the gradient to use (between 0 and 1)
  32041. * @param factor defines the drag value to affect to the specified gradient
  32042. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32043. * @returns the current particle system
  32044. */
  32045. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32046. /**
  32047. * Remove a specific drag gradient
  32048. * @param gradient defines the gradient to remove
  32049. * @returns the current particle system
  32050. */
  32051. removeDragGradient(gradient: number): IParticleSystem;
  32052. /**
  32053. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  32054. * @param gradient defines the gradient to use (between 0 and 1)
  32055. * @param factor defines the emit rate value to affect to the specified gradient
  32056. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32057. * @returns the current particle system
  32058. */
  32059. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32060. /**
  32061. * Remove a specific emit rate gradient
  32062. * @param gradient defines the gradient to remove
  32063. * @returns the current particle system
  32064. */
  32065. removeEmitRateGradient(gradient: number): IParticleSystem;
  32066. /**
  32067. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  32068. * @param gradient defines the gradient to use (between 0 and 1)
  32069. * @param factor defines the start size value to affect to the specified gradient
  32070. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32071. * @returns the current particle system
  32072. */
  32073. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32074. /**
  32075. * Remove a specific start size gradient
  32076. * @param gradient defines the gradient to remove
  32077. * @returns the current particle system
  32078. */
  32079. removeStartSizeGradient(gradient: number): IParticleSystem;
  32080. private _createRampGradientTexture;
  32081. /**
  32082. * Gets the current list of ramp gradients.
  32083. * You must use addRampGradient and removeRampGradient to udpate this list
  32084. * @returns the list of ramp gradients
  32085. */
  32086. getRampGradients(): Nullable<Array<Color3Gradient>>;
  32087. /**
  32088. * Adds a new ramp gradient used to remap particle colors
  32089. * @param gradient defines the gradient to use (between 0 and 1)
  32090. * @param color defines the color to affect to the specified gradient
  32091. * @returns the current particle system
  32092. */
  32093. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  32094. /**
  32095. * Remove a specific ramp gradient
  32096. * @param gradient defines the gradient to remove
  32097. * @returns the current particle system
  32098. */
  32099. removeRampGradient(gradient: number): ParticleSystem;
  32100. /**
  32101. * Adds a new color gradient
  32102. * @param gradient defines the gradient to use (between 0 and 1)
  32103. * @param color1 defines the color to affect to the specified gradient
  32104. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32105. * @returns this particle system
  32106. */
  32107. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  32108. /**
  32109. * Remove a specific color gradient
  32110. * @param gradient defines the gradient to remove
  32111. * @returns this particle system
  32112. */
  32113. removeColorGradient(gradient: number): IParticleSystem;
  32114. private _fetchR;
  32115. protected _reset(): void;
  32116. private _resetEffect;
  32117. private _createVertexBuffers;
  32118. private _createIndexBuffer;
  32119. /**
  32120. * Gets the maximum number of particles active at the same time.
  32121. * @returns The max number of active particles.
  32122. */
  32123. getCapacity(): number;
  32124. /**
  32125. * Gets whether there are still active particles in the system.
  32126. * @returns True if it is alive, otherwise false.
  32127. */
  32128. isAlive(): boolean;
  32129. /**
  32130. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32131. * @returns True if it has been started, otherwise false.
  32132. */
  32133. isStarted(): boolean;
  32134. private _prepareSubEmitterInternalArray;
  32135. /**
  32136. * Starts the particle system and begins to emit
  32137. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  32138. */
  32139. start(delay?: number): void;
  32140. /**
  32141. * Stops the particle system.
  32142. * @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.
  32143. */
  32144. stop(stopSubEmitters?: boolean): void;
  32145. /**
  32146. * Remove all active particles
  32147. */
  32148. reset(): void;
  32149. /**
  32150. * @hidden (for internal use only)
  32151. */
  32152. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  32153. /**
  32154. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  32155. * Its lifetime will start back at 0.
  32156. */
  32157. recycleParticle: (particle: Particle) => void;
  32158. private _stopSubEmitters;
  32159. private _createParticle;
  32160. private _removeFromRoot;
  32161. private _emitFromParticle;
  32162. private _update;
  32163. /** @hidden */
  32164. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  32165. /** @hidden */
  32166. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  32167. /** @hidden */
  32168. private _getEffect;
  32169. /**
  32170. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  32171. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  32172. */
  32173. animate(preWarmOnly?: boolean): void;
  32174. private _appendParticleVertices;
  32175. /**
  32176. * Rebuilds the particle system.
  32177. */
  32178. rebuild(): void;
  32179. /**
  32180. * Is this system ready to be used/rendered
  32181. * @return true if the system is ready
  32182. */
  32183. isReady(): boolean;
  32184. private _render;
  32185. /**
  32186. * Renders the particle system in its current state.
  32187. * @returns the current number of particles
  32188. */
  32189. render(): number;
  32190. /**
  32191. * Disposes the particle system and free the associated resources
  32192. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32193. */
  32194. dispose(disposeTexture?: boolean): void;
  32195. /**
  32196. * Clones the particle system.
  32197. * @param name The name of the cloned object
  32198. * @param newEmitter The new emitter to use
  32199. * @returns the cloned particle system
  32200. */
  32201. clone(name: string, newEmitter: any): ParticleSystem;
  32202. /**
  32203. * Serializes the particle system to a JSON object.
  32204. * @returns the JSON object
  32205. */
  32206. serialize(): any;
  32207. /** @hidden */
  32208. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  32209. /** @hidden */
  32210. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  32211. /**
  32212. * Parses a JSON object to create a particle system.
  32213. * @param parsedParticleSystem The JSON object to parse
  32214. * @param scene The scene to create the particle system in
  32215. * @param rootUrl The root url to use to load external dependencies like texture
  32216. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  32217. * @returns the Parsed particle system
  32218. */
  32219. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  32220. }
  32221. }
  32222. declare module BABYLON {
  32223. interface Engine {
  32224. /**
  32225. * Create an effect to use with particle systems.
  32226. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  32227. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  32228. * @param uniformsNames defines a list of attribute names
  32229. * @param samplers defines an array of string used to represent textures
  32230. * @param defines defines the string containing the defines to use to compile the shaders
  32231. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32232. * @param onCompiled defines a function to call when the effect creation is successful
  32233. * @param onError defines a function to call when the effect creation has failed
  32234. * @returns the new Effect
  32235. */
  32236. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  32237. }
  32238. interface Mesh {
  32239. /**
  32240. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  32241. * @returns an array of IParticleSystem
  32242. */
  32243. getEmittedParticleSystems(): IParticleSystem[];
  32244. /**
  32245. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  32246. * @returns an array of IParticleSystem
  32247. */
  32248. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  32249. }
  32250. }
  32251. declare module BABYLON {
  32252. /**
  32253. * Represents a set of particle systems working together to create a specific effect
  32254. */
  32255. class ParticleSystemSet implements IDisposable {
  32256. private _emitterCreationOptions;
  32257. private _emitterNode;
  32258. /**
  32259. * Gets the particle system list
  32260. */
  32261. systems: IParticleSystem[];
  32262. /**
  32263. * Gets the emitter node used with this set
  32264. */
  32265. readonly emitterNode: Nullable<TransformNode>;
  32266. /**
  32267. * Creates a new emitter mesh as a sphere
  32268. * @param options defines the options used to create the sphere
  32269. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  32270. * @param scene defines the hosting scene
  32271. */
  32272. setEmitterAsSphere(options: {
  32273. diameter: number;
  32274. segments: number;
  32275. color: Color3;
  32276. }, renderingGroupId: number, scene: Scene): void;
  32277. /**
  32278. * Starts all particle systems of the set
  32279. * @param emitter defines an optional mesh to use as emitter for the particle systems
  32280. */
  32281. start(emitter?: AbstractMesh): void;
  32282. /**
  32283. * Release all associated resources
  32284. */
  32285. dispose(): void;
  32286. /**
  32287. * Serialize the set into a JSON compatible object
  32288. * @returns a JSON compatible representation of the set
  32289. */
  32290. serialize(): any;
  32291. /**
  32292. * Parse a new ParticleSystemSet from a serialized source
  32293. * @param data defines a JSON compatible representation of the set
  32294. * @param scene defines the hosting scene
  32295. * @param gpu defines if we want GPU particles or CPU particles
  32296. * @returns a new ParticleSystemSet
  32297. */
  32298. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  32299. }
  32300. }
  32301. declare module BABYLON {
  32302. /**
  32303. * Represents one particle of a solid particle system.
  32304. */
  32305. class SolidParticle {
  32306. /**
  32307. * particle global index
  32308. */
  32309. idx: number;
  32310. /**
  32311. * The color of the particle
  32312. */
  32313. color: Nullable<Color4>;
  32314. /**
  32315. * The world space position of the particle.
  32316. */
  32317. position: Vector3;
  32318. /**
  32319. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32320. */
  32321. rotation: Vector3;
  32322. /**
  32323. * The world space rotation quaternion of the particle.
  32324. */
  32325. rotationQuaternion: Nullable<Quaternion>;
  32326. /**
  32327. * The scaling of the particle.
  32328. */
  32329. scaling: Vector3;
  32330. /**
  32331. * The uvs of the particle.
  32332. */
  32333. uvs: Vector4;
  32334. /**
  32335. * The current speed of the particle.
  32336. */
  32337. velocity: Vector3;
  32338. /**
  32339. * The pivot point in the particle local space.
  32340. */
  32341. pivot: Vector3;
  32342. /**
  32343. * Must the particle be translated from its pivot point in its local space ?
  32344. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32345. * Default : false
  32346. */
  32347. translateFromPivot: boolean;
  32348. /**
  32349. * Is the particle active or not ?
  32350. */
  32351. alive: boolean;
  32352. /**
  32353. * Is the particle visible or not ?
  32354. */
  32355. isVisible: boolean;
  32356. /**
  32357. * Index of this particle in the global "positions" array (Internal use)
  32358. * @hidden
  32359. */
  32360. _pos: number;
  32361. /**
  32362. * @hidden Index of this particle in the global "indices" array (Internal use)
  32363. */
  32364. _ind: number;
  32365. /**
  32366. * @hidden ModelShape of this particle (Internal use)
  32367. */
  32368. _model: ModelShape;
  32369. /**
  32370. * ModelShape id of this particle
  32371. */
  32372. shapeId: number;
  32373. /**
  32374. * Index of the particle in its shape id (Internal use)
  32375. */
  32376. idxInShape: number;
  32377. /**
  32378. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32379. */
  32380. _modelBoundingInfo: BoundingInfo;
  32381. /**
  32382. * @hidden Particle BoundingInfo object (Internal use)
  32383. */
  32384. _boundingInfo: BoundingInfo;
  32385. /**
  32386. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32387. */
  32388. _sps: SolidParticleSystem;
  32389. /**
  32390. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32391. */
  32392. _stillInvisible: boolean;
  32393. /**
  32394. * @hidden Last computed particle rotation matrix
  32395. */
  32396. _rotationMatrix: number[];
  32397. /**
  32398. * Parent particle Id, if any.
  32399. * Default null.
  32400. */
  32401. parentId: Nullable<number>;
  32402. /**
  32403. * @hidden Internal global position in the SPS.
  32404. */
  32405. _globalPosition: Vector3;
  32406. /**
  32407. * Creates a Solid Particle object.
  32408. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32409. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  32410. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32411. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32412. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32413. * @param shapeId (integer) is the model shape identifier in the SPS.
  32414. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32415. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32416. */
  32417. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  32418. /**
  32419. * Legacy support, changed scale to scaling
  32420. */
  32421. /**
  32422. * Legacy support, changed scale to scaling
  32423. */
  32424. scale: Vector3;
  32425. /**
  32426. * Legacy support, changed quaternion to rotationQuaternion
  32427. */
  32428. /**
  32429. * Legacy support, changed quaternion to rotationQuaternion
  32430. */
  32431. quaternion: Nullable<Quaternion>;
  32432. /**
  32433. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32434. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32435. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32436. * @returns true if it intersects
  32437. */
  32438. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32439. /**
  32440. * get the rotation matrix of the particle
  32441. * @hidden
  32442. */
  32443. getRotationMatrix(m: Matrix): void;
  32444. }
  32445. /**
  32446. * Represents the shape of the model used by one particle of a solid particle system.
  32447. * SPS internal tool, don't use it manually.
  32448. */
  32449. class ModelShape {
  32450. /**
  32451. * The shape id
  32452. * @hidden
  32453. */
  32454. shapeID: number;
  32455. /**
  32456. * flat array of model positions (internal use)
  32457. * @hidden
  32458. */
  32459. _shape: Vector3[];
  32460. /**
  32461. * flat array of model UVs (internal use)
  32462. * @hidden
  32463. */
  32464. _shapeUV: number[];
  32465. /**
  32466. * length of the shape in the model indices array (internal use)
  32467. * @hidden
  32468. */
  32469. _indicesLength: number;
  32470. /**
  32471. * Custom position function (internal use)
  32472. * @hidden
  32473. */
  32474. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32475. /**
  32476. * Custom vertex function (internal use)
  32477. * @hidden
  32478. */
  32479. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32480. /**
  32481. * 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.
  32482. * SPS internal tool, don't use it manually.
  32483. * @hidden
  32484. */
  32485. 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>);
  32486. }
  32487. /**
  32488. * Represents a Depth Sorted Particle in the solid particle system.
  32489. */
  32490. class DepthSortedParticle {
  32491. /**
  32492. * Index of the particle in the "indices" array
  32493. */
  32494. ind: number;
  32495. /**
  32496. * Length of the particle shape in the "indices" array
  32497. */
  32498. indicesLength: number;
  32499. /**
  32500. * Squared distance from the particle to the camera
  32501. */
  32502. sqDistance: number;
  32503. }
  32504. }
  32505. declare module BABYLON {
  32506. /**
  32507. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32508. *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.
  32509. * The SPS is also a particle system. It provides some methods to manage the particles.
  32510. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32511. *
  32512. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  32513. */
  32514. class SolidParticleSystem implements IDisposable {
  32515. /**
  32516. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32517. * Example : var p = SPS.particles[i];
  32518. */
  32519. particles: SolidParticle[];
  32520. /**
  32521. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32522. */
  32523. nbParticles: number;
  32524. /**
  32525. * If the particles must ever face the camera (default false). Useful for planar particles.
  32526. */
  32527. billboard: boolean;
  32528. /**
  32529. * Recompute normals when adding a shape
  32530. */
  32531. recomputeNormals: boolean;
  32532. /**
  32533. * This a counter ofr your own usage. It's not set by any SPS functions.
  32534. */
  32535. counter: number;
  32536. /**
  32537. * The SPS name. This name is also given to the underlying mesh.
  32538. */
  32539. name: string;
  32540. /**
  32541. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32542. */
  32543. mesh: Mesh;
  32544. /**
  32545. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32546. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  32547. */
  32548. vars: any;
  32549. /**
  32550. * This array is populated when the SPS is set as 'pickable'.
  32551. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32552. * Each element of this array is an object `{idx: int, faceId: int}`.
  32553. * `idx` is the picked particle index in the `SPS.particles` array
  32554. * `faceId` is the picked face index counted within this particle.
  32555. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  32556. */
  32557. pickedParticles: {
  32558. idx: number;
  32559. faceId: number;
  32560. }[];
  32561. /**
  32562. * This array is populated when `enableDepthSort` is set to true.
  32563. * Each element of this array is an instance of the class DepthSortedParticle.
  32564. */
  32565. depthSortedParticles: DepthSortedParticle[];
  32566. /**
  32567. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32568. * @hidden
  32569. */
  32570. _bSphereOnly: boolean;
  32571. /**
  32572. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32573. * @hidden
  32574. */
  32575. _bSphereRadiusFactor: number;
  32576. private _scene;
  32577. private _positions;
  32578. private _indices;
  32579. private _normals;
  32580. private _colors;
  32581. private _uvs;
  32582. private _indices32;
  32583. private _positions32;
  32584. private _normals32;
  32585. private _fixedNormal32;
  32586. private _colors32;
  32587. private _uvs32;
  32588. private _index;
  32589. private _updatable;
  32590. private _pickable;
  32591. private _isVisibilityBoxLocked;
  32592. private _alwaysVisible;
  32593. private _depthSort;
  32594. private _shapeCounter;
  32595. private _copy;
  32596. private _color;
  32597. private _computeParticleColor;
  32598. private _computeParticleTexture;
  32599. private _computeParticleRotation;
  32600. private _computeParticleVertex;
  32601. private _computeBoundingBox;
  32602. private _depthSortParticles;
  32603. private _camera;
  32604. private _mustUnrotateFixedNormals;
  32605. private _particlesIntersect;
  32606. private _needs32Bits;
  32607. /**
  32608. * Creates a SPS (Solid Particle System) object.
  32609. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32610. * @param scene (Scene) is the scene in which the SPS is added.
  32611. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32612. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32613. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32614. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32615. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32616. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32617. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32618. */
  32619. constructor(name: string, scene: Scene, options?: {
  32620. updatable?: boolean;
  32621. isPickable?: boolean;
  32622. enableDepthSort?: boolean;
  32623. particleIntersection?: boolean;
  32624. boundingSphereOnly?: boolean;
  32625. bSphereRadiusFactor?: number;
  32626. });
  32627. /**
  32628. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32629. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32630. * @returns the created mesh
  32631. */
  32632. buildMesh(): Mesh;
  32633. /**
  32634. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32635. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32636. * Thus the particles generated from `digest()` have their property `position` set yet.
  32637. * @param mesh ( Mesh ) is the mesh to be digested
  32638. * @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
  32639. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32640. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32641. * @returns the current SPS
  32642. */
  32643. digest(mesh: Mesh, options?: {
  32644. facetNb?: number;
  32645. number?: number;
  32646. delta?: number;
  32647. }): SolidParticleSystem;
  32648. private _unrotateFixedNormals;
  32649. private _resetCopy;
  32650. private _meshBuilder;
  32651. private _posToShape;
  32652. private _uvsToShapeUV;
  32653. private _addParticle;
  32654. /**
  32655. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32656. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  32657. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32658. * @param nb (positive integer) the number of particles to be created from this model
  32659. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32660. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32661. * @returns the number of shapes in the system
  32662. */
  32663. addShape(mesh: Mesh, nb: number, options?: {
  32664. positionFunction?: any;
  32665. vertexFunction?: any;
  32666. }): number;
  32667. private _rebuildParticle;
  32668. /**
  32669. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32670. * @returns the SPS.
  32671. */
  32672. rebuildMesh(): SolidParticleSystem;
  32673. /**
  32674. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32675. * This method calls `updateParticle()` for each particle of the SPS.
  32676. * For an animated SPS, it is usually called within the render loop.
  32677. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32678. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32679. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32680. * @returns the SPS.
  32681. */
  32682. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32683. /**
  32684. * Disposes the SPS.
  32685. */
  32686. dispose(): void;
  32687. /**
  32688. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32689. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32690. * @returns the SPS.
  32691. */
  32692. refreshVisibleSize(): SolidParticleSystem;
  32693. /**
  32694. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32695. * @param size the size (float) of the visibility box
  32696. * note : this doesn't lock the SPS mesh bounding box.
  32697. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32698. */
  32699. setVisibilityBox(size: number): void;
  32700. /**
  32701. * Gets whether the SPS as always visible or not
  32702. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32703. */
  32704. /**
  32705. * Sets the SPS as always visible or not
  32706. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32707. */
  32708. isAlwaysVisible: boolean;
  32709. /**
  32710. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32711. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32712. */
  32713. /**
  32714. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32715. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32716. */
  32717. isVisibilityBoxLocked: boolean;
  32718. /**
  32719. * Tells to `setParticles()` to compute the particle rotations or not.
  32720. * Default value : true. The SPS is faster when it's set to false.
  32721. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32722. */
  32723. /**
  32724. * Gets if `setParticles()` computes the particle rotations or not.
  32725. * Default value : true. The SPS is faster when it's set to false.
  32726. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32727. */
  32728. computeParticleRotation: boolean;
  32729. /**
  32730. * Tells to `setParticles()` to compute the particle colors or not.
  32731. * Default value : true. The SPS is faster when it's set to false.
  32732. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32733. */
  32734. /**
  32735. * Gets if `setParticles()` computes the particle colors or not.
  32736. * Default value : true. The SPS is faster when it's set to false.
  32737. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32738. */
  32739. computeParticleColor: boolean;
  32740. /**
  32741. * Gets if `setParticles()` computes the particle textures or not.
  32742. * Default value : true. The SPS is faster when it's set to false.
  32743. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32744. */
  32745. computeParticleTexture: boolean;
  32746. /**
  32747. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32748. * Default value : false. The SPS is faster when it's set to false.
  32749. * Note : the particle custom vertex positions aren't stored values.
  32750. */
  32751. /**
  32752. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32753. * Default value : false. The SPS is faster when it's set to false.
  32754. * Note : the particle custom vertex positions aren't stored values.
  32755. */
  32756. computeParticleVertex: boolean;
  32757. /**
  32758. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32759. */
  32760. /**
  32761. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32762. */
  32763. computeBoundingBox: boolean;
  32764. /**
  32765. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32766. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32767. * Default : `true`
  32768. */
  32769. /**
  32770. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32771. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32772. * Default : `true`
  32773. */
  32774. depthSortParticles: boolean;
  32775. /**
  32776. * This function does nothing. It may be overwritten to set all the particle first values.
  32777. * The SPS doesn't call this function, you may have to call it by your own.
  32778. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32779. */
  32780. initParticles(): void;
  32781. /**
  32782. * This function does nothing. It may be overwritten to recycle a particle.
  32783. * The SPS doesn't call this function, you may have to call it by your own.
  32784. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32785. * @param particle The particle to recycle
  32786. * @returns the recycled particle
  32787. */
  32788. recycleParticle(particle: SolidParticle): SolidParticle;
  32789. /**
  32790. * Updates a particle : this function should be overwritten by the user.
  32791. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32792. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32793. * @example : just set a particle position or velocity and recycle conditions
  32794. * @param particle The particle to update
  32795. * @returns the updated particle
  32796. */
  32797. updateParticle(particle: SolidParticle): SolidParticle;
  32798. /**
  32799. * Updates a vertex of a particle : it can be overwritten by the user.
  32800. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32801. * @param particle the current particle
  32802. * @param vertex the current index of the current particle
  32803. * @param pt the index of the current vertex in the particle shape
  32804. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  32805. * @example : just set a vertex particle position
  32806. * @returns the updated vertex
  32807. */
  32808. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  32809. /**
  32810. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32811. * This does nothing and may be overwritten by the user.
  32812. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32813. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32814. * @param update the boolean update value actually passed to setParticles()
  32815. */
  32816. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32817. /**
  32818. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32819. * This will be passed three parameters.
  32820. * This does nothing and may be overwritten by the user.
  32821. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32822. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32823. * @param update the boolean update value actually passed to setParticles()
  32824. */
  32825. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32826. }
  32827. }
  32828. declare module BABYLON {
  32829. /**
  32830. * Type of sub emitter
  32831. */
  32832. enum SubEmitterType {
  32833. /**
  32834. * Attached to the particle over it's lifetime
  32835. */
  32836. ATTACHED = 0,
  32837. /**
  32838. * Created when the particle dies
  32839. */
  32840. END = 1
  32841. }
  32842. /**
  32843. * Sub emitter class used to emit particles from an existing particle
  32844. */
  32845. class SubEmitter {
  32846. /**
  32847. * the particle system to be used by the sub emitter
  32848. */
  32849. particleSystem: ParticleSystem;
  32850. /**
  32851. * Type of the submitter (Default: END)
  32852. */
  32853. type: SubEmitterType;
  32854. /**
  32855. * 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)
  32856. * Note: This only is supported when using an emitter of type Mesh
  32857. */
  32858. inheritDirection: boolean;
  32859. /**
  32860. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  32861. */
  32862. inheritedVelocityAmount: number;
  32863. /**
  32864. * Creates a sub emitter
  32865. * @param particleSystem the particle system to be used by the sub emitter
  32866. */
  32867. constructor(
  32868. /**
  32869. * the particle system to be used by the sub emitter
  32870. */
  32871. particleSystem: ParticleSystem);
  32872. /**
  32873. * Clones the sub emitter
  32874. * @returns the cloned sub emitter
  32875. */
  32876. clone(): SubEmitter;
  32877. /**
  32878. * Serialize current object to a JSON object
  32879. * @returns the serialized object
  32880. */
  32881. serialize(): any;
  32882. /**
  32883. * Creates a new SubEmitter from a serialized JSON version
  32884. * @param serializationObject defines the JSON object to read from
  32885. * @param scene defines the hosting scene
  32886. * @param rootUrl defines the rootUrl for data loading
  32887. * @returns a new SubEmitter
  32888. */
  32889. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  32890. /** Release associated resources */
  32891. dispose(): void;
  32892. }
  32893. }
  32894. declare module BABYLON {
  32895. /**
  32896. * Interface used to describe a physics joint
  32897. */
  32898. interface PhysicsImpostorJoint {
  32899. /** Defines the main impostor to which the joint is linked */
  32900. mainImpostor: PhysicsImpostor;
  32901. /** Defines the impostor that is connected to the main impostor using this joint */
  32902. connectedImpostor: PhysicsImpostor;
  32903. /** Defines the joint itself */
  32904. joint: PhysicsJoint;
  32905. }
  32906. /** @hidden */
  32907. interface IPhysicsEnginePlugin {
  32908. world: any;
  32909. name: string;
  32910. setGravity(gravity: Vector3): void;
  32911. setTimeStep(timeStep: number): void;
  32912. getTimeStep(): number;
  32913. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32914. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32915. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32916. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32917. removePhysicsBody(impostor: PhysicsImpostor): void;
  32918. generateJoint(joint: PhysicsImpostorJoint): void;
  32919. removeJoint(joint: PhysicsImpostorJoint): void;
  32920. isSupported(): boolean;
  32921. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32922. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32923. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32924. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32925. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32926. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32927. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32928. getBodyMass(impostor: PhysicsImpostor): number;
  32929. getBodyFriction(impostor: PhysicsImpostor): number;
  32930. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32931. getBodyRestitution(impostor: PhysicsImpostor): number;
  32932. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32933. sleepBody(impostor: PhysicsImpostor): void;
  32934. wakeUpBody(impostor: PhysicsImpostor): void;
  32935. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32936. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32937. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32938. getRadius(impostor: PhysicsImpostor): number;
  32939. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32940. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32941. dispose(): void;
  32942. }
  32943. /**
  32944. * Interface used to define a physics engine
  32945. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32946. */
  32947. interface IPhysicsEngine {
  32948. /**
  32949. * Gets the gravity vector used by the simulation
  32950. */
  32951. gravity: Vector3;
  32952. /**
  32953. * Sets the gravity vector used by the simulation
  32954. * @param gravity defines the gravity vector to use
  32955. */
  32956. setGravity(gravity: Vector3): void;
  32957. /**
  32958. * Set the time step of the physics engine.
  32959. * Default is 1/60.
  32960. * To slow it down, enter 1/600 for example.
  32961. * To speed it up, 1/30
  32962. * @param newTimeStep the new timestep to apply to this world.
  32963. */
  32964. setTimeStep(newTimeStep: number): void;
  32965. /**
  32966. * Get the time step of the physics engine.
  32967. * @returns the current time step
  32968. */
  32969. getTimeStep(): number;
  32970. /**
  32971. * Release all resources
  32972. */
  32973. dispose(): void;
  32974. /**
  32975. * Gets the name of the current physics plugin
  32976. * @returns the name of the plugin
  32977. */
  32978. getPhysicsPluginName(): string;
  32979. /**
  32980. * Adding a new impostor for the impostor tracking.
  32981. * This will be done by the impostor itself.
  32982. * @param impostor the impostor to add
  32983. */
  32984. addImpostor(impostor: PhysicsImpostor): void;
  32985. /**
  32986. * Remove an impostor from the engine.
  32987. * This impostor and its mesh will not longer be updated by the physics engine.
  32988. * @param impostor the impostor to remove
  32989. */
  32990. removeImpostor(impostor: PhysicsImpostor): void;
  32991. /**
  32992. * Add a joint to the physics engine
  32993. * @param mainImpostor defines the main impostor to which the joint is added.
  32994. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32995. * @param joint defines the joint that will connect both impostors.
  32996. */
  32997. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32998. /**
  32999. * Removes a joint from the simulation
  33000. * @param mainImpostor defines the impostor used with the joint
  33001. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33002. * @param joint defines the joint to remove
  33003. */
  33004. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33005. /**
  33006. * Gets the current plugin used to run the simulation
  33007. * @returns current plugin
  33008. */
  33009. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33010. /**
  33011. * Gets the list of physic impostors
  33012. * @returns an array of PhysicsImpostor
  33013. */
  33014. getImpostors(): Array<PhysicsImpostor>;
  33015. /**
  33016. * Gets the impostor for a physics enabled object
  33017. * @param object defines the object impersonated by the impostor
  33018. * @returns the PhysicsImpostor or null if not found
  33019. */
  33020. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33021. /**
  33022. * Gets the impostor for a physics body object
  33023. * @param body defines physics body used by the impostor
  33024. * @returns the PhysicsImpostor or null if not found
  33025. */
  33026. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33027. /**
  33028. * Called by the scene. No need to call it.
  33029. * @param delta defines the timespam between frames
  33030. */
  33031. _step(delta: number): void;
  33032. }
  33033. }
  33034. declare module BABYLON {
  33035. /**
  33036. * Class used to control physics engine
  33037. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33038. */
  33039. class PhysicsEngine implements IPhysicsEngine {
  33040. private _physicsPlugin;
  33041. /**
  33042. * Global value used to control the smallest number supported by the simulation
  33043. */
  33044. static Epsilon: number;
  33045. private _impostors;
  33046. private _joints;
  33047. /**
  33048. * Gets the gravity vector used by the simulation
  33049. */
  33050. gravity: Vector3;
  33051. /**
  33052. * Creates a new Physics Engine
  33053. * @param gravity defines the gravity vector used by the simulation
  33054. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  33055. */
  33056. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  33057. /**
  33058. * Sets the gravity vector used by the simulation
  33059. * @param gravity defines the gravity vector to use
  33060. */
  33061. setGravity(gravity: Vector3): void;
  33062. /**
  33063. * Set the time step of the physics engine.
  33064. * Default is 1/60.
  33065. * To slow it down, enter 1/600 for example.
  33066. * To speed it up, 1/30
  33067. * @param newTimeStep defines the new timestep to apply to this world.
  33068. */
  33069. setTimeStep(newTimeStep?: number): void;
  33070. /**
  33071. * Get the time step of the physics engine.
  33072. * @returns the current time step
  33073. */
  33074. getTimeStep(): number;
  33075. /**
  33076. * Release all resources
  33077. */
  33078. dispose(): void;
  33079. /**
  33080. * Gets the name of the current physics plugin
  33081. * @returns the name of the plugin
  33082. */
  33083. getPhysicsPluginName(): string;
  33084. /**
  33085. * Adding a new impostor for the impostor tracking.
  33086. * This will be done by the impostor itself.
  33087. * @param impostor the impostor to add
  33088. */
  33089. addImpostor(impostor: PhysicsImpostor): void;
  33090. /**
  33091. * Remove an impostor from the engine.
  33092. * This impostor and its mesh will not longer be updated by the physics engine.
  33093. * @param impostor the impostor to remove
  33094. */
  33095. removeImpostor(impostor: PhysicsImpostor): void;
  33096. /**
  33097. * Add a joint to the physics engine
  33098. * @param mainImpostor defines the main impostor to which the joint is added.
  33099. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33100. * @param joint defines the joint that will connect both impostors.
  33101. */
  33102. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33103. /**
  33104. * Removes a joint from the simulation
  33105. * @param mainImpostor defines the impostor used with the joint
  33106. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33107. * @param joint defines the joint to remove
  33108. */
  33109. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33110. /**
  33111. * Called by the scene. No need to call it.
  33112. * @param delta defines the timespam between frames
  33113. */
  33114. _step(delta: number): void;
  33115. /**
  33116. * Gets the current plugin used to run the simulation
  33117. * @returns current plugin
  33118. */
  33119. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33120. /**
  33121. * Gets the list of physic impostors
  33122. * @returns an array of PhysicsImpostor
  33123. */
  33124. getImpostors(): Array<PhysicsImpostor>;
  33125. /**
  33126. * Gets the impostor for a physics enabled object
  33127. * @param object defines the object impersonated by the impostor
  33128. * @returns the PhysicsImpostor or null if not found
  33129. */
  33130. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33131. /**
  33132. * Gets the impostor for a physics body object
  33133. * @param body defines physics body used by the impostor
  33134. * @returns the PhysicsImpostor or null if not found
  33135. */
  33136. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33137. }
  33138. }
  33139. declare module BABYLON {
  33140. interface Scene {
  33141. /** @hidden (Backing field) */
  33142. _physicsEngine: Nullable<IPhysicsEngine>;
  33143. /**
  33144. * Gets the current physics engine
  33145. * @returns a IPhysicsEngine or null if none attached
  33146. */
  33147. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  33148. /**
  33149. * Enables physics to the current scene
  33150. * @param gravity defines the scene's gravity for the physics engine
  33151. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  33152. * @return a boolean indicating if the physics engine was initialized
  33153. */
  33154. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  33155. /**
  33156. * Disables and disposes the physics engine associated with the scene
  33157. */
  33158. disablePhysicsEngine(): void;
  33159. /**
  33160. * Gets a boolean indicating if there is an active physics engine
  33161. * @returns a boolean indicating if there is an active physics engine
  33162. */
  33163. isPhysicsEnabled(): boolean;
  33164. /**
  33165. * Deletes a physics compound impostor
  33166. * @param compound defines the compound to delete
  33167. */
  33168. deleteCompoundImpostor(compound: any): void;
  33169. /**
  33170. * An event triggered when physic simulation is about to be run
  33171. */
  33172. onBeforePhysicsObservable: Observable<Scene>;
  33173. /**
  33174. * An event triggered when physic simulation has been done
  33175. */
  33176. onAfterPhysicsObservable: Observable<Scene>;
  33177. }
  33178. interface AbstractMesh {
  33179. /** @hidden */
  33180. _physicsImpostor: Nullable<PhysicsImpostor>;
  33181. /**
  33182. * Gets or sets impostor used for physic simulation
  33183. * @see http://doc.babylonjs.com/features/physics_engine
  33184. */
  33185. physicsImpostor: Nullable<PhysicsImpostor>;
  33186. /**
  33187. * Gets the current physics impostor
  33188. * @see http://doc.babylonjs.com/features/physics_engine
  33189. * @returns a physics impostor or null
  33190. */
  33191. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  33192. /** Apply a physic impulse to the mesh
  33193. * @param force defines the force to apply
  33194. * @param contactPoint defines where to apply the force
  33195. * @returns the current mesh
  33196. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33197. */
  33198. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  33199. /**
  33200. * Creates a physic joint between two meshes
  33201. * @param otherMesh defines the other mesh to use
  33202. * @param pivot1 defines the pivot to use on this mesh
  33203. * @param pivot2 defines the pivot to use on the other mesh
  33204. * @param options defines additional options (can be plugin dependent)
  33205. * @returns the current mesh
  33206. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  33207. */
  33208. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  33209. /** @hidden */
  33210. _disposePhysicsObserver: Nullable<Observer<Node>>;
  33211. }
  33212. /**
  33213. * Defines the physics engine scene component responsible to manage a physics engine
  33214. */
  33215. class PhysicsEngineSceneComponent implements ISceneComponent {
  33216. /**
  33217. * The component name helpful to identify the component in the list of scene components.
  33218. */
  33219. readonly name: string;
  33220. /**
  33221. * The scene the component belongs to.
  33222. */
  33223. scene: Scene;
  33224. /**
  33225. * Creates a new instance of the component for the given scene
  33226. * @param scene Defines the scene to register the component in
  33227. */
  33228. constructor(scene: Scene);
  33229. /**
  33230. * Registers the component in a given scene
  33231. */
  33232. register(): void;
  33233. /**
  33234. * Rebuilds the elements related to this component in case of
  33235. * context lost for instance.
  33236. */
  33237. rebuild(): void;
  33238. /**
  33239. * Disposes the component and the associated ressources
  33240. */
  33241. dispose(): void;
  33242. }
  33243. }
  33244. declare module BABYLON {
  33245. /**
  33246. * A helper for physics simulations
  33247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33248. */
  33249. class PhysicsHelper {
  33250. private _scene;
  33251. private _physicsEngine;
  33252. /**
  33253. * Initializes the Physics helper
  33254. * @param scene Babylon.js scene
  33255. */
  33256. constructor(scene: Scene);
  33257. /**
  33258. * Applies a radial explosion impulse
  33259. * @param origin the origin of the explosion
  33260. * @param radius the explosion radius
  33261. * @param strength the explosion strength
  33262. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33263. * @returns A physics radial explosion event, or null
  33264. */
  33265. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33266. /**
  33267. * Applies a radial explosion force
  33268. * @param origin the origin of the explosion
  33269. * @param radius the explosion radius
  33270. * @param strength the explosion strength
  33271. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33272. * @returns A physics radial explosion event, or null
  33273. */
  33274. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33275. /**
  33276. * Creates a gravitational field
  33277. * @param origin the origin of the explosion
  33278. * @param radius the explosion radius
  33279. * @param strength the explosion strength
  33280. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33281. * @returns A physics gravitational field event, or null
  33282. */
  33283. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  33284. /**
  33285. * Creates a physics updraft event
  33286. * @param origin the origin of the updraft
  33287. * @param radius the radius of the updraft
  33288. * @param strength the strength of the updraft
  33289. * @param height the height of the updraft
  33290. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  33291. * @returns A physics updraft event, or null
  33292. */
  33293. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  33294. /**
  33295. * Creates a physics vortex event
  33296. * @param origin the of the vortex
  33297. * @param radius the radius of the vortex
  33298. * @param strength the strength of the vortex
  33299. * @param height the height of the vortex
  33300. * @returns a Physics vortex event, or null
  33301. * A physics vortex event or null
  33302. */
  33303. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  33304. }
  33305. /**
  33306. * Represents a physics radial explosion event
  33307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33308. */
  33309. class PhysicsRadialExplosionEvent {
  33310. private _scene;
  33311. private _sphere;
  33312. private _sphereOptions;
  33313. private _rays;
  33314. private _dataFetched;
  33315. /**
  33316. * Initializes a radial explosioin event
  33317. * @param scene BabylonJS scene
  33318. */
  33319. constructor(scene: Scene);
  33320. /**
  33321. * Returns the data related to the radial explosion event (sphere & rays).
  33322. * @returns The radial explosion event data
  33323. */
  33324. getData(): PhysicsRadialExplosionEventData;
  33325. /**
  33326. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  33327. * @param impostor A physics imposter
  33328. * @param origin the origin of the explosion
  33329. * @param radius the explosion radius
  33330. * @param strength the explosion strength
  33331. * @param falloff possible options: Constant & Linear
  33332. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  33333. */
  33334. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  33335. /**
  33336. * Disposes the sphere.
  33337. * @param force Specifies if the sphere should be disposed by force
  33338. */
  33339. dispose(force?: boolean): void;
  33340. /*** Helpers ***/
  33341. private _prepareSphere;
  33342. private _intersectsWithSphere;
  33343. }
  33344. /**
  33345. * Represents a gravitational field event
  33346. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33347. */
  33348. class PhysicsGravitationalFieldEvent {
  33349. private _physicsHelper;
  33350. private _scene;
  33351. private _origin;
  33352. private _radius;
  33353. private _strength;
  33354. private _falloff;
  33355. private _tickCallback;
  33356. private _sphere;
  33357. private _dataFetched;
  33358. /**
  33359. * Initializes the physics gravitational field event
  33360. * @param physicsHelper A physics helper
  33361. * @param scene BabylonJS scene
  33362. * @param origin The origin position of the gravitational field event
  33363. * @param radius The radius of the gravitational field event
  33364. * @param strength The strength of the gravitational field event
  33365. * @param falloff The falloff for the gravitational field event
  33366. */
  33367. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  33368. /**
  33369. * Returns the data related to the gravitational field event (sphere).
  33370. * @returns A gravitational field event
  33371. */
  33372. getData(): PhysicsGravitationalFieldEventData;
  33373. /**
  33374. * Enables the gravitational field.
  33375. */
  33376. enable(): void;
  33377. /**
  33378. * Disables the gravitational field.
  33379. */
  33380. disable(): void;
  33381. /**
  33382. * Disposes the sphere.
  33383. * @param force The force to dispose from the gravitational field event
  33384. */
  33385. dispose(force?: boolean): void;
  33386. private _tick;
  33387. }
  33388. /**
  33389. * Represents a physics updraft event
  33390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33391. */
  33392. class PhysicsUpdraftEvent {
  33393. private _scene;
  33394. private _origin;
  33395. private _radius;
  33396. private _strength;
  33397. private _height;
  33398. private _updraftMode;
  33399. private _physicsEngine;
  33400. private _originTop;
  33401. private _originDirection;
  33402. private _tickCallback;
  33403. private _cylinder;
  33404. private _cylinderPosition;
  33405. private _dataFetched;
  33406. /**
  33407. * Initializes the physics updraft event
  33408. * @param _scene BabylonJS scene
  33409. * @param _origin The origin position of the updraft
  33410. * @param _radius The radius of the updraft
  33411. * @param _strength The strength of the updraft
  33412. * @param _height The height of the updraft
  33413. * @param _updraftMode The mode of the updraft
  33414. */
  33415. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  33416. /**
  33417. * Returns the data related to the updraft event (cylinder).
  33418. * @returns A physics updraft event
  33419. */
  33420. getData(): PhysicsUpdraftEventData;
  33421. /**
  33422. * Enables the updraft.
  33423. */
  33424. enable(): void;
  33425. /**
  33426. * Disables the cortex.
  33427. */
  33428. disable(): void;
  33429. /**
  33430. * Disposes the sphere.
  33431. * @param force Specifies if the updraft should be disposed by force
  33432. */
  33433. dispose(force?: boolean): void;
  33434. private getImpostorForceAndContactPoint;
  33435. private _tick;
  33436. /*** Helpers ***/
  33437. private _prepareCylinder;
  33438. private _intersectsWithCylinder;
  33439. }
  33440. /**
  33441. * Represents a physics vortex event
  33442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33443. */
  33444. class PhysicsVortexEvent {
  33445. private _scene;
  33446. private _origin;
  33447. private _radius;
  33448. private _strength;
  33449. private _height;
  33450. private _physicsEngine;
  33451. private _originTop;
  33452. private _centripetalForceThreshold;
  33453. private _updraftMultiplier;
  33454. private _tickCallback;
  33455. private _cylinder;
  33456. private _cylinderPosition;
  33457. private _dataFetched;
  33458. /**
  33459. * Initializes the physics vortex event
  33460. * @param _scene The BabylonJS scene
  33461. * @param _origin The origin position of the vortex
  33462. * @param _radius The radius of the vortex
  33463. * @param _strength The strength of the vortex
  33464. * @param _height The height of the vortex
  33465. */
  33466. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  33467. /**
  33468. * Returns the data related to the vortex event (cylinder).
  33469. * @returns The physics vortex event data
  33470. */
  33471. getData(): PhysicsVortexEventData;
  33472. /**
  33473. * Enables the vortex.
  33474. */
  33475. enable(): void;
  33476. /**
  33477. * Disables the cortex.
  33478. */
  33479. disable(): void;
  33480. /**
  33481. * Disposes the sphere.
  33482. * @param force
  33483. */
  33484. dispose(force?: boolean): void;
  33485. private getImpostorForceAndContactPoint;
  33486. private _tick;
  33487. /*** Helpers ***/
  33488. private _prepareCylinder;
  33489. private _intersectsWithCylinder;
  33490. }
  33491. /**
  33492. * The strenght of the force in correspondence to the distance of the affected object
  33493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33494. */
  33495. enum PhysicsRadialImpulseFalloff {
  33496. /** Defines that impulse is constant in strength across it's whole radius */
  33497. Constant = 0,
  33498. /** DEfines that impulse gets weaker if it's further from the origin */
  33499. Linear = 1
  33500. }
  33501. /**
  33502. * The strength of the force in correspondence to the distance of the affected object
  33503. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33504. */
  33505. enum PhysicsUpdraftMode {
  33506. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  33507. Center = 0,
  33508. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  33509. Perpendicular = 1
  33510. }
  33511. /**
  33512. * Interface for a physics force and contact point
  33513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33514. */
  33515. interface PhysicsForceAndContactPoint {
  33516. /**
  33517. * The force applied at the contact point
  33518. */
  33519. force: Vector3;
  33520. /**
  33521. * The contact point
  33522. */
  33523. contactPoint: Vector3;
  33524. }
  33525. /**
  33526. * Interface for radial explosion event data
  33527. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33528. */
  33529. interface PhysicsRadialExplosionEventData {
  33530. /**
  33531. * A sphere used for the radial explosion event
  33532. */
  33533. sphere: Mesh;
  33534. /**
  33535. * An array of rays for the radial explosion event
  33536. */
  33537. rays: Array<Ray>;
  33538. }
  33539. /**
  33540. * Interface for gravitational field event data
  33541. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33542. */
  33543. interface PhysicsGravitationalFieldEventData {
  33544. /**
  33545. * A sphere mesh used for the gravitational field event
  33546. */
  33547. sphere: Mesh;
  33548. }
  33549. /**
  33550. * Interface for updraft event data
  33551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33552. */
  33553. interface PhysicsUpdraftEventData {
  33554. /**
  33555. * A cylinder used for the updraft event
  33556. */
  33557. cylinder: Mesh;
  33558. }
  33559. /**
  33560. * Interface for vortex event data
  33561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33562. */
  33563. interface PhysicsVortexEventData {
  33564. /**
  33565. * A cylinder used for the vortex event
  33566. */
  33567. cylinder: Mesh;
  33568. }
  33569. }
  33570. declare module BABYLON {
  33571. /**
  33572. * The interface for the physics imposter parameters
  33573. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33574. */
  33575. interface PhysicsImpostorParameters {
  33576. /**
  33577. * The mass of the physics imposter
  33578. */
  33579. mass: number;
  33580. /**
  33581. * The friction of the physics imposter
  33582. */
  33583. friction?: number;
  33584. /**
  33585. * The coefficient of restitution of the physics imposter
  33586. */
  33587. restitution?: number;
  33588. /**
  33589. * The native options of the physics imposter
  33590. */
  33591. nativeOptions?: any;
  33592. /**
  33593. * Specifies if the parent should be ignored
  33594. */
  33595. ignoreParent?: boolean;
  33596. /**
  33597. * Specifies if bi-directional transformations should be disabled
  33598. */
  33599. disableBidirectionalTransformation?: boolean;
  33600. }
  33601. /**
  33602. * Interface for a physics-enabled object
  33603. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33604. */
  33605. interface IPhysicsEnabledObject {
  33606. /**
  33607. * The position of the physics-enabled object
  33608. */
  33609. position: Vector3;
  33610. /**
  33611. * The rotation of the physics-enabled object
  33612. */
  33613. rotationQuaternion: Nullable<Quaternion>;
  33614. /**
  33615. * The scale of the physics-enabled object
  33616. */
  33617. scaling: Vector3;
  33618. /**
  33619. * The rotation of the physics-enabled object
  33620. */
  33621. rotation?: Vector3;
  33622. /**
  33623. * The parent of the physics-enabled object
  33624. */
  33625. parent?: any;
  33626. /**
  33627. * The bounding info of the physics-enabled object
  33628. * @returns The bounding info of the physics-enabled object
  33629. */
  33630. getBoundingInfo(): BoundingInfo;
  33631. /**
  33632. * Computes the world matrix
  33633. * @param force Specifies if the world matrix should be computed by force
  33634. * @returns A world matrix
  33635. */
  33636. computeWorldMatrix(force: boolean): Matrix;
  33637. /**
  33638. * Gets the world matrix
  33639. * @returns A world matrix
  33640. */
  33641. getWorldMatrix?(): Matrix;
  33642. /**
  33643. * Gets the child meshes
  33644. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33645. * @returns An array of abstract meshes
  33646. */
  33647. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33648. /**
  33649. * Gets the vertex data
  33650. * @param kind The type of vertex data
  33651. * @returns A nullable array of numbers, or a float32 array
  33652. */
  33653. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33654. /**
  33655. * Gets the indices from the mesh
  33656. * @returns A nullable array of index arrays
  33657. */
  33658. getIndices?(): Nullable<IndicesArray>;
  33659. /**
  33660. * Gets the scene from the mesh
  33661. * @returns the indices array or null
  33662. */
  33663. getScene?(): Scene;
  33664. /**
  33665. * Gets the absolute position from the mesh
  33666. * @returns the absolute position
  33667. */
  33668. getAbsolutePosition(): Vector3;
  33669. /**
  33670. * Gets the absolute pivot point from the mesh
  33671. * @returns the absolute pivot point
  33672. */
  33673. getAbsolutePivotPoint(): Vector3;
  33674. /**
  33675. * Rotates the mesh
  33676. * @param axis The axis of rotation
  33677. * @param amount The amount of rotation
  33678. * @param space The space of the rotation
  33679. * @returns The rotation transform node
  33680. */
  33681. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33682. /**
  33683. * Translates the mesh
  33684. * @param axis The axis of translation
  33685. * @param distance The distance of translation
  33686. * @param space The space of the translation
  33687. * @returns The transform node
  33688. */
  33689. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33690. /**
  33691. * Sets the absolute position of the mesh
  33692. * @param absolutePosition The absolute position of the mesh
  33693. * @returns The transform node
  33694. */
  33695. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33696. /**
  33697. * Gets the class name of the mesh
  33698. * @returns The class name
  33699. */
  33700. getClassName(): string;
  33701. }
  33702. /**
  33703. * Represents a physics imposter
  33704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33705. */
  33706. class PhysicsImpostor {
  33707. /**
  33708. * The physics-enabled object used as the physics imposter
  33709. */
  33710. object: IPhysicsEnabledObject;
  33711. /**
  33712. * The type of the physics imposter
  33713. */
  33714. type: number;
  33715. private _options;
  33716. private _scene?;
  33717. /**
  33718. * The default object size of the imposter
  33719. */
  33720. static DEFAULT_OBJECT_SIZE: Vector3;
  33721. /**
  33722. * The identity quaternion of the imposter
  33723. */
  33724. static IDENTITY_QUATERNION: Quaternion;
  33725. private _physicsEngine;
  33726. private _physicsBody;
  33727. private _bodyUpdateRequired;
  33728. private _onBeforePhysicsStepCallbacks;
  33729. private _onAfterPhysicsStepCallbacks;
  33730. private _onPhysicsCollideCallbacks;
  33731. private _deltaPosition;
  33732. private _deltaRotation;
  33733. private _deltaRotationConjugated;
  33734. private _parent;
  33735. private _isDisposed;
  33736. private static _tmpVecs;
  33737. private static _tmpQuat;
  33738. /**
  33739. * Specifies if the physics imposter is disposed
  33740. */
  33741. readonly isDisposed: boolean;
  33742. /**
  33743. * Gets the mass of the physics imposter
  33744. */
  33745. mass: number;
  33746. /**
  33747. * Gets the coefficient of friction
  33748. */
  33749. /**
  33750. * Sets the coefficient of friction
  33751. */
  33752. friction: number;
  33753. /**
  33754. * Gets the coefficient of restitution
  33755. */
  33756. /**
  33757. * Sets the coefficient of restitution
  33758. */
  33759. restitution: number;
  33760. /**
  33761. * The unique id of the physics imposter
  33762. * set by the physics engine when adding this impostor to the array
  33763. */
  33764. uniqueId: number;
  33765. private _joints;
  33766. /**
  33767. * Initializes the physics imposter
  33768. * @param object The physics-enabled object used as the physics imposter
  33769. * @param type The type of the physics imposter
  33770. * @param _options The options for the physics imposter
  33771. * @param _scene The Babylon scene
  33772. */
  33773. constructor(
  33774. /**
  33775. * The physics-enabled object used as the physics imposter
  33776. */
  33777. object: IPhysicsEnabledObject,
  33778. /**
  33779. * The type of the physics imposter
  33780. */
  33781. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33782. /**
  33783. * This function will completly initialize this impostor.
  33784. * It will create a new body - but only if this mesh has no parent.
  33785. * If it has, this impostor will not be used other than to define the impostor
  33786. * of the child mesh.
  33787. * @hidden
  33788. */
  33789. _init(): void;
  33790. private _getPhysicsParent;
  33791. /**
  33792. * Should a new body be generated.
  33793. * @returns boolean specifying if body initialization is required
  33794. */
  33795. isBodyInitRequired(): boolean;
  33796. /**
  33797. * Sets the updated scaling
  33798. * @param updated Specifies if the scaling is updated
  33799. */
  33800. setScalingUpdated(updated: boolean): void;
  33801. /**
  33802. * Force a regeneration of this or the parent's impostor's body.
  33803. * Use under cautious - This will remove all joints already implemented.
  33804. */
  33805. forceUpdate(): void;
  33806. /**
  33807. * Gets the body that holds this impostor. Either its own, or its parent.
  33808. */
  33809. /**
  33810. * Set the physics body. Used mainly by the physics engine/plugin
  33811. */
  33812. physicsBody: any;
  33813. /**
  33814. * Get the parent of the physics imposter
  33815. * @returns Physics imposter or null
  33816. */
  33817. /**
  33818. * Sets the parent of the physics imposter
  33819. */
  33820. parent: Nullable<PhysicsImpostor>;
  33821. /**
  33822. * Resets the update flags
  33823. */
  33824. resetUpdateFlags(): void;
  33825. /**
  33826. * Gets the object extend size
  33827. * @returns the object extend size
  33828. */
  33829. getObjectExtendSize(): Vector3;
  33830. /**
  33831. * Gets the object center
  33832. * @returns The object center
  33833. */
  33834. getObjectCenter(): Vector3;
  33835. /**
  33836. * Get a specific parametes from the options parameter
  33837. * @param paramName The object parameter name
  33838. * @returns The object parameter
  33839. */
  33840. getParam(paramName: string): any;
  33841. /**
  33842. * Sets a specific parameter in the options given to the physics plugin
  33843. * @param paramName The parameter name
  33844. * @param value The value of the parameter
  33845. */
  33846. setParam(paramName: string, value: number): void;
  33847. /**
  33848. * Specifically change the body's mass option. Won't recreate the physics body object
  33849. * @param mass The mass of the physics imposter
  33850. */
  33851. setMass(mass: number): void;
  33852. /**
  33853. * Gets the linear velocity
  33854. * @returns linear velocity or null
  33855. */
  33856. getLinearVelocity(): Nullable<Vector3>;
  33857. /**
  33858. * Sets the linear velocity
  33859. * @param velocity linear velocity or null
  33860. */
  33861. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33862. /**
  33863. * Gets the angular velocity
  33864. * @returns angular velocity or null
  33865. */
  33866. getAngularVelocity(): Nullable<Vector3>;
  33867. /**
  33868. * Sets the angular velocity
  33869. * @param velocity The velocity or null
  33870. */
  33871. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33872. /**
  33873. * Execute a function with the physics plugin native code
  33874. * Provide a function the will have two variables - the world object and the physics body object
  33875. * @param func The function to execute with the physics plugin native code
  33876. */
  33877. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33878. /**
  33879. * Register a function that will be executed before the physics world is stepping forward
  33880. * @param func The function to execute before the physics world is stepped forward
  33881. */
  33882. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33883. /**
  33884. * Unregister a function that will be executed before the physics world is stepping forward
  33885. * @param func The function to execute before the physics world is stepped forward
  33886. */
  33887. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33888. /**
  33889. * Register a function that will be executed after the physics step
  33890. * @param func The function to execute after physics step
  33891. */
  33892. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33893. /**
  33894. * Unregisters a function that will be executed after the physics step
  33895. * @param func The function to execute after physics step
  33896. */
  33897. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33898. /**
  33899. * register a function that will be executed when this impostor collides against a different body
  33900. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33901. * @param func Callback that is executed on collision
  33902. */
  33903. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33904. /**
  33905. * Unregisters the physics imposter on contact
  33906. * @param collideAgainst The physics object to collide against
  33907. * @param func Callback to execute on collision
  33908. */
  33909. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33910. private _tmpQuat;
  33911. private _tmpQuat2;
  33912. /**
  33913. * Get the parent rotation
  33914. * @returns The parent rotation
  33915. */
  33916. getParentsRotation(): Quaternion;
  33917. /**
  33918. * this function is executed by the physics engine.
  33919. */
  33920. beforeStep: () => void;
  33921. /**
  33922. * this function is executed by the physics engine
  33923. */
  33924. afterStep: () => void;
  33925. /**
  33926. * Legacy collision detection event support
  33927. */
  33928. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33929. /**
  33930. * event and body object due to cannon's event-based architecture.
  33931. */
  33932. onCollide: (e: {
  33933. body: any;
  33934. }) => void;
  33935. /**
  33936. * Apply a force
  33937. * @param force The force to apply
  33938. * @param contactPoint The contact point for the force
  33939. * @returns The physics imposter
  33940. */
  33941. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33942. /**
  33943. * Apply an impulse
  33944. * @param force The impulse force
  33945. * @param contactPoint The contact point for the impulse force
  33946. * @returns The physics imposter
  33947. */
  33948. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33949. /**
  33950. * A help function to create a joint
  33951. * @param otherImpostor A physics imposter used to create a joint
  33952. * @param jointType The type of joint
  33953. * @param jointData The data for the joint
  33954. * @returns The physics imposter
  33955. */
  33956. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33957. /**
  33958. * Add a joint to this impostor with a different impostor
  33959. * @param otherImpostor A physics imposter used to add a joint
  33960. * @param joint The joint to add
  33961. * @returns The physics imposter
  33962. */
  33963. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33964. /**
  33965. * Will keep this body still, in a sleep mode.
  33966. * @returns the physics imposter
  33967. */
  33968. sleep(): PhysicsImpostor;
  33969. /**
  33970. * Wake the body up.
  33971. * @returns The physics imposter
  33972. */
  33973. wakeUp(): PhysicsImpostor;
  33974. /**
  33975. * Clones the physics imposter
  33976. * @param newObject The physics imposter clones to this physics-enabled object
  33977. * @returns A nullable physics imposter
  33978. */
  33979. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33980. /**
  33981. * Disposes the physics imposter
  33982. */
  33983. dispose(): void;
  33984. /**
  33985. * Sets the delta position
  33986. * @param position The delta position amount
  33987. */
  33988. setDeltaPosition(position: Vector3): void;
  33989. /**
  33990. * Sets the delta rotation
  33991. * @param rotation The delta rotation amount
  33992. */
  33993. setDeltaRotation(rotation: Quaternion): void;
  33994. /**
  33995. * Gets the box size of the physics imposter and stores the result in the input parameter
  33996. * @param result Stores the box size
  33997. * @returns The physics imposter
  33998. */
  33999. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  34000. /**
  34001. * Gets the radius of the physics imposter
  34002. * @returns Radius of the physics imposter
  34003. */
  34004. getRadius(): number;
  34005. /**
  34006. * Sync a bone with this impostor
  34007. * @param bone The bone to sync to the impostor.
  34008. * @param boneMesh The mesh that the bone is influencing.
  34009. * @param jointPivot The pivot of the joint / bone in local space.
  34010. * @param distToJoint Optional distance from the impostor to the joint.
  34011. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34012. */
  34013. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  34014. /**
  34015. * Sync impostor to a bone
  34016. * @param bone The bone that the impostor will be synced to.
  34017. * @param boneMesh The mesh that the bone is influencing.
  34018. * @param jointPivot The pivot of the joint / bone in local space.
  34019. * @param distToJoint Optional distance from the impostor to the joint.
  34020. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34021. * @param boneAxis Optional vector3 axis the bone is aligned with
  34022. */
  34023. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  34024. /**
  34025. * No-Imposter type
  34026. */
  34027. static NoImpostor: number;
  34028. /**
  34029. * Sphere-Imposter type
  34030. */
  34031. static SphereImpostor: number;
  34032. /**
  34033. * Box-Imposter type
  34034. */
  34035. static BoxImpostor: number;
  34036. /**
  34037. * Plane-Imposter type
  34038. */
  34039. static PlaneImpostor: number;
  34040. /**
  34041. * Mesh-imposter type
  34042. */
  34043. static MeshImpostor: number;
  34044. /**
  34045. * Cylinder-Imposter type
  34046. */
  34047. static CylinderImpostor: number;
  34048. /**
  34049. * Particle-Imposter type
  34050. */
  34051. static ParticleImpostor: number;
  34052. /**
  34053. * Heightmap-Imposter type
  34054. */
  34055. static HeightmapImpostor: number;
  34056. }
  34057. }
  34058. declare module BABYLON {
  34059. /**
  34060. * Interface for Physics-Joint data
  34061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34062. */
  34063. interface PhysicsJointData {
  34064. /**
  34065. * The main pivot of the joint
  34066. */
  34067. mainPivot?: Vector3;
  34068. /**
  34069. * The connected pivot of the joint
  34070. */
  34071. connectedPivot?: Vector3;
  34072. /**
  34073. * The main axis of the joint
  34074. */
  34075. mainAxis?: Vector3;
  34076. /**
  34077. * The connected axis of the joint
  34078. */
  34079. connectedAxis?: Vector3;
  34080. /**
  34081. * The collision of the joint
  34082. */
  34083. collision?: boolean;
  34084. /**
  34085. * Native Oimo/Cannon/Energy data
  34086. */
  34087. nativeParams?: any;
  34088. }
  34089. /**
  34090. * This is a holder class for the physics joint created by the physics plugin
  34091. * It holds a set of functions to control the underlying joint
  34092. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34093. */
  34094. class PhysicsJoint {
  34095. /**
  34096. * The type of the physics joint
  34097. */
  34098. type: number;
  34099. /**
  34100. * The data for the physics joint
  34101. */
  34102. jointData: PhysicsJointData;
  34103. private _physicsJoint;
  34104. protected _physicsPlugin: IPhysicsEnginePlugin;
  34105. /**
  34106. * Initializes the physics joint
  34107. * @param type The type of the physics joint
  34108. * @param jointData The data for the physics joint
  34109. */
  34110. constructor(
  34111. /**
  34112. * The type of the physics joint
  34113. */
  34114. type: number,
  34115. /**
  34116. * The data for the physics joint
  34117. */
  34118. jointData: PhysicsJointData);
  34119. /**
  34120. * Gets the physics joint
  34121. */
  34122. /**
  34123. * Sets the physics joint
  34124. */
  34125. physicsJoint: any;
  34126. /**
  34127. * Sets the physics plugin
  34128. */
  34129. physicsPlugin: IPhysicsEnginePlugin;
  34130. /**
  34131. * Execute a function that is physics-plugin specific.
  34132. * @param {Function} func the function that will be executed.
  34133. * It accepts two parameters: the physics world and the physics joint
  34134. */
  34135. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  34136. /**
  34137. * Distance-Joint type
  34138. */
  34139. static DistanceJoint: number;
  34140. /**
  34141. * Hinge-Joint type
  34142. */
  34143. static HingeJoint: number;
  34144. /**
  34145. * Ball-and-Socket joint type
  34146. */
  34147. static BallAndSocketJoint: number;
  34148. /**
  34149. * Wheel-Joint type
  34150. */
  34151. static WheelJoint: number;
  34152. /**
  34153. * Slider-Joint type
  34154. */
  34155. static SliderJoint: number;
  34156. /**
  34157. * Prismatic-Joint type
  34158. */
  34159. static PrismaticJoint: number;
  34160. /**
  34161. * Universal-Joint type
  34162. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  34163. */
  34164. static UniversalJoint: number;
  34165. /**
  34166. * Hinge-Joint 2 type
  34167. */
  34168. static Hinge2Joint: number;
  34169. /**
  34170. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  34171. */
  34172. static PointToPointJoint: number;
  34173. /**
  34174. * Spring-Joint type
  34175. */
  34176. static SpringJoint: number;
  34177. /**
  34178. * Lock-Joint type
  34179. */
  34180. static LockJoint: number;
  34181. }
  34182. /**
  34183. * A class representing a physics distance joint
  34184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34185. */
  34186. class DistanceJoint extends PhysicsJoint {
  34187. /**
  34188. *
  34189. * @param jointData The data for the Distance-Joint
  34190. */
  34191. constructor(jointData: DistanceJointData);
  34192. /**
  34193. * Update the predefined distance.
  34194. * @param maxDistance The maximum preferred distance
  34195. * @param minDistance The minimum preferred distance
  34196. */
  34197. updateDistance(maxDistance: number, minDistance?: number): void;
  34198. }
  34199. /**
  34200. * Represents a Motor-Enabled Joint
  34201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34202. */
  34203. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  34204. /**
  34205. * Initializes the Motor-Enabled Joint
  34206. * @param type The type of the joint
  34207. * @param jointData The physica joint data for the joint
  34208. */
  34209. constructor(type: number, jointData: PhysicsJointData);
  34210. /**
  34211. * Set the motor values.
  34212. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34213. * @param force the force to apply
  34214. * @param maxForce max force for this motor.
  34215. */
  34216. setMotor(force?: number, maxForce?: number): void;
  34217. /**
  34218. * Set the motor's limits.
  34219. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34220. * @param upperLimit The upper limit of the motor
  34221. * @param lowerLimit The lower limit of the motor
  34222. */
  34223. setLimit(upperLimit: number, lowerLimit?: number): void;
  34224. }
  34225. /**
  34226. * This class represents a single physics Hinge-Joint
  34227. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34228. */
  34229. class HingeJoint extends MotorEnabledJoint {
  34230. /**
  34231. * Initializes the Hinge-Joint
  34232. * @param jointData The joint data for the Hinge-Joint
  34233. */
  34234. constructor(jointData: PhysicsJointData);
  34235. /**
  34236. * Set the motor values.
  34237. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34238. * @param {number} force the force to apply
  34239. * @param {number} maxForce max force for this motor.
  34240. */
  34241. setMotor(force?: number, maxForce?: number): void;
  34242. /**
  34243. * Set the motor's limits.
  34244. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34245. * @param upperLimit The upper limit of the motor
  34246. * @param lowerLimit The lower limit of the motor
  34247. */
  34248. setLimit(upperLimit: number, lowerLimit?: number): void;
  34249. }
  34250. /**
  34251. * This class represents a dual hinge physics joint (same as wheel joint)
  34252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34253. */
  34254. class Hinge2Joint extends MotorEnabledJoint {
  34255. /**
  34256. * Initializes the Hinge2-Joint
  34257. * @param jointData The joint data for the Hinge2-Joint
  34258. */
  34259. constructor(jointData: PhysicsJointData);
  34260. /**
  34261. * Set the motor values.
  34262. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34263. * @param {number} force the force to apply
  34264. * @param {number} maxForce max force for this motor.
  34265. * @param {motorIndex} the motor's index, 0 or 1.
  34266. */
  34267. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34268. /**
  34269. * Set the motor limits.
  34270. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34271. * @param {number} upperLimit the upper limit
  34272. * @param {number} lowerLimit lower limit
  34273. * @param {motorIndex} the motor's index, 0 or 1.
  34274. */
  34275. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34276. }
  34277. /**
  34278. * Interface for a motor enabled joint
  34279. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34280. */
  34281. interface IMotorEnabledJoint {
  34282. /**
  34283. * Physics joint
  34284. */
  34285. physicsJoint: any;
  34286. /**
  34287. * Sets the motor of the motor-enabled joint
  34288. * @param force The force of the motor
  34289. * @param maxForce The maximum force of the motor
  34290. * @param motorIndex The index of the motor
  34291. */
  34292. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34293. /**
  34294. * Sets the limit of the motor
  34295. * @param upperLimit The upper limit of the motor
  34296. * @param lowerLimit The lower limit of the motor
  34297. * @param motorIndex The index of the motor
  34298. */
  34299. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34300. }
  34301. /**
  34302. * Joint data for a Distance-Joint
  34303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34304. */
  34305. interface DistanceJointData extends PhysicsJointData {
  34306. /**
  34307. * Max distance the 2 joint objects can be apart
  34308. */
  34309. maxDistance: number;
  34310. }
  34311. /**
  34312. * Joint data from a spring joint
  34313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34314. */
  34315. interface SpringJointData extends PhysicsJointData {
  34316. /**
  34317. * Length of the spring
  34318. */
  34319. length: number;
  34320. /**
  34321. * Stiffness of the spring
  34322. */
  34323. stiffness: number;
  34324. /**
  34325. * Damping of the spring
  34326. */
  34327. damping: number;
  34328. /** this callback will be called when applying the force to the impostors. */
  34329. forceApplicationCallback: () => void;
  34330. }
  34331. }
  34332. declare module BABYLON {
  34333. interface AbstractScene {
  34334. /**
  34335. * The list of reflection probes added to the scene
  34336. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34337. */
  34338. reflectionProbes: Array<ReflectionProbe>;
  34339. /**
  34340. * Removes the given reflection probe from this scene.
  34341. * @param toRemove The reflection probe to remove
  34342. * @returns The index of the removed reflection probe
  34343. */
  34344. removeReflectionProbe(toRemove: ReflectionProbe): number;
  34345. /**
  34346. * Adds the given reflection probe to this scene.
  34347. * @param newReflectionProbe The reflection probe to add
  34348. */
  34349. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  34350. }
  34351. /**
  34352. * Class used to generate realtime reflection / refraction cube textures
  34353. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34354. */
  34355. class ReflectionProbe {
  34356. /** defines the name of the probe */
  34357. name: string;
  34358. private _scene;
  34359. private _renderTargetTexture;
  34360. private _projectionMatrix;
  34361. private _viewMatrix;
  34362. private _target;
  34363. private _add;
  34364. private _attachedMesh;
  34365. private _invertYAxis;
  34366. /** Gets or sets probe position (center of the cube map) */
  34367. position: Vector3;
  34368. /**
  34369. * Creates a new reflection probe
  34370. * @param name defines the name of the probe
  34371. * @param size defines the texture resolution (for each face)
  34372. * @param scene defines the hosting scene
  34373. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  34374. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  34375. */
  34376. constructor(
  34377. /** defines the name of the probe */
  34378. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  34379. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  34380. samples: number;
  34381. /** Gets or sets the refresh rate to use (on every frame by default) */
  34382. refreshRate: number;
  34383. /**
  34384. * Gets the hosting scene
  34385. * @returns a Scene
  34386. */
  34387. getScene(): Scene;
  34388. /** Gets the internal CubeTexture used to render to */
  34389. readonly cubeTexture: RenderTargetTexture;
  34390. /** Gets the list of meshes to render */
  34391. readonly renderList: Nullable<AbstractMesh[]>;
  34392. /**
  34393. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  34394. * @param mesh defines the mesh to attach to
  34395. */
  34396. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  34397. /**
  34398. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  34399. * @param renderingGroupId The rendering group id corresponding to its index
  34400. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34401. */
  34402. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34403. /**
  34404. * Clean all associated resources
  34405. */
  34406. dispose(): void;
  34407. /**
  34408. * Converts the reflection probe information to a readable string for debug purpose.
  34409. * @param fullDetails Supports for multiple levels of logging within scene loading
  34410. * @returns the human readable reflection probe info
  34411. */
  34412. toString(fullDetails?: boolean): string;
  34413. /**
  34414. * Get the class name of the relfection probe.
  34415. * @returns "ReflectionProbe"
  34416. */
  34417. getClassName(): string;
  34418. /**
  34419. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  34420. * @returns The JSON representation of the texture
  34421. */
  34422. serialize(): any;
  34423. /**
  34424. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  34425. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  34426. * @param scene Define the scene the parsed reflection probe should be instantiated in
  34427. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  34428. * @returns The parsed reflection probe if successful
  34429. */
  34430. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  34431. }
  34432. }
  34433. declare module BABYLON {
  34434. interface Scene {
  34435. /** @hidden (Backing field) */
  34436. _boundingBoxRenderer: BoundingBoxRenderer;
  34437. /** @hidden (Backing field) */
  34438. _forceShowBoundingBoxes: boolean;
  34439. /**
  34440. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  34441. */
  34442. forceShowBoundingBoxes: boolean;
  34443. /**
  34444. * Gets the bounding box renderer associated with the scene
  34445. * @returns a BoundingBoxRenderer
  34446. */
  34447. getBoundingBoxRenderer(): BoundingBoxRenderer;
  34448. }
  34449. interface AbstractMesh {
  34450. /** @hidden (Backing field) */
  34451. _showBoundingBox: boolean;
  34452. /**
  34453. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  34454. */
  34455. showBoundingBox: boolean;
  34456. }
  34457. /**
  34458. * Component responsible of rendering the bounding box of the meshes in a scene.
  34459. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  34460. */
  34461. class BoundingBoxRenderer implements ISceneComponent {
  34462. /**
  34463. * The component name helpfull to identify the component in the list of scene components.
  34464. */
  34465. readonly name: string;
  34466. /**
  34467. * The scene the component belongs to.
  34468. */
  34469. scene: Scene;
  34470. /**
  34471. * Color of the bounding box lines placed in front of an object
  34472. */
  34473. frontColor: Color3;
  34474. /**
  34475. * Color of the bounding box lines placed behind an object
  34476. */
  34477. backColor: Color3;
  34478. /**
  34479. * Defines if the renderer should show the back lines or not
  34480. */
  34481. showBackLines: boolean;
  34482. /**
  34483. * @hidden
  34484. */
  34485. renderList: SmartArray<BoundingBox>;
  34486. private _colorShader;
  34487. private _vertexBuffers;
  34488. private _indexBuffer;
  34489. /**
  34490. * Instantiates a new bounding box renderer in a scene.
  34491. * @param scene the scene the renderer renders in
  34492. */
  34493. constructor(scene: Scene);
  34494. /**
  34495. * Registers the component in a given scene
  34496. */
  34497. register(): void;
  34498. private _evaluateSubMesh;
  34499. private _activeMesh;
  34500. private _prepareRessources;
  34501. private _createIndexBuffer;
  34502. /**
  34503. * Rebuilds the elements related to this component in case of
  34504. * context lost for instance.
  34505. */
  34506. rebuild(): void;
  34507. /**
  34508. * @hidden
  34509. */
  34510. reset(): void;
  34511. /**
  34512. * Render the bounding boxes of a specific rendering group
  34513. * @param renderingGroupId defines the rendering group to render
  34514. */
  34515. render(renderingGroupId: number): void;
  34516. /**
  34517. * In case of occlusion queries, we can render the occlusion bounding box through this method
  34518. * @param mesh Define the mesh to render the occlusion bounding box for
  34519. */
  34520. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  34521. /**
  34522. * Dispose and release the resources attached to this renderer.
  34523. */
  34524. dispose(): void;
  34525. }
  34526. }
  34527. declare module BABYLON {
  34528. /**
  34529. * This represents a depth renderer in Babylon.
  34530. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  34531. */
  34532. class DepthRenderer {
  34533. private _scene;
  34534. private _depthMap;
  34535. private _effect;
  34536. private _cachedDefines;
  34537. private _camera;
  34538. /**
  34539. * Specifiess that the depth renderer will only be used within
  34540. * the camera it is created for.
  34541. * This can help forcing its rendering during the camera processing.
  34542. */
  34543. useOnlyInActiveCamera: boolean;
  34544. /**
  34545. * Instantiates a depth renderer
  34546. * @param scene The scene the renderer belongs to
  34547. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  34548. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  34549. */
  34550. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  34551. /**
  34552. * Creates the depth rendering effect and checks if the effect is ready.
  34553. * @param subMesh The submesh to be used to render the depth map of
  34554. * @param useInstances If multiple world instances should be used
  34555. * @returns if the depth renderer is ready to render the depth map
  34556. */
  34557. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34558. /**
  34559. * Gets the texture which the depth map will be written to.
  34560. * @returns The depth map texture
  34561. */
  34562. getDepthMap(): RenderTargetTexture;
  34563. /**
  34564. * Disposes of the depth renderer.
  34565. */
  34566. dispose(): void;
  34567. }
  34568. }
  34569. declare module BABYLON {
  34570. interface Scene {
  34571. /** @hidden (Backing field) */
  34572. _depthRenderer: {
  34573. [id: string]: DepthRenderer;
  34574. };
  34575. /**
  34576. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  34577. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  34578. * @returns the created depth renderer
  34579. */
  34580. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  34581. /**
  34582. * Disables a depth renderer for a given camera
  34583. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  34584. */
  34585. disableDepthRenderer(camera?: Nullable<Camera>): void;
  34586. }
  34587. /**
  34588. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  34589. * in several rendering techniques.
  34590. */
  34591. class DepthRendererSceneComponent implements ISceneComponent {
  34592. /**
  34593. * The component name helpfull to identify the component in the list of scene components.
  34594. */
  34595. readonly name: string;
  34596. /**
  34597. * The scene the component belongs to.
  34598. */
  34599. scene: Scene;
  34600. /**
  34601. * Creates a new instance of the component for the given scene
  34602. * @param scene Defines the scene to register the component in
  34603. */
  34604. constructor(scene: Scene);
  34605. /**
  34606. * Registers the component in a given scene
  34607. */
  34608. register(): void;
  34609. /**
  34610. * Rebuilds the elements related to this component in case of
  34611. * context lost for instance.
  34612. */
  34613. rebuild(): void;
  34614. /**
  34615. * Disposes the component and the associated ressources
  34616. */
  34617. dispose(): void;
  34618. private _gatherRenderTargets;
  34619. private _gatherActiveCameraRenderTargets;
  34620. }
  34621. }
  34622. declare module BABYLON {
  34623. interface AbstractMesh {
  34624. /**
  34625. * Disables the mesh edge rendering mode
  34626. * @returns the currentAbstractMesh
  34627. */
  34628. disableEdgesRendering(): AbstractMesh;
  34629. /**
  34630. * Enables the edge rendering mode on the mesh.
  34631. * This mode makes the mesh edges visible
  34632. * @param epsilon defines the maximal distance between two angles to detect a face
  34633. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34634. * @returns the currentAbstractMesh
  34635. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34636. */
  34637. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34638. /**
  34639. * Gets the edgesRenderer associated with the mesh
  34640. */
  34641. edgesRenderer: Nullable<EdgesRenderer>;
  34642. }
  34643. interface LinesMesh {
  34644. /**
  34645. * Enables the edge rendering mode on the mesh.
  34646. * This mode makes the mesh edges visible
  34647. * @param epsilon defines the maximal distance between two angles to detect a face
  34648. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34649. * @returns the currentAbstractMesh
  34650. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34651. */
  34652. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34653. }
  34654. interface InstancedLinesMesh {
  34655. /**
  34656. * Enables the edge rendering mode on the mesh.
  34657. * This mode makes the mesh edges visible
  34658. * @param epsilon defines the maximal distance between two angles to detect a face
  34659. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34660. * @returns the current InstancedLinesMesh
  34661. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34662. */
  34663. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  34664. }
  34665. /**
  34666. * Defines the minimum contract an Edges renderer should follow.
  34667. */
  34668. interface IEdgesRenderer extends IDisposable {
  34669. /**
  34670. * Gets or sets a boolean indicating if the edgesRenderer is active
  34671. */
  34672. isEnabled: boolean;
  34673. /**
  34674. * Renders the edges of the attached mesh,
  34675. */
  34676. render(): void;
  34677. /**
  34678. * Checks wether or not the edges renderer is ready to render.
  34679. * @return true if ready, otherwise false.
  34680. */
  34681. isReady(): boolean;
  34682. }
  34683. /**
  34684. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  34685. */
  34686. class EdgesRenderer implements IEdgesRenderer {
  34687. /**
  34688. * Define the size of the edges with an orthographic camera
  34689. */
  34690. edgesWidthScalerForOrthographic: number;
  34691. /**
  34692. * Define the size of the edges with a perspective camera
  34693. */
  34694. edgesWidthScalerForPerspective: number;
  34695. protected _source: AbstractMesh;
  34696. protected _linesPositions: number[];
  34697. protected _linesNormals: number[];
  34698. protected _linesIndices: number[];
  34699. protected _epsilon: number;
  34700. protected _indicesCount: number;
  34701. protected _lineShader: ShaderMaterial;
  34702. protected _ib: WebGLBuffer;
  34703. protected _buffers: {
  34704. [key: string]: Nullable<VertexBuffer>;
  34705. };
  34706. protected _checkVerticesInsteadOfIndices: boolean;
  34707. private _meshRebuildObserver;
  34708. private _meshDisposeObserver;
  34709. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  34710. isEnabled: boolean;
  34711. /**
  34712. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  34713. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  34714. * @param source Mesh used to create edges
  34715. * @param epsilon sum of angles in adjacency to check for edge
  34716. * @param checkVerticesInsteadOfIndices
  34717. * @param generateEdgesLines - should generate Lines or only prepare resources.
  34718. */
  34719. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  34720. protected _prepareRessources(): void;
  34721. /** @hidden */
  34722. _rebuild(): void;
  34723. /**
  34724. * Releases the required resources for the edges renderer
  34725. */
  34726. dispose(): void;
  34727. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  34728. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  34729. /**
  34730. * Checks if the pair of p0 and p1 is en edge
  34731. * @param faceIndex
  34732. * @param edge
  34733. * @param faceNormals
  34734. * @param p0
  34735. * @param p1
  34736. * @private
  34737. */
  34738. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  34739. /**
  34740. * push line into the position, normal and index buffer
  34741. * @protected
  34742. */
  34743. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  34744. /**
  34745. * Generates lines edges from adjacencjes
  34746. * @private
  34747. */
  34748. _generateEdgesLines(): void;
  34749. /**
  34750. * Checks wether or not the edges renderer is ready to render.
  34751. * @return true if ready, otherwise false.
  34752. */
  34753. isReady(): boolean;
  34754. /**
  34755. * Renders the edges of the attached mesh,
  34756. */
  34757. render(): void;
  34758. }
  34759. }
  34760. declare module BABYLON {
  34761. /**
  34762. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  34763. */
  34764. class GeometryBufferRenderer {
  34765. /**
  34766. * Constant used to retrieve the position texture index in the G-Buffer textures array
  34767. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  34768. */
  34769. static readonly POSITION_TEXTURE_TYPE: number;
  34770. /**
  34771. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  34772. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  34773. */
  34774. static readonly VELOCITY_TEXTURE_TYPE: number;
  34775. /**
  34776. * Dictionary used to store the previous transformation matrices of each rendered mesh
  34777. * in order to compute objects velocities when enableVelocity is set to "true"
  34778. * @hidden
  34779. */
  34780. _previousTransformationMatrices: {
  34781. [index: number]: Matrix;
  34782. };
  34783. private _scene;
  34784. private _multiRenderTarget;
  34785. private _ratio;
  34786. private _enablePosition;
  34787. private _enableVelocity;
  34788. private _positionIndex;
  34789. private _velocityIndex;
  34790. protected _effect: Effect;
  34791. protected _cachedDefines: string;
  34792. /**
  34793. * Set the render list (meshes to be rendered) used in the G buffer.
  34794. */
  34795. renderList: Mesh[];
  34796. /**
  34797. * Gets wether or not G buffer are supported by the running hardware.
  34798. * This requires draw buffer supports
  34799. */
  34800. readonly isSupported: boolean;
  34801. /**
  34802. * Returns the index of the given texture type in the G-Buffer textures array
  34803. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  34804. * @returns the index of the given texture type in the G-Buffer textures array
  34805. */
  34806. getTextureIndex(textureType: number): number;
  34807. /**
  34808. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  34809. */
  34810. /**
  34811. * Sets whether or not objects positions are enabled for the G buffer.
  34812. */
  34813. enablePosition: boolean;
  34814. /**
  34815. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  34816. */
  34817. /**
  34818. * Sets wether or not objects velocities are enabled for the G buffer.
  34819. */
  34820. enableVelocity: boolean;
  34821. /**
  34822. * Gets the scene associated with the buffer.
  34823. */
  34824. readonly scene: Scene;
  34825. /**
  34826. * Gets the ratio used by the buffer during its creation.
  34827. * How big is the buffer related to the main canvas.
  34828. */
  34829. readonly ratio: number;
  34830. /**
  34831. * Creates a new G Buffer for the scene
  34832. * @param scene The scene the buffer belongs to
  34833. * @param ratio How big is the buffer related to the main canvas.
  34834. */
  34835. constructor(scene: Scene, ratio?: number);
  34836. /**
  34837. * Checks wether everything is ready to render a submesh to the G buffer.
  34838. * @param subMesh the submesh to check readiness for
  34839. * @param useInstances is the mesh drawn using instance or not
  34840. * @returns true if ready otherwise false
  34841. */
  34842. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34843. /**
  34844. * Gets the current underlying G Buffer.
  34845. * @returns the buffer
  34846. */
  34847. getGBuffer(): MultiRenderTarget;
  34848. /**
  34849. * Gets the number of samples used to render the buffer (anti aliasing).
  34850. */
  34851. /**
  34852. * Sets the number of samples used to render the buffer (anti aliasing).
  34853. */
  34854. samples: number;
  34855. /**
  34856. * Disposes the renderer and frees up associated resources.
  34857. */
  34858. dispose(): void;
  34859. protected _createRenderTargets(): void;
  34860. }
  34861. }
  34862. declare module BABYLON {
  34863. interface Scene {
  34864. /** @hidden (Backing field) */
  34865. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  34866. /**
  34867. * Gets or Sets the current geometry buffer associated to the scene.
  34868. */
  34869. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  34870. /**
  34871. * Enables a GeometryBufferRender and associates it with the scene
  34872. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  34873. * @returns the GeometryBufferRenderer
  34874. */
  34875. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  34876. /**
  34877. * Disables the GeometryBufferRender associated with the scene
  34878. */
  34879. disableGeometryBufferRenderer(): void;
  34880. }
  34881. /**
  34882. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  34883. * in several rendering techniques.
  34884. */
  34885. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  34886. /**
  34887. * The component name helpful to identify the component in the list of scene components.
  34888. */
  34889. readonly name: string;
  34890. /**
  34891. * The scene the component belongs to.
  34892. */
  34893. scene: Scene;
  34894. /**
  34895. * Creates a new instance of the component for the given scene
  34896. * @param scene Defines the scene to register the component in
  34897. */
  34898. constructor(scene: Scene);
  34899. /**
  34900. * Registers the component in a given scene
  34901. */
  34902. register(): void;
  34903. /**
  34904. * Rebuilds the elements related to this component in case of
  34905. * context lost for instance.
  34906. */
  34907. rebuild(): void;
  34908. /**
  34909. * Disposes the component and the associated ressources
  34910. */
  34911. dispose(): void;
  34912. private _gatherRenderTargets;
  34913. }
  34914. }
  34915. declare module BABYLON {
  34916. /**
  34917. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  34918. */
  34919. class LineEdgesRenderer extends EdgesRenderer {
  34920. /**
  34921. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  34922. * @param source LineMesh used to generate edges
  34923. * @param epsilon not important (specified angle for edge detection)
  34924. * @param checkVerticesInsteadOfIndices not important for LineMesh
  34925. */
  34926. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  34927. /**
  34928. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  34929. */
  34930. _generateEdgesLines(): void;
  34931. }
  34932. }
  34933. declare module BABYLON {
  34934. interface Scene {
  34935. /** @hidden */
  34936. _outlineRenderer: OutlineRenderer;
  34937. /**
  34938. * Gets the outline renderer associated with the scene
  34939. * @returns a OutlineRenderer
  34940. */
  34941. getOutlineRenderer(): OutlineRenderer;
  34942. }
  34943. interface AbstractMesh {
  34944. /** @hidden (Backing field) */
  34945. _renderOutline: boolean;
  34946. /**
  34947. * Gets or sets a boolean indicating if the outline must be rendered as well
  34948. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  34949. */
  34950. renderOutline: boolean;
  34951. /** @hidden (Backing field) */
  34952. _renderOverlay: boolean;
  34953. /**
  34954. * Gets or sets a boolean indicating if the overlay must be rendered as well
  34955. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  34956. */
  34957. renderOverlay: boolean;
  34958. }
  34959. /**
  34960. * This class is responsible to draw bothe outline/overlay of meshes.
  34961. * It should not be used directly but through the available method on mesh.
  34962. */
  34963. class OutlineRenderer implements ISceneComponent {
  34964. /**
  34965. * The name of the component. Each component must have a unique name.
  34966. */
  34967. name: string;
  34968. /**
  34969. * The scene the component belongs to.
  34970. */
  34971. scene: Scene;
  34972. /**
  34973. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  34974. */
  34975. zOffset: number;
  34976. private _engine;
  34977. private _effect;
  34978. private _cachedDefines;
  34979. private _savedDepthWrite;
  34980. /**
  34981. * Instantiates a new outline renderer. (There could be only one per scene).
  34982. * @param scene Defines the scene it belongs to
  34983. */
  34984. constructor(scene: Scene);
  34985. /**
  34986. * Register the component to one instance of a scene.
  34987. */
  34988. register(): void;
  34989. /**
  34990. * Rebuilds the elements related to this component in case of
  34991. * context lost for instance.
  34992. */
  34993. rebuild(): void;
  34994. /**
  34995. * Disposes the component and the associated ressources.
  34996. */
  34997. dispose(): void;
  34998. /**
  34999. * Renders the outline in the canvas.
  35000. * @param subMesh Defines the sumesh to render
  35001. * @param batch Defines the batch of meshes in case of instances
  35002. * @param useOverlay Defines if the rendering is for the overlay or the outline
  35003. */
  35004. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  35005. /**
  35006. * Returns whether or not the outline renderer is ready for a given submesh.
  35007. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  35008. * @param subMesh Defines the submesh to check readyness for
  35009. * @param useInstances Defines wheter wee are trying to render instances or not
  35010. * @returns true if ready otherwise false
  35011. */
  35012. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35013. private _beforeRenderingMesh;
  35014. private _afterRenderingMesh;
  35015. }
  35016. }
  35017. declare module BABYLON {
  35018. /**
  35019. * This represents the object necessary to create a rendering group.
  35020. * This is exclusively used and created by the rendering manager.
  35021. * To modify the behavior, you use the available helpers in your scene or meshes.
  35022. * @hidden
  35023. */
  35024. class RenderingGroup {
  35025. index: number;
  35026. private _scene;
  35027. private _opaqueSubMeshes;
  35028. private _transparentSubMeshes;
  35029. private _alphaTestSubMeshes;
  35030. private _depthOnlySubMeshes;
  35031. private _particleSystems;
  35032. private _spriteManagers;
  35033. private _opaqueSortCompareFn;
  35034. private _alphaTestSortCompareFn;
  35035. private _transparentSortCompareFn;
  35036. private _renderOpaque;
  35037. private _renderAlphaTest;
  35038. private _renderTransparent;
  35039. private _edgesRenderers;
  35040. onBeforeTransparentRendering: () => void;
  35041. /**
  35042. * Set the opaque sort comparison function.
  35043. * If null the sub meshes will be render in the order they were created
  35044. */
  35045. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35046. /**
  35047. * Set the alpha test sort comparison function.
  35048. * If null the sub meshes will be render in the order they were created
  35049. */
  35050. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35051. /**
  35052. * Set the transparent sort comparison function.
  35053. * If null the sub meshes will be render in the order they were created
  35054. */
  35055. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35056. /**
  35057. * Creates a new rendering group.
  35058. * @param index The rendering group index
  35059. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  35060. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  35061. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  35062. */
  35063. 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>);
  35064. /**
  35065. * Render all the sub meshes contained in the group.
  35066. * @param customRenderFunction Used to override the default render behaviour of the group.
  35067. * @returns true if rendered some submeshes.
  35068. */
  35069. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  35070. /**
  35071. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  35072. * @param subMeshes The submeshes to render
  35073. */
  35074. private renderOpaqueSorted;
  35075. /**
  35076. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  35077. * @param subMeshes The submeshes to render
  35078. */
  35079. private renderAlphaTestSorted;
  35080. /**
  35081. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  35082. * @param subMeshes The submeshes to render
  35083. */
  35084. private renderTransparentSorted;
  35085. /**
  35086. * Renders the submeshes in a specified order.
  35087. * @param subMeshes The submeshes to sort before render
  35088. * @param sortCompareFn The comparison function use to sort
  35089. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  35090. * @param transparent Specifies to activate blending if true
  35091. */
  35092. private static renderSorted;
  35093. /**
  35094. * Renders the submeshes in the order they were dispatched (no sort applied).
  35095. * @param subMeshes The submeshes to render
  35096. */
  35097. private static renderUnsorted;
  35098. /**
  35099. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35100. * are rendered back to front if in the same alpha index.
  35101. *
  35102. * @param a The first submesh
  35103. * @param b The second submesh
  35104. * @returns The result of the comparison
  35105. */
  35106. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  35107. /**
  35108. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35109. * are rendered back to front.
  35110. *
  35111. * @param a The first submesh
  35112. * @param b The second submesh
  35113. * @returns The result of the comparison
  35114. */
  35115. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  35116. /**
  35117. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35118. * are rendered front to back (prevent overdraw).
  35119. *
  35120. * @param a The first submesh
  35121. * @param b The second submesh
  35122. * @returns The result of the comparison
  35123. */
  35124. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  35125. /**
  35126. * Resets the different lists of submeshes to prepare a new frame.
  35127. */
  35128. prepare(): void;
  35129. dispose(): void;
  35130. /**
  35131. * Inserts the submesh in its correct queue depending on its material.
  35132. * @param subMesh The submesh to dispatch
  35133. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35134. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35135. */
  35136. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35137. dispatchSprites(spriteManager: ISpriteManager): void;
  35138. dispatchParticles(particleSystem: IParticleSystem): void;
  35139. private _renderParticles;
  35140. private _renderSprites;
  35141. }
  35142. }
  35143. declare module BABYLON {
  35144. /**
  35145. * Interface describing the different options available in the rendering manager
  35146. * regarding Auto Clear between groups.
  35147. */
  35148. interface IRenderingManagerAutoClearSetup {
  35149. /**
  35150. * Defines whether or not autoclear is enable.
  35151. */
  35152. autoClear: boolean;
  35153. /**
  35154. * Defines whether or not to autoclear the depth buffer.
  35155. */
  35156. depth: boolean;
  35157. /**
  35158. * Defines whether or not to autoclear the stencil buffer.
  35159. */
  35160. stencil: boolean;
  35161. }
  35162. /**
  35163. * This is the manager responsible of all the rendering for meshes sprites and particles.
  35164. * It is enable to manage the different groups as well as the different necessary sort functions.
  35165. * This should not be used directly aside of the few static configurations
  35166. */
  35167. class RenderingManager {
  35168. /**
  35169. * The max id used for rendering groups (not included)
  35170. */
  35171. static MAX_RENDERINGGROUPS: number;
  35172. /**
  35173. * The min id used for rendering groups (included)
  35174. */
  35175. static MIN_RENDERINGGROUPS: number;
  35176. /**
  35177. * Used to globally prevent autoclearing scenes.
  35178. */
  35179. static AUTOCLEAR: boolean;
  35180. /**
  35181. * @hidden
  35182. */
  35183. _useSceneAutoClearSetup: boolean;
  35184. private _scene;
  35185. private _renderingGroups;
  35186. private _depthStencilBufferAlreadyCleaned;
  35187. private _autoClearDepthStencil;
  35188. private _customOpaqueSortCompareFn;
  35189. private _customAlphaTestSortCompareFn;
  35190. private _customTransparentSortCompareFn;
  35191. private _renderingGroupInfo;
  35192. /**
  35193. * Instantiates a new rendering group for a particular scene
  35194. * @param scene Defines the scene the groups belongs to
  35195. */
  35196. constructor(scene: Scene);
  35197. private _clearDepthStencilBuffer;
  35198. /**
  35199. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  35200. * @hidden
  35201. */
  35202. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  35203. /**
  35204. * Resets the different information of the group to prepare a new frame
  35205. * @hidden
  35206. */
  35207. reset(): void;
  35208. /**
  35209. * Dispose and release the group and its associated resources.
  35210. * @hidden
  35211. */
  35212. dispose(): void;
  35213. /**
  35214. * Clear the info related to rendering groups preventing retention points during dispose.
  35215. */
  35216. freeRenderingGroups(): void;
  35217. private _prepareRenderingGroup;
  35218. /**
  35219. * Add a sprite manager to the rendering manager in order to render it this frame.
  35220. * @param spriteManager Define the sprite manager to render
  35221. */
  35222. dispatchSprites(spriteManager: ISpriteManager): void;
  35223. /**
  35224. * Add a particle system to the rendering manager in order to render it this frame.
  35225. * @param particleSystem Define the particle system to render
  35226. */
  35227. dispatchParticles(particleSystem: IParticleSystem): void;
  35228. /**
  35229. * Add a submesh to the manager in order to render it this frame
  35230. * @param subMesh The submesh to dispatch
  35231. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35232. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35233. */
  35234. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35235. /**
  35236. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35237. * This allowed control for front to back rendering or reversly depending of the special needs.
  35238. *
  35239. * @param renderingGroupId The rendering group id corresponding to its index
  35240. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35241. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35242. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35243. */
  35244. 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;
  35245. /**
  35246. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35247. *
  35248. * @param renderingGroupId The rendering group id corresponding to its index
  35249. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35250. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35251. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35252. */
  35253. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35254. /**
  35255. * Gets the current auto clear configuration for one rendering group of the rendering
  35256. * manager.
  35257. * @param index the rendering group index to get the information for
  35258. * @returns The auto clear setup for the requested rendering group
  35259. */
  35260. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35261. }
  35262. }
  35263. declare module BABYLON {
  35264. /**
  35265. * Renders a layer on top of an existing scene
  35266. */
  35267. class UtilityLayerRenderer implements IDisposable {
  35268. /** the original scene that will be rendered on top of */
  35269. originalScene: Scene;
  35270. private _pointerCaptures;
  35271. private _lastPointerEvents;
  35272. private static _DefaultUtilityLayer;
  35273. private static _DefaultKeepDepthUtilityLayer;
  35274. /**
  35275. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  35276. */
  35277. pickUtilitySceneFirst: boolean;
  35278. /**
  35279. * 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)
  35280. */
  35281. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  35282. /**
  35283. * 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)
  35284. */
  35285. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  35286. /**
  35287. * The scene that is rendered on top of the original scene
  35288. */
  35289. utilityLayerScene: Scene;
  35290. /**
  35291. * If the utility layer should automatically be rendered on top of existing scene
  35292. */
  35293. shouldRender: boolean;
  35294. /**
  35295. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  35296. */
  35297. onlyCheckPointerDownEvents: boolean;
  35298. /**
  35299. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  35300. */
  35301. processAllEvents: boolean;
  35302. /**
  35303. * Observable raised when the pointer move from the utility layer scene to the main scene
  35304. */
  35305. onPointerOutObservable: Observable<number>;
  35306. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  35307. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  35308. private _afterRenderObserver;
  35309. private _sceneDisposeObserver;
  35310. private _originalPointerObserver;
  35311. /**
  35312. * Instantiates a UtilityLayerRenderer
  35313. * @param originalScene the original scene that will be rendered on top of
  35314. * @param handleEvents boolean indicating if the utility layer should handle events
  35315. */
  35316. constructor(
  35317. /** the original scene that will be rendered on top of */
  35318. originalScene: Scene, handleEvents?: boolean);
  35319. private _notifyObservers;
  35320. /**
  35321. * Renders the utility layers scene on top of the original scene
  35322. */
  35323. render(): void;
  35324. /**
  35325. * Disposes of the renderer
  35326. */
  35327. dispose(): void;
  35328. private _updateCamera;
  35329. }
  35330. }
  35331. declare module BABYLON {
  35332. /**
  35333. * Postprocess used to generate anaglyphic rendering
  35334. */
  35335. class AnaglyphPostProcess extends PostProcess {
  35336. private _passedProcess;
  35337. /**
  35338. * Creates a new AnaglyphPostProcess
  35339. * @param name defines postprocess name
  35340. * @param options defines creation options or target ratio scale
  35341. * @param rigCameras defines cameras using this postprocess
  35342. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  35343. * @param engine defines hosting engine
  35344. * @param reusable defines if the postprocess will be reused multiple times per frame
  35345. */
  35346. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  35347. }
  35348. }
  35349. declare module BABYLON {
  35350. /**
  35351. * Post process used to render in black and white
  35352. */
  35353. class BlackAndWhitePostProcess extends PostProcess {
  35354. /**
  35355. * Linear about to convert he result to black and white (default: 1)
  35356. */
  35357. degree: number;
  35358. /**
  35359. * Creates a black and white post process
  35360. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  35361. * @param name The name of the effect.
  35362. * @param options The required width/height ratio to downsize to before computing the render pass.
  35363. * @param camera The camera to apply the render pass to.
  35364. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35365. * @param engine The engine which the post process will be applied. (default: current engine)
  35366. * @param reusable If the post process can be reused on the same frame. (default: false)
  35367. */
  35368. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35369. }
  35370. }
  35371. declare module BABYLON {
  35372. /**
  35373. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  35374. */
  35375. class BloomEffect extends PostProcessRenderEffect {
  35376. private bloomScale;
  35377. /**
  35378. * @hidden Internal
  35379. */
  35380. _effects: Array<PostProcess>;
  35381. /**
  35382. * @hidden Internal
  35383. */
  35384. _downscale: ExtractHighlightsPostProcess;
  35385. private _blurX;
  35386. private _blurY;
  35387. private _merge;
  35388. /**
  35389. * The luminance threshold to find bright areas of the image to bloom.
  35390. */
  35391. threshold: number;
  35392. /**
  35393. * The strength of the bloom.
  35394. */
  35395. weight: number;
  35396. /**
  35397. * Specifies the size of the bloom blur kernel, relative to the final output size
  35398. */
  35399. kernel: number;
  35400. /**
  35401. * Creates a new instance of @see BloomEffect
  35402. * @param scene The scene the effect belongs to.
  35403. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  35404. * @param bloomKernel The size of the kernel to be used when applying the blur.
  35405. * @param bloomWeight The the strength of bloom.
  35406. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  35407. * @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)
  35408. */
  35409. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  35410. /**
  35411. * Disposes each of the internal effects for a given camera.
  35412. * @param camera The camera to dispose the effect on.
  35413. */
  35414. disposeEffects(camera: Camera): void;
  35415. /**
  35416. * @hidden Internal
  35417. */
  35418. _updateEffects(): void;
  35419. /**
  35420. * Internal
  35421. * @returns if all the contained post processes are ready.
  35422. * @hidden
  35423. */
  35424. _isReady(): boolean;
  35425. }
  35426. }
  35427. declare module BABYLON {
  35428. /**
  35429. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  35430. */
  35431. class BloomMergePostProcess extends PostProcess {
  35432. /** Weight of the bloom to be added to the original input. */
  35433. weight: number;
  35434. /**
  35435. * Creates a new instance of @see BloomMergePostProcess
  35436. * @param name The name of the effect.
  35437. * @param originalFromInput Post process which's input will be used for the merge.
  35438. * @param blurred Blurred highlights post process which's output will be used.
  35439. * @param weight Weight of the bloom to be added to the original input.
  35440. * @param options The required width/height ratio to downsize to before computing the render pass.
  35441. * @param camera The camera to apply the render pass to.
  35442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35443. * @param engine The engine which the post process will be applied. (default: current engine)
  35444. * @param reusable If the post process can be reused on the same frame. (default: false)
  35445. * @param textureType Type of textures used when performing the post process. (default: 0)
  35446. * @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)
  35447. */
  35448. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  35449. /** Weight of the bloom to be added to the original input. */
  35450. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35451. }
  35452. }
  35453. declare module BABYLON {
  35454. /**
  35455. * The Blur Post Process which blurs an image based on a kernel and direction.
  35456. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  35457. */
  35458. class BlurPostProcess extends PostProcess {
  35459. /** The direction in which to blur the image. */
  35460. direction: Vector2;
  35461. private blockCompilation;
  35462. protected _kernel: number;
  35463. protected _idealKernel: number;
  35464. protected _packedFloat: boolean;
  35465. private _staticDefines;
  35466. /**
  35467. * Sets the length in pixels of the blur sample region
  35468. */
  35469. /**
  35470. * Gets the length in pixels of the blur sample region
  35471. */
  35472. kernel: number;
  35473. /**
  35474. * Sets wether or not the blur needs to unpack/repack floats
  35475. */
  35476. /**
  35477. * Gets wether or not the blur is unpacking/repacking floats
  35478. */
  35479. packedFloat: boolean;
  35480. /**
  35481. * Creates a new instance BlurPostProcess
  35482. * @param name The name of the effect.
  35483. * @param direction The direction in which to blur the image.
  35484. * @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.
  35485. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35486. * @param camera The camera to apply the render pass to.
  35487. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35488. * @param engine The engine which the post process will be applied. (default: current engine)
  35489. * @param reusable If the post process can be reused on the same frame. (default: false)
  35490. * @param textureType Type of textures used when performing the post process. (default: 0)
  35491. * @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)
  35492. */
  35493. constructor(name: string,
  35494. /** The direction in which to blur the image. */
  35495. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  35496. /**
  35497. * Updates the effect with the current post process compile time values and recompiles the shader.
  35498. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35499. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35500. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35501. * @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
  35502. * @param onCompiled Called when the shader has been compiled.
  35503. * @param onError Called if there is an error when compiling a shader.
  35504. */
  35505. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35506. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35507. /**
  35508. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  35509. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  35510. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  35511. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  35512. * The gaps between physical kernels are compensated for in the weighting of the samples
  35513. * @param idealKernel Ideal blur kernel.
  35514. * @return Nearest best kernel.
  35515. */
  35516. protected _nearestBestKernel(idealKernel: number): number;
  35517. /**
  35518. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  35519. * @param x The point on the Gaussian distribution to sample.
  35520. * @return the value of the Gaussian function at x.
  35521. */
  35522. protected _gaussianWeight(x: number): number;
  35523. /**
  35524. * Generates a string that can be used as a floating point number in GLSL.
  35525. * @param x Value to print.
  35526. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  35527. * @return GLSL float string.
  35528. */
  35529. protected _glslFloat(x: number, decimalFigures?: number): string;
  35530. }
  35531. }
  35532. declare module BABYLON {
  35533. /**
  35534. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  35535. */
  35536. class ChromaticAberrationPostProcess extends PostProcess {
  35537. /**
  35538. * The amount of seperation of rgb channels (default: 30)
  35539. */
  35540. aberrationAmount: number;
  35541. /**
  35542. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  35543. */
  35544. radialIntensity: number;
  35545. /**
  35546. * 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))
  35547. */
  35548. direction: Vector2;
  35549. /**
  35550. * 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))
  35551. */
  35552. centerPosition: Vector2;
  35553. /**
  35554. * Creates a new instance ChromaticAberrationPostProcess
  35555. * @param name The name of the effect.
  35556. * @param screenWidth The width of the screen to apply the effect on.
  35557. * @param screenHeight The height of the screen to apply the effect on.
  35558. * @param options The required width/height ratio to downsize to before computing the render pass.
  35559. * @param camera The camera to apply the render pass to.
  35560. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35561. * @param engine The engine which the post process will be applied. (default: current engine)
  35562. * @param reusable If the post process can be reused on the same frame. (default: false)
  35563. * @param textureType Type of textures used when performing the post process. (default: 0)
  35564. * @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)
  35565. */
  35566. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35567. }
  35568. }
  35569. declare module BABYLON {
  35570. /**
  35571. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  35572. */
  35573. class CircleOfConfusionPostProcess extends PostProcess {
  35574. /**
  35575. * 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.
  35576. */
  35577. lensSize: number;
  35578. /**
  35579. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  35580. */
  35581. fStop: number;
  35582. /**
  35583. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  35584. */
  35585. focusDistance: number;
  35586. /**
  35587. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  35588. */
  35589. focalLength: number;
  35590. private _depthTexture;
  35591. /**
  35592. * Creates a new instance CircleOfConfusionPostProcess
  35593. * @param name The name of the effect.
  35594. * @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.
  35595. * @param options The required width/height ratio to downsize to before computing the render pass.
  35596. * @param camera The camera to apply the render pass to.
  35597. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35598. * @param engine The engine which the post process will be applied. (default: current engine)
  35599. * @param reusable If the post process can be reused on the same frame. (default: false)
  35600. * @param textureType Type of textures used when performing the post process. (default: 0)
  35601. * @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)
  35602. */
  35603. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35604. /**
  35605. * 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.
  35606. */
  35607. depthTexture: RenderTargetTexture;
  35608. }
  35609. }
  35610. declare module BABYLON {
  35611. /**
  35612. *
  35613. * This post-process allows the modification of rendered colors by using
  35614. * a 'look-up table' (LUT). This effect is also called Color Grading.
  35615. *
  35616. * The object needs to be provided an url to a texture containing the color
  35617. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  35618. * Use an image editing software to tweak the LUT to match your needs.
  35619. *
  35620. * For an example of a color LUT, see here:
  35621. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  35622. * For explanations on color grading, see here:
  35623. * @see http://udn.epicgames.com/Three/ColorGrading.html
  35624. *
  35625. */
  35626. class ColorCorrectionPostProcess extends PostProcess {
  35627. private _colorTableTexture;
  35628. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35629. }
  35630. }
  35631. declare module BABYLON {
  35632. /**
  35633. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  35634. * input texture to perform effects such as edge detection or sharpening
  35635. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35636. */
  35637. class ConvolutionPostProcess extends PostProcess {
  35638. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  35639. kernel: number[];
  35640. /**
  35641. * Creates a new instance ConvolutionPostProcess
  35642. * @param name The name of the effect.
  35643. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  35644. * @param options The required width/height ratio to downsize to before computing the render pass.
  35645. * @param camera The camera to apply the render pass to.
  35646. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35647. * @param engine The engine which the post process will be applied. (default: current engine)
  35648. * @param reusable If the post process can be reused on the same frame. (default: false)
  35649. * @param textureType Type of textures used when performing the post process. (default: 0)
  35650. */
  35651. constructor(name: string,
  35652. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  35653. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35654. /**
  35655. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35656. */
  35657. static EdgeDetect0Kernel: number[];
  35658. /**
  35659. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35660. */
  35661. static EdgeDetect1Kernel: number[];
  35662. /**
  35663. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35664. */
  35665. static EdgeDetect2Kernel: number[];
  35666. /**
  35667. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35668. */
  35669. static SharpenKernel: number[];
  35670. /**
  35671. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35672. */
  35673. static EmbossKernel: number[];
  35674. /**
  35675. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35676. */
  35677. static GaussianKernel: number[];
  35678. }
  35679. }
  35680. declare module BABYLON {
  35681. /**
  35682. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  35683. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  35684. * based on samples that have a large difference in distance than the center pixel.
  35685. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  35686. */
  35687. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  35688. direction: Vector2;
  35689. /**
  35690. * Creates a new instance CircleOfConfusionPostProcess
  35691. * @param name The name of the effect.
  35692. * @param scene The scene the effect belongs to.
  35693. * @param direction The direction the blur should be applied.
  35694. * @param kernel The size of the kernel used to blur.
  35695. * @param options The required width/height ratio to downsize to before computing the render pass.
  35696. * @param camera The camera to apply the render pass to.
  35697. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  35698. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  35699. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35700. * @param engine The engine which the post process will be applied. (default: current engine)
  35701. * @param reusable If the post process can be reused on the same frame. (default: false)
  35702. * @param textureType Type of textures used when performing the post process. (default: 0)
  35703. * @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)
  35704. */
  35705. 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);
  35706. }
  35707. }
  35708. declare module BABYLON {
  35709. /**
  35710. * Specifies the level of max blur that should be applied when using the depth of field effect
  35711. */
  35712. enum DepthOfFieldEffectBlurLevel {
  35713. /**
  35714. * Subtle blur
  35715. */
  35716. Low = 0,
  35717. /**
  35718. * Medium blur
  35719. */
  35720. Medium = 1,
  35721. /**
  35722. * Large blur
  35723. */
  35724. High = 2
  35725. }
  35726. /**
  35727. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  35728. */
  35729. class DepthOfFieldEffect extends PostProcessRenderEffect {
  35730. private _circleOfConfusion;
  35731. /**
  35732. * @hidden Internal, blurs from high to low
  35733. */
  35734. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  35735. private _depthOfFieldBlurY;
  35736. private _dofMerge;
  35737. /**
  35738. * @hidden Internal post processes in depth of field effect
  35739. */
  35740. _effects: Array<PostProcess>;
  35741. /**
  35742. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  35743. */
  35744. focalLength: number;
  35745. /**
  35746. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  35747. */
  35748. fStop: number;
  35749. /**
  35750. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  35751. */
  35752. focusDistance: number;
  35753. /**
  35754. * 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.
  35755. */
  35756. lensSize: number;
  35757. /**
  35758. * Creates a new instance DepthOfFieldEffect
  35759. * @param scene The scene the effect belongs to.
  35760. * @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.
  35761. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  35762. * @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)
  35763. */
  35764. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  35765. /**
  35766. * 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.
  35767. */
  35768. depthTexture: RenderTargetTexture;
  35769. /**
  35770. * Disposes each of the internal effects for a given camera.
  35771. * @param camera The camera to dispose the effect on.
  35772. */
  35773. disposeEffects(camera: Camera): void;
  35774. /**
  35775. * @hidden Internal
  35776. */
  35777. _updateEffects(): void;
  35778. /**
  35779. * Internal
  35780. * @returns if all the contained post processes are ready.
  35781. * @hidden
  35782. */
  35783. _isReady(): boolean;
  35784. }
  35785. }
  35786. declare module BABYLON {
  35787. /**
  35788. * Options to be set when merging outputs from the default pipeline.
  35789. */
  35790. class DepthOfFieldMergePostProcessOptions {
  35791. /**
  35792. * The original image to merge on top of
  35793. */
  35794. originalFromInput: PostProcess;
  35795. /**
  35796. * Parameters to perform the merge of the depth of field effect
  35797. */
  35798. depthOfField?: {
  35799. circleOfConfusion: PostProcess;
  35800. blurSteps: Array<PostProcess>;
  35801. };
  35802. /**
  35803. * Parameters to perform the merge of bloom effect
  35804. */
  35805. bloom?: {
  35806. blurred: PostProcess;
  35807. weight: number;
  35808. };
  35809. }
  35810. /**
  35811. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  35812. */
  35813. class DepthOfFieldMergePostProcess extends PostProcess {
  35814. private blurSteps;
  35815. /**
  35816. * Creates a new instance of DepthOfFieldMergePostProcess
  35817. * @param name The name of the effect.
  35818. * @param originalFromInput Post process which's input will be used for the merge.
  35819. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  35820. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  35821. * @param options The required width/height ratio to downsize to before computing the render pass.
  35822. * @param camera The camera to apply the render pass to.
  35823. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35824. * @param engine The engine which the post process will be applied. (default: current engine)
  35825. * @param reusable If the post process can be reused on the same frame. (default: false)
  35826. * @param textureType Type of textures used when performing the post process. (default: 0)
  35827. * @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)
  35828. */
  35829. 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);
  35830. /**
  35831. * Updates the effect with the current post process compile time values and recompiles the shader.
  35832. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35833. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35834. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35835. * @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
  35836. * @param onCompiled Called when the shader has been compiled.
  35837. * @param onError Called if there is an error when compiling a shader.
  35838. */
  35839. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35840. }
  35841. }
  35842. declare module BABYLON {
  35843. /**
  35844. * DisplayPassPostProcess which produces an output the same as it's input
  35845. */
  35846. class DisplayPassPostProcess extends PostProcess {
  35847. /**
  35848. * Creates the DisplayPassPostProcess
  35849. * @param name The name of the effect.
  35850. * @param options The required width/height ratio to downsize to before computing the render pass.
  35851. * @param camera The camera to apply the render pass to.
  35852. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35853. * @param engine The engine which the post process will be applied. (default: current engine)
  35854. * @param reusable If the post process can be reused on the same frame. (default: false)
  35855. */
  35856. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35857. }
  35858. }
  35859. declare module BABYLON {
  35860. /**
  35861. * 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.
  35862. */
  35863. class ExtractHighlightsPostProcess extends PostProcess {
  35864. /**
  35865. * The luminance threshold, pixels below this value will be set to black.
  35866. */
  35867. threshold: number;
  35868. /** @hidden */
  35869. _exposure: number;
  35870. /**
  35871. * Post process which has the input texture to be used when performing highlight extraction
  35872. * @hidden
  35873. */
  35874. _inputPostProcess: Nullable<PostProcess>;
  35875. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35876. }
  35877. }
  35878. declare module BABYLON {
  35879. /**
  35880. * Applies a kernel filter to the image
  35881. */
  35882. class FilterPostProcess extends PostProcess {
  35883. /** The matrix to be applied to the image */
  35884. kernelMatrix: Matrix;
  35885. /**
  35886. *
  35887. * @param name The name of the effect.
  35888. * @param kernelMatrix The matrix to be applied to the image
  35889. * @param options The required width/height ratio to downsize to before computing the render pass.
  35890. * @param camera The camera to apply the render pass to.
  35891. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35892. * @param engine The engine which the post process will be applied. (default: current engine)
  35893. * @param reusable If the post process can be reused on the same frame. (default: false)
  35894. */
  35895. constructor(name: string,
  35896. /** The matrix to be applied to the image */
  35897. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35898. }
  35899. }
  35900. declare module BABYLON {
  35901. /**
  35902. * Fxaa post process
  35903. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  35904. */
  35905. class FxaaPostProcess extends PostProcess {
  35906. /** @hidden */
  35907. texelWidth: number;
  35908. /** @hidden */
  35909. texelHeight: number;
  35910. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35911. private _getDefines;
  35912. }
  35913. }
  35914. declare module BABYLON {
  35915. /**
  35916. * The GrainPostProcess adds noise to the image at mid luminance levels
  35917. */
  35918. class GrainPostProcess extends PostProcess {
  35919. /**
  35920. * The intensity of the grain added (default: 30)
  35921. */
  35922. intensity: number;
  35923. /**
  35924. * If the grain should be randomized on every frame
  35925. */
  35926. animated: boolean;
  35927. /**
  35928. * Creates a new instance of @see GrainPostProcess
  35929. * @param name The name of the effect.
  35930. * @param options The required width/height ratio to downsize to before computing the render pass.
  35931. * @param camera The camera to apply the render pass to.
  35932. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35933. * @param engine The engine which the post process will be applied. (default: current engine)
  35934. * @param reusable If the post process can be reused on the same frame. (default: false)
  35935. * @param textureType Type of textures used when performing the post process. (default: 0)
  35936. * @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)
  35937. */
  35938. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35939. }
  35940. }
  35941. declare module BABYLON {
  35942. /**
  35943. * Extracts highlights from the image
  35944. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35945. */
  35946. class HighlightsPostProcess extends PostProcess {
  35947. /**
  35948. * Extracts highlights from the image
  35949. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35950. * @param name The name of the effect.
  35951. * @param options The required width/height ratio to downsize to before computing the render pass.
  35952. * @param camera The camera to apply the render pass to.
  35953. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35954. * @param engine The engine which the post process will be applied. (default: current engine)
  35955. * @param reusable If the post process can be reused on the same frame. (default: false)
  35956. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  35957. */
  35958. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35959. }
  35960. }
  35961. declare module BABYLON {
  35962. /**
  35963. * ImageProcessingPostProcess
  35964. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  35965. */
  35966. class ImageProcessingPostProcess extends PostProcess {
  35967. /**
  35968. * Default configuration related to image processing available in the PBR Material.
  35969. */
  35970. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35971. /**
  35972. * Gets the image processing configuration used either in this material.
  35973. */
  35974. /**
  35975. * Sets the Default image processing configuration used either in the this material.
  35976. *
  35977. * If sets to null, the scene one is in use.
  35978. */
  35979. imageProcessingConfiguration: ImageProcessingConfiguration;
  35980. /**
  35981. * Keep track of the image processing observer to allow dispose and replace.
  35982. */
  35983. private _imageProcessingObserver;
  35984. /**
  35985. * Attaches a new image processing configuration to the PBR Material.
  35986. * @param configuration
  35987. */
  35988. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  35989. /**
  35990. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35991. */
  35992. /**
  35993. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35994. */
  35995. colorCurves: Nullable<ColorCurves>;
  35996. /**
  35997. * Gets wether the color curves effect is enabled.
  35998. */
  35999. /**
  36000. * Sets wether the color curves effect is enabled.
  36001. */
  36002. colorCurvesEnabled: boolean;
  36003. /**
  36004. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  36005. */
  36006. /**
  36007. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  36008. */
  36009. colorGradingTexture: Nullable<BaseTexture>;
  36010. /**
  36011. * Gets wether the color grading effect is enabled.
  36012. */
  36013. /**
  36014. * Gets wether the color grading effect is enabled.
  36015. */
  36016. colorGradingEnabled: boolean;
  36017. /**
  36018. * Gets exposure used in the effect.
  36019. */
  36020. /**
  36021. * Sets exposure used in the effect.
  36022. */
  36023. exposure: number;
  36024. /**
  36025. * Gets wether tonemapping is enabled or not.
  36026. */
  36027. /**
  36028. * Sets wether tonemapping is enabled or not
  36029. */
  36030. toneMappingEnabled: boolean;
  36031. /**
  36032. * Gets contrast used in the effect.
  36033. */
  36034. /**
  36035. * Sets contrast used in the effect.
  36036. */
  36037. contrast: number;
  36038. /**
  36039. * Gets Vignette stretch size.
  36040. */
  36041. /**
  36042. * Sets Vignette stretch size.
  36043. */
  36044. vignetteStretch: number;
  36045. /**
  36046. * Gets Vignette centre X Offset.
  36047. */
  36048. /**
  36049. * Sets Vignette centre X Offset.
  36050. */
  36051. vignetteCentreX: number;
  36052. /**
  36053. * Gets Vignette centre Y Offset.
  36054. */
  36055. /**
  36056. * Sets Vignette centre Y Offset.
  36057. */
  36058. vignetteCentreY: number;
  36059. /**
  36060. * Gets Vignette weight or intensity of the vignette effect.
  36061. */
  36062. /**
  36063. * Sets Vignette weight or intensity of the vignette effect.
  36064. */
  36065. vignetteWeight: number;
  36066. /**
  36067. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  36068. * if vignetteEnabled is set to true.
  36069. */
  36070. /**
  36071. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  36072. * if vignetteEnabled is set to true.
  36073. */
  36074. vignetteColor: Color4;
  36075. /**
  36076. * Gets Camera field of view used by the Vignette effect.
  36077. */
  36078. /**
  36079. * Sets Camera field of view used by the Vignette effect.
  36080. */
  36081. vignetteCameraFov: number;
  36082. /**
  36083. * Gets the vignette blend mode allowing different kind of effect.
  36084. */
  36085. /**
  36086. * Sets the vignette blend mode allowing different kind of effect.
  36087. */
  36088. vignetteBlendMode: number;
  36089. /**
  36090. * Gets wether the vignette effect is enabled.
  36091. */
  36092. /**
  36093. * Sets wether the vignette effect is enabled.
  36094. */
  36095. vignetteEnabled: boolean;
  36096. private _fromLinearSpace;
  36097. /**
  36098. * Gets wether the input of the processing is in Gamma or Linear Space.
  36099. */
  36100. /**
  36101. * Sets wether the input of the processing is in Gamma or Linear Space.
  36102. */
  36103. fromLinearSpace: boolean;
  36104. /**
  36105. * Defines cache preventing GC.
  36106. */
  36107. private _defines;
  36108. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  36109. /**
  36110. * "ImageProcessingPostProcess"
  36111. * @returns "ImageProcessingPostProcess"
  36112. */
  36113. getClassName(): string;
  36114. protected _updateParameters(): void;
  36115. dispose(camera?: Camera): void;
  36116. }
  36117. }
  36118. declare module BABYLON {
  36119. /**
  36120. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  36121. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  36122. * As an example, all you have to do is to create the post-process:
  36123. * var mb = new BABYLON.MotionBlurPostProcess(
  36124. * 'mb', // The name of the effect.
  36125. * scene, // The scene containing the objects to blur according to their velocity.
  36126. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  36127. * camera // The camera to apply the render pass to.
  36128. * );
  36129. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  36130. */
  36131. class MotionBlurPostProcess extends PostProcess {
  36132. /**
  36133. * Defines how much the image is blurred by the movement. Default value is equal to 1
  36134. */
  36135. motionStrength: number;
  36136. /**
  36137. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  36138. */
  36139. /**
  36140. * Sets the number of iterations to be used for motion blur quality
  36141. */
  36142. motionBlurSamples: number;
  36143. private _motionBlurSamples;
  36144. private _geometryBufferRenderer;
  36145. /**
  36146. * Creates a new instance MotionBlurPostProcess
  36147. * @param name The name of the effect.
  36148. * @param scene The scene containing the objects to blur according to their velocity.
  36149. * @param options The required width/height ratio to downsize to before computing the render pass.
  36150. * @param camera The camera to apply the render pass to.
  36151. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36152. * @param engine The engine which the post process will be applied. (default: current engine)
  36153. * @param reusable If the post process can be reused on the same frame. (default: false)
  36154. * @param textureType Type of textures used when performing the post process. (default: 0)
  36155. * @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)
  36156. */
  36157. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36158. /**
  36159. * Disposes the post process.
  36160. * @param camera The camera to dispose the post process on.
  36161. */
  36162. dispose(camera?: Camera): void;
  36163. }
  36164. }
  36165. declare module BABYLON {
  36166. /**
  36167. * PassPostProcess which produces an output the same as it's input
  36168. */
  36169. class PassPostProcess extends PostProcess {
  36170. /**
  36171. * Creates the PassPostProcess
  36172. * @param name The name of the effect.
  36173. * @param options The required width/height ratio to downsize to before computing the render pass.
  36174. * @param camera The camera to apply the render pass to.
  36175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36176. * @param engine The engine which the post process will be applied. (default: current engine)
  36177. * @param reusable If the post process can be reused on the same frame. (default: false)
  36178. * @param textureType The type of texture to be used when performing the post processing.
  36179. * @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)
  36180. */
  36181. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36182. }
  36183. /**
  36184. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36185. */
  36186. class PassCubePostProcess extends PostProcess {
  36187. private _face;
  36188. /**
  36189. * Gets or sets the cube face to display.
  36190. * * 0 is +X
  36191. * * 1 is -X
  36192. * * 2 is +Y
  36193. * * 3 is -Y
  36194. * * 4 is +Z
  36195. * * 5 is -Z
  36196. */
  36197. face: number;
  36198. /**
  36199. * Creates the PassCubePostProcess
  36200. * @param name The name of the effect.
  36201. * @param options The required width/height ratio to downsize to before computing the render pass.
  36202. * @param camera The camera to apply the render pass to.
  36203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36204. * @param engine The engine which the post process will be applied. (default: current engine)
  36205. * @param reusable If the post process can be reused on the same frame. (default: false)
  36206. * @param textureType The type of texture to be used when performing the post processing.
  36207. * @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)
  36208. */
  36209. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36210. }
  36211. }
  36212. declare module BABYLON {
  36213. /**
  36214. * Size options for a post process
  36215. */
  36216. type PostProcessOptions = {
  36217. width: number;
  36218. height: number;
  36219. };
  36220. /**
  36221. * PostProcess can be used to apply a shader to a texture after it has been rendered
  36222. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36223. */
  36224. class PostProcess {
  36225. /** Name of the PostProcess. */
  36226. name: string;
  36227. /**
  36228. * Width of the texture to apply the post process on
  36229. */
  36230. width: number;
  36231. /**
  36232. * Height of the texture to apply the post process on
  36233. */
  36234. height: number;
  36235. /**
  36236. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  36237. * @hidden
  36238. */
  36239. _outputTexture: Nullable<InternalTexture>;
  36240. /**
  36241. * Sampling mode used by the shader
  36242. * See https://doc.babylonjs.com/classes/3.1/texture
  36243. */
  36244. renderTargetSamplingMode: number;
  36245. /**
  36246. * Clear color to use when screen clearing
  36247. */
  36248. clearColor: Color4;
  36249. /**
  36250. * If the buffer needs to be cleared before applying the post process. (default: true)
  36251. * Should be set to false if shader will overwrite all previous pixels.
  36252. */
  36253. autoClear: boolean;
  36254. /**
  36255. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  36256. */
  36257. alphaMode: number;
  36258. /**
  36259. * Sets the setAlphaBlendConstants of the babylon engine
  36260. */
  36261. alphaConstants: Color4;
  36262. /**
  36263. * Animations to be used for the post processing
  36264. */
  36265. animations: Animation[];
  36266. /**
  36267. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  36268. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  36269. */
  36270. enablePixelPerfectMode: boolean;
  36271. /**
  36272. * Force the postprocess to be applied without taking in account viewport
  36273. */
  36274. forceFullscreenViewport: boolean;
  36275. /**
  36276. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  36277. *
  36278. * | Value | Type | Description |
  36279. * | ----- | ----------------------------------- | ----------- |
  36280. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  36281. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  36282. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  36283. *
  36284. */
  36285. scaleMode: number;
  36286. /**
  36287. * Force textures to be a power of two (default: false)
  36288. */
  36289. alwaysForcePOT: boolean;
  36290. private _samples;
  36291. /**
  36292. * Number of sample textures (default: 1)
  36293. */
  36294. samples: number;
  36295. /**
  36296. * Modify the scale of the post process to be the same as the viewport (default: false)
  36297. */
  36298. adaptScaleToCurrentViewport: boolean;
  36299. private _camera;
  36300. private _scene;
  36301. private _engine;
  36302. private _options;
  36303. private _reusable;
  36304. private _textureType;
  36305. /**
  36306. * Smart array of input and output textures for the post process.
  36307. * @hidden
  36308. */
  36309. _textures: SmartArray<InternalTexture>;
  36310. /**
  36311. * The index in _textures that corresponds to the output texture.
  36312. * @hidden
  36313. */
  36314. _currentRenderTextureInd: number;
  36315. private _effect;
  36316. private _samplers;
  36317. private _fragmentUrl;
  36318. private _vertexUrl;
  36319. private _parameters;
  36320. private _scaleRatio;
  36321. protected _indexParameters: any;
  36322. private _shareOutputWithPostProcess;
  36323. private _texelSize;
  36324. private _forcedOutputTexture;
  36325. /**
  36326. * An event triggered when the postprocess is activated.
  36327. */
  36328. onActivateObservable: Observable<Camera>;
  36329. private _onActivateObserver;
  36330. /**
  36331. * A function that is added to the onActivateObservable
  36332. */
  36333. onActivate: Nullable<(camera: Camera) => void>;
  36334. /**
  36335. * An event triggered when the postprocess changes its size.
  36336. */
  36337. onSizeChangedObservable: Observable<PostProcess>;
  36338. private _onSizeChangedObserver;
  36339. /**
  36340. * A function that is added to the onSizeChangedObservable
  36341. */
  36342. onSizeChanged: (postProcess: PostProcess) => void;
  36343. /**
  36344. * An event triggered when the postprocess applies its effect.
  36345. */
  36346. onApplyObservable: Observable<Effect>;
  36347. private _onApplyObserver;
  36348. /**
  36349. * A function that is added to the onApplyObservable
  36350. */
  36351. onApply: (effect: Effect) => void;
  36352. /**
  36353. * An event triggered before rendering the postprocess
  36354. */
  36355. onBeforeRenderObservable: Observable<Effect>;
  36356. private _onBeforeRenderObserver;
  36357. /**
  36358. * A function that is added to the onBeforeRenderObservable
  36359. */
  36360. onBeforeRender: (effect: Effect) => void;
  36361. /**
  36362. * An event triggered after rendering the postprocess
  36363. */
  36364. onAfterRenderObservable: Observable<Effect>;
  36365. private _onAfterRenderObserver;
  36366. /**
  36367. * A function that is added to the onAfterRenderObservable
  36368. */
  36369. onAfterRender: (efect: Effect) => void;
  36370. /**
  36371. * 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
  36372. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  36373. */
  36374. inputTexture: InternalTexture;
  36375. /**
  36376. * Gets the camera which post process is applied to.
  36377. * @returns The camera the post process is applied to.
  36378. */
  36379. getCamera(): Camera;
  36380. /**
  36381. * Gets the texel size of the postprocess.
  36382. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  36383. */
  36384. readonly texelSize: Vector2;
  36385. /**
  36386. * Creates a new instance PostProcess
  36387. * @param name The name of the PostProcess.
  36388. * @param fragmentUrl The url of the fragment shader to be used.
  36389. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  36390. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  36391. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  36392. * @param camera The camera to apply the render pass to.
  36393. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36394. * @param engine The engine which the post process will be applied. (default: current engine)
  36395. * @param reusable If the post process can be reused on the same frame. (default: false)
  36396. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  36397. * @param textureType Type of textures used when performing the post process. (default: 0)
  36398. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  36399. * @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
  36400. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  36401. */
  36402. constructor(
  36403. /** Name of the PostProcess. */
  36404. 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);
  36405. /**
  36406. * Gets the engine which this post process belongs to.
  36407. * @returns The engine the post process was enabled with.
  36408. */
  36409. getEngine(): Engine;
  36410. /**
  36411. * The effect that is created when initializing the post process.
  36412. * @returns The created effect corrisponding the the postprocess.
  36413. */
  36414. getEffect(): Effect;
  36415. /**
  36416. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  36417. * @param postProcess The post process to share the output with.
  36418. * @returns This post process.
  36419. */
  36420. shareOutputWith(postProcess: PostProcess): PostProcess;
  36421. /**
  36422. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  36423. * This should be called if the post process that shares output with this post process is disabled/disposed.
  36424. */
  36425. useOwnOutput(): void;
  36426. /**
  36427. * Updates the effect with the current post process compile time values and recompiles the shader.
  36428. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  36429. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  36430. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  36431. * @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
  36432. * @param onCompiled Called when the shader has been compiled.
  36433. * @param onError Called if there is an error when compiling a shader.
  36434. */
  36435. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  36436. /**
  36437. * The post process is reusable if it can be used multiple times within one frame.
  36438. * @returns If the post process is reusable
  36439. */
  36440. isReusable(): boolean;
  36441. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  36442. markTextureDirty(): void;
  36443. /**
  36444. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  36445. * 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.
  36446. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  36447. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  36448. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  36449. * @returns The target texture that was bound to be written to.
  36450. */
  36451. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  36452. /**
  36453. * If the post process is supported.
  36454. */
  36455. readonly isSupported: boolean;
  36456. /**
  36457. * The aspect ratio of the output texture.
  36458. */
  36459. readonly aspectRatio: number;
  36460. /**
  36461. * Get a value indicating if the post-process is ready to be used
  36462. * @returns true if the post-process is ready (shader is compiled)
  36463. */
  36464. isReady(): boolean;
  36465. /**
  36466. * Binds all textures and uniforms to the shader, this will be run on every pass.
  36467. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  36468. */
  36469. apply(): Nullable<Effect>;
  36470. private _disposeTextures;
  36471. /**
  36472. * Disposes the post process.
  36473. * @param camera The camera to dispose the post process on.
  36474. */
  36475. dispose(camera?: Camera): void;
  36476. }
  36477. }
  36478. declare module BABYLON {
  36479. /**
  36480. * PostProcessManager is used to manage one or more post processes or post process pipelines
  36481. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36482. */
  36483. class PostProcessManager {
  36484. private _scene;
  36485. private _indexBuffer;
  36486. private _vertexBuffers;
  36487. /**
  36488. * Creates a new instance PostProcess
  36489. * @param scene The scene that the post process is associated with.
  36490. */
  36491. constructor(scene: Scene);
  36492. private _prepareBuffers;
  36493. private _buildIndexBuffer;
  36494. /**
  36495. * Rebuilds the vertex buffers of the manager.
  36496. * @hidden
  36497. */
  36498. _rebuild(): void;
  36499. /**
  36500. * Prepares a frame to be run through a post process.
  36501. * @param sourceTexture The input texture to the post procesess. (default: null)
  36502. * @param postProcesses An array of post processes to be run. (default: null)
  36503. * @returns True if the post processes were able to be run.
  36504. * @hidden
  36505. */
  36506. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  36507. /**
  36508. * Manually render a set of post processes to a texture.
  36509. * @param postProcesses An array of post processes to be run.
  36510. * @param targetTexture The target texture to render to.
  36511. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  36512. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  36513. * @param lodLevel defines which lod of the texture to render to
  36514. */
  36515. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  36516. /**
  36517. * Finalize the result of the output of the postprocesses.
  36518. * @param doNotPresent If true the result will not be displayed to the screen.
  36519. * @param targetTexture The target texture to render to.
  36520. * @param faceIndex The index of the face to bind the target texture to.
  36521. * @param postProcesses The array of post processes to render.
  36522. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  36523. * @hidden
  36524. */
  36525. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  36526. /**
  36527. * Disposes of the post process manager.
  36528. */
  36529. dispose(): void;
  36530. }
  36531. }
  36532. declare module BABYLON {
  36533. /**
  36534. * Post process which applies a refractin texture
  36535. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  36536. */
  36537. class RefractionPostProcess extends PostProcess {
  36538. /** the base color of the refraction (used to taint the rendering) */
  36539. color: Color3;
  36540. /** simulated refraction depth */
  36541. depth: number;
  36542. /** the coefficient of the base color (0 to remove base color tainting) */
  36543. colorLevel: number;
  36544. private _refTexture;
  36545. private _ownRefractionTexture;
  36546. /**
  36547. * Gets or sets the refraction texture
  36548. * Please note that you are responsible for disposing the texture if you set it manually
  36549. */
  36550. refractionTexture: Texture;
  36551. /**
  36552. * Initializes the RefractionPostProcess
  36553. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  36554. * @param name The name of the effect.
  36555. * @param refractionTextureUrl Url of the refraction texture to use
  36556. * @param color the base color of the refraction (used to taint the rendering)
  36557. * @param depth simulated refraction depth
  36558. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  36559. * @param camera The camera to apply the render pass to.
  36560. * @param options The required width/height ratio to downsize to before computing the render pass.
  36561. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36562. * @param engine The engine which the post process will be applied. (default: current engine)
  36563. * @param reusable If the post process can be reused on the same frame. (default: false)
  36564. */
  36565. constructor(name: string, refractionTextureUrl: string,
  36566. /** the base color of the refraction (used to taint the rendering) */
  36567. color: Color3,
  36568. /** simulated refraction depth */
  36569. depth: number,
  36570. /** the coefficient of the base color (0 to remove base color tainting) */
  36571. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36572. /**
  36573. * Disposes of the post process
  36574. * @param camera Camera to dispose post process on
  36575. */
  36576. dispose(camera: Camera): void;
  36577. }
  36578. }
  36579. declare module BABYLON {
  36580. /**
  36581. * The SharpenPostProcess applies a sharpen kernel to every pixel
  36582. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  36583. */
  36584. class SharpenPostProcess extends PostProcess {
  36585. /**
  36586. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  36587. */
  36588. colorAmount: number;
  36589. /**
  36590. * How much sharpness should be applied (default: 0.3)
  36591. */
  36592. edgeAmount: number;
  36593. /**
  36594. * Creates a new instance ConvolutionPostProcess
  36595. * @param name The name of the effect.
  36596. * @param options The required width/height ratio to downsize to before computing the render pass.
  36597. * @param camera The camera to apply the render pass to.
  36598. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36599. * @param engine The engine which the post process will be applied. (default: current engine)
  36600. * @param reusable If the post process can be reused on the same frame. (default: false)
  36601. * @param textureType Type of textures used when performing the post process. (default: 0)
  36602. * @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)
  36603. */
  36604. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36605. }
  36606. }
  36607. declare module BABYLON {
  36608. /**
  36609. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  36610. */
  36611. class StereoscopicInterlacePostProcess extends PostProcess {
  36612. private _stepSize;
  36613. private _passedProcess;
  36614. /**
  36615. * Initializes a StereoscopicInterlacePostProcess
  36616. * @param name The name of the effect.
  36617. * @param rigCameras The rig cameras to be appled to the post process
  36618. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  36619. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36620. * @param engine The engine which the post process will be applied. (default: current engine)
  36621. * @param reusable If the post process can be reused on the same frame. (default: false)
  36622. */
  36623. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36624. }
  36625. }
  36626. declare module BABYLON {
  36627. /** Defines operator used for tonemapping */
  36628. enum TonemappingOperator {
  36629. /** Hable */
  36630. Hable = 0,
  36631. /** Reinhard */
  36632. Reinhard = 1,
  36633. /** HejiDawson */
  36634. HejiDawson = 2,
  36635. /** Photographic */
  36636. Photographic = 3
  36637. }
  36638. /**
  36639. * Defines a post process to apply tone mapping
  36640. */
  36641. class TonemapPostProcess extends PostProcess {
  36642. private _operator;
  36643. /** Defines the required exposure adjustement */
  36644. exposureAdjustment: number;
  36645. /**
  36646. * Creates a new TonemapPostProcess
  36647. * @param name defines the name of the postprocess
  36648. * @param _operator defines the operator to use
  36649. * @param exposureAdjustment defines the required exposure adjustement
  36650. * @param camera defines the camera to use (can be null)
  36651. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  36652. * @param engine defines the hosting engine (can be ignore if camera is set)
  36653. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  36654. */
  36655. constructor(name: string, _operator: TonemappingOperator,
  36656. /** Defines the required exposure adjustement */
  36657. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  36658. }
  36659. }
  36660. declare module BABYLON {
  36661. /**
  36662. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  36663. */
  36664. class VolumetricLightScatteringPostProcess extends PostProcess {
  36665. private _volumetricLightScatteringPass;
  36666. private _volumetricLightScatteringRTT;
  36667. private _viewPort;
  36668. private _screenCoordinates;
  36669. private _cachedDefines;
  36670. /**
  36671. * If not undefined, the mesh position is computed from the attached node position
  36672. */
  36673. attachedNode: {
  36674. position: Vector3;
  36675. };
  36676. /**
  36677. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  36678. */
  36679. customMeshPosition: Vector3;
  36680. /**
  36681. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  36682. */
  36683. useCustomMeshPosition: boolean;
  36684. /**
  36685. * If the post-process should inverse the light scattering direction
  36686. */
  36687. invert: boolean;
  36688. /**
  36689. * The internal mesh used by the post-process
  36690. */
  36691. mesh: Mesh;
  36692. /**
  36693. * @hidden
  36694. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  36695. */
  36696. useDiffuseColor: boolean;
  36697. /**
  36698. * Array containing the excluded meshes not rendered in the internal pass
  36699. */
  36700. excludedMeshes: AbstractMesh[];
  36701. /**
  36702. * Controls the overall intensity of the post-process
  36703. */
  36704. exposure: number;
  36705. /**
  36706. * Dissipates each sample's contribution in range [0, 1]
  36707. */
  36708. decay: number;
  36709. /**
  36710. * Controls the overall intensity of each sample
  36711. */
  36712. weight: number;
  36713. /**
  36714. * Controls the density of each sample
  36715. */
  36716. density: number;
  36717. /**
  36718. * @constructor
  36719. * @param name The post-process name
  36720. * @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)
  36721. * @param camera The camera that the post-process will be attached to
  36722. * @param mesh The mesh used to create the light scattering
  36723. * @param samples The post-process quality, default 100
  36724. * @param samplingModeThe post-process filtering mode
  36725. * @param engine The babylon engine
  36726. * @param reusable If the post-process is reusable
  36727. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  36728. */
  36729. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  36730. /**
  36731. * Returns the string "VolumetricLightScatteringPostProcess"
  36732. * @returns "VolumetricLightScatteringPostProcess"
  36733. */
  36734. getClassName(): string;
  36735. private _isReady;
  36736. /**
  36737. * Sets the new light position for light scattering effect
  36738. * @param position The new custom light position
  36739. */
  36740. setCustomMeshPosition(position: Vector3): void;
  36741. /**
  36742. * Returns the light position for light scattering effect
  36743. * @return Vector3 The custom light position
  36744. */
  36745. getCustomMeshPosition(): Vector3;
  36746. /**
  36747. * Disposes the internal assets and detaches the post-process from the camera
  36748. */
  36749. dispose(camera: Camera): void;
  36750. /**
  36751. * Returns the render target texture used by the post-process
  36752. * @return the render target texture used by the post-process
  36753. */
  36754. getPass(): RenderTargetTexture;
  36755. private _meshExcluded;
  36756. private _createPass;
  36757. private _updateMeshScreenCoordinates;
  36758. /**
  36759. * Creates a default mesh for the Volumeric Light Scattering post-process
  36760. * @param name The mesh name
  36761. * @param scene The scene where to create the mesh
  36762. * @return the default mesh
  36763. */
  36764. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  36765. }
  36766. }
  36767. declare module BABYLON {
  36768. /**
  36769. * VRDistortionCorrectionPostProcess used for mobile VR
  36770. */
  36771. class VRDistortionCorrectionPostProcess extends PostProcess {
  36772. private _isRightEye;
  36773. private _distortionFactors;
  36774. private _postProcessScaleFactor;
  36775. private _lensCenterOffset;
  36776. private _scaleIn;
  36777. private _scaleFactor;
  36778. private _lensCenter;
  36779. /**
  36780. * Initializes the VRDistortionCorrectionPostProcess
  36781. * @param name The name of the effect.
  36782. * @param camera The camera to apply the render pass to.
  36783. * @param isRightEye If this is for the right eye distortion
  36784. * @param vrMetrics All the required metrics for the VR camera
  36785. */
  36786. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  36787. }
  36788. }
  36789. declare module BABYLON {
  36790. /**
  36791. * Class used to represent a sprite
  36792. * @see http://doc.babylonjs.com/babylon101/sprites
  36793. */
  36794. class Sprite {
  36795. /** defines the name */
  36796. name: string;
  36797. /** Gets or sets the current world position */
  36798. position: Vector3;
  36799. /** Gets or sets the main color */
  36800. color: Color4;
  36801. /** Gets or sets the width */
  36802. width: number;
  36803. /** Gets or sets the height */
  36804. height: number;
  36805. /** Gets or sets rotation angle */
  36806. angle: number;
  36807. /** Gets or sets the cell index in the sprite sheet */
  36808. cellIndex: number;
  36809. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  36810. invertU: number;
  36811. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  36812. invertV: number;
  36813. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  36814. disposeWhenFinishedAnimating: boolean;
  36815. /** Gets the list of attached animations */
  36816. animations: Animation[];
  36817. /** Gets or sets a boolean indicating if the sprite can be picked */
  36818. isPickable: boolean;
  36819. /**
  36820. * Gets or sets the associated action manager
  36821. */
  36822. actionManager: Nullable<ActionManager>;
  36823. private _animationStarted;
  36824. private _loopAnimation;
  36825. private _fromIndex;
  36826. private _toIndex;
  36827. private _delay;
  36828. private _direction;
  36829. private _manager;
  36830. private _time;
  36831. private _onAnimationEnd;
  36832. /**
  36833. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  36834. */
  36835. isVisible: boolean;
  36836. /**
  36837. * Gets or sets the sprite size
  36838. */
  36839. size: number;
  36840. /**
  36841. * Creates a new Sprite
  36842. * @param name defines the name
  36843. * @param manager defines the manager
  36844. */
  36845. constructor(
  36846. /** defines the name */
  36847. name: string, manager: ISpriteManager);
  36848. /**
  36849. * Starts an animation
  36850. * @param from defines the initial key
  36851. * @param to defines the end key
  36852. * @param loop defines if the animation must loop
  36853. * @param delay defines the start delay (in ms)
  36854. * @param onAnimationEnd defines a callback to call when animation ends
  36855. */
  36856. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  36857. /** Stops current animation (if any) */
  36858. stopAnimation(): void;
  36859. /** @hidden */
  36860. _animate(deltaTime: number): void;
  36861. /** Release associated resources */
  36862. dispose(): void;
  36863. }
  36864. }
  36865. declare module BABYLON {
  36866. /**
  36867. * Defines the minimum interface to fullfil in order to be a sprite manager.
  36868. */
  36869. interface ISpriteManager extends IDisposable {
  36870. /**
  36871. * Restricts the camera to viewing objects with the same layerMask.
  36872. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  36873. */
  36874. layerMask: number;
  36875. /**
  36876. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36877. */
  36878. isPickable: boolean;
  36879. /**
  36880. * Specifies the rendering group id for this mesh (0 by default)
  36881. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36882. */
  36883. renderingGroupId: number;
  36884. /**
  36885. * Defines the list of sprites managed by the manager.
  36886. */
  36887. sprites: Array<Sprite>;
  36888. /**
  36889. * Tests the intersection of a sprite with a specific ray.
  36890. * @param ray The ray we are sending to test the collision
  36891. * @param camera The camera space we are sending rays in
  36892. * @param predicate A predicate allowing excluding sprites from the list of object to test
  36893. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  36894. * @returns picking info or null.
  36895. */
  36896. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36897. /**
  36898. * Renders the list of sprites on screen.
  36899. */
  36900. render(): void;
  36901. }
  36902. /**
  36903. * Class used to manage multiple sprites on the same spritesheet
  36904. * @see http://doc.babylonjs.com/babylon101/sprites
  36905. */
  36906. class SpriteManager implements ISpriteManager {
  36907. /** defines the manager's name */
  36908. name: string;
  36909. /** Gets the list of sprites */
  36910. sprites: Sprite[];
  36911. /** Gets or sets the rendering group id (0 by default) */
  36912. renderingGroupId: number;
  36913. /** Gets or sets camera layer mask */
  36914. layerMask: number;
  36915. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  36916. fogEnabled: boolean;
  36917. /** Gets or sets a boolean indicating if the sprites are pickable */
  36918. isPickable: boolean;
  36919. /** Defines the default width of a cell in the spritesheet */
  36920. cellWidth: number;
  36921. /** Defines the default height of a cell in the spritesheet */
  36922. cellHeight: number;
  36923. /**
  36924. * An event triggered when the manager is disposed.
  36925. */
  36926. onDisposeObservable: Observable<SpriteManager>;
  36927. private _onDisposeObserver;
  36928. /**
  36929. * Callback called when the manager is disposed
  36930. */
  36931. onDispose: () => void;
  36932. private _capacity;
  36933. private _spriteTexture;
  36934. private _epsilon;
  36935. private _scene;
  36936. private _vertexData;
  36937. private _buffer;
  36938. private _vertexBuffers;
  36939. private _indexBuffer;
  36940. private _effectBase;
  36941. private _effectFog;
  36942. /**
  36943. * Gets or sets the spritesheet texture
  36944. */
  36945. texture: Texture;
  36946. /**
  36947. * Creates a new sprite manager
  36948. * @param name defines the manager's name
  36949. * @param imgUrl defines the sprite sheet url
  36950. * @param capacity defines the maximum allowed number of sprites
  36951. * @param cellSize defines the size of a sprite cell
  36952. * @param scene defines the hosting scene
  36953. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  36954. * @param samplingMode defines the smapling mode to use with spritesheet
  36955. */
  36956. constructor(
  36957. /** defines the manager's name */
  36958. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  36959. private _appendSpriteVertex;
  36960. /**
  36961. * Intersects the sprites with a ray
  36962. * @param ray defines the ray to intersect with
  36963. * @param camera defines the current active camera
  36964. * @param predicate defines a predicate used to select candidate sprites
  36965. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  36966. * @returns null if no hit or a PickingInfo
  36967. */
  36968. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36969. /**
  36970. * Render all child sprites
  36971. */
  36972. render(): void;
  36973. /**
  36974. * Release associated resources
  36975. */
  36976. dispose(): void;
  36977. }
  36978. }
  36979. declare module BABYLON {
  36980. interface Scene {
  36981. /** @hidden */
  36982. _pointerOverSprite: Nullable<Sprite>;
  36983. /** @hidden */
  36984. _pickedDownSprite: Nullable<Sprite>;
  36985. /** @hidden */
  36986. _tempSpritePickingRay: Nullable<Ray>;
  36987. /**
  36988. * All of the sprite managers added to this scene
  36989. * @see http://doc.babylonjs.com/babylon101/sprites
  36990. */
  36991. spriteManagers: Array<ISpriteManager>;
  36992. /**
  36993. * An event triggered when sprites rendering is about to start
  36994. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  36995. */
  36996. onBeforeSpritesRenderingObservable: Observable<Scene>;
  36997. /**
  36998. * An event triggered when sprites rendering is done
  36999. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  37000. */
  37001. onAfterSpritesRenderingObservable: Observable<Scene>;
  37002. /** @hidden */
  37003. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37004. /** Launch a ray to try to pick a sprite in the scene
  37005. * @param x position on screen
  37006. * @param y position on screen
  37007. * @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
  37008. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37009. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37010. * @returns a PickingInfo
  37011. */
  37012. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37013. /** Use the given ray to pick a sprite in the scene
  37014. * @param ray The ray (in world space) to use to pick meshes
  37015. * @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
  37016. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37017. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  37018. * @returns a PickingInfo
  37019. */
  37020. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37021. /**
  37022. * Force the sprite under the pointer
  37023. * @param sprite defines the sprite to use
  37024. */
  37025. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  37026. /**
  37027. * Gets the sprite under the pointer
  37028. * @returns a Sprite or null if no sprite is under the pointer
  37029. */
  37030. getPointerOverSprite(): Nullable<Sprite>;
  37031. }
  37032. /**
  37033. * Defines the sprite scene component responsible to manage sprites
  37034. * in a given scene.
  37035. */
  37036. class SpriteSceneComponent implements ISceneComponent {
  37037. /**
  37038. * The component name helpfull to identify the component in the list of scene components.
  37039. */
  37040. readonly name: string;
  37041. /**
  37042. * The scene the component belongs to.
  37043. */
  37044. scene: Scene;
  37045. /** @hidden */
  37046. private _spritePredicate;
  37047. /**
  37048. * Creates a new instance of the component for the given scene
  37049. * @param scene Defines the scene to register the component in
  37050. */
  37051. constructor(scene: Scene);
  37052. /**
  37053. * Registers the component in a given scene
  37054. */
  37055. register(): void;
  37056. /**
  37057. * Rebuilds the elements related to this component in case of
  37058. * context lost for instance.
  37059. */
  37060. rebuild(): void;
  37061. /**
  37062. * Disposes the component and the associated ressources.
  37063. */
  37064. dispose(): void;
  37065. private _pickSpriteButKeepRay;
  37066. private _pointerMove;
  37067. private _pointerDown;
  37068. private _pointerUp;
  37069. }
  37070. }
  37071. declare module BABYLON {
  37072. /**
  37073. * @hidden
  37074. **/
  37075. class _AlphaState {
  37076. private _isAlphaBlendDirty;
  37077. private _isBlendFunctionParametersDirty;
  37078. private _isBlendEquationParametersDirty;
  37079. private _isBlendConstantsDirty;
  37080. private _alphaBlend;
  37081. private _blendFunctionParameters;
  37082. private _blendEquationParameters;
  37083. private _blendConstants;
  37084. /**
  37085. * Initializes the state.
  37086. */
  37087. constructor();
  37088. readonly isDirty: boolean;
  37089. alphaBlend: boolean;
  37090. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  37091. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  37092. setAlphaEquationParameters(rgb: number, alpha: number): void;
  37093. reset(): void;
  37094. apply(gl: WebGLRenderingContext): void;
  37095. }
  37096. }
  37097. declare module BABYLON {
  37098. /**
  37099. * @hidden
  37100. **/
  37101. class _DepthCullingState {
  37102. private _isDepthTestDirty;
  37103. private _isDepthMaskDirty;
  37104. private _isDepthFuncDirty;
  37105. private _isCullFaceDirty;
  37106. private _isCullDirty;
  37107. private _isZOffsetDirty;
  37108. private _isFrontFaceDirty;
  37109. private _depthTest;
  37110. private _depthMask;
  37111. private _depthFunc;
  37112. private _cull;
  37113. private _cullFace;
  37114. private _zOffset;
  37115. private _frontFace;
  37116. /**
  37117. * Initializes the state.
  37118. */
  37119. constructor();
  37120. readonly isDirty: boolean;
  37121. zOffset: number;
  37122. cullFace: Nullable<number>;
  37123. cull: Nullable<boolean>;
  37124. depthFunc: Nullable<number>;
  37125. depthMask: boolean;
  37126. depthTest: boolean;
  37127. frontFace: Nullable<number>;
  37128. reset(): void;
  37129. apply(gl: WebGLRenderingContext): void;
  37130. }
  37131. }
  37132. declare module BABYLON {
  37133. /**
  37134. * @hidden
  37135. **/
  37136. class _StencilState {
  37137. private _isStencilTestDirty;
  37138. private _isStencilMaskDirty;
  37139. private _isStencilFuncDirty;
  37140. private _isStencilOpDirty;
  37141. private _stencilTest;
  37142. private _stencilMask;
  37143. private _stencilFunc;
  37144. private _stencilFuncRef;
  37145. private _stencilFuncMask;
  37146. private _stencilOpStencilFail;
  37147. private _stencilOpDepthFail;
  37148. private _stencilOpStencilDepthPass;
  37149. readonly isDirty: boolean;
  37150. stencilFunc: number;
  37151. stencilFuncRef: number;
  37152. stencilFuncMask: number;
  37153. stencilOpStencilFail: number;
  37154. stencilOpDepthFail: number;
  37155. stencilOpStencilDepthPass: number;
  37156. stencilMask: number;
  37157. stencilTest: boolean;
  37158. constructor();
  37159. reset(): void;
  37160. apply(gl: WebGLRenderingContext): void;
  37161. }
  37162. }
  37163. declare module BABYLON {
  37164. /**
  37165. * Class used to evalaute queries containing `and` and `or` operators
  37166. */
  37167. class AndOrNotEvaluator {
  37168. /**
  37169. * Evaluate a query
  37170. * @param query defines the query to evaluate
  37171. * @param evaluateCallback defines the callback used to filter result
  37172. * @returns true if the query matches
  37173. */
  37174. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  37175. private static _HandleParenthesisContent;
  37176. private static _SimplifyNegation;
  37177. }
  37178. }
  37179. declare module BABYLON {
  37180. /**
  37181. * Defines the list of states available for a task inside a AssetsManager
  37182. */
  37183. enum AssetTaskState {
  37184. /**
  37185. * Initialization
  37186. */
  37187. INIT = 0,
  37188. /**
  37189. * Running
  37190. */
  37191. RUNNING = 1,
  37192. /**
  37193. * Done
  37194. */
  37195. DONE = 2,
  37196. /**
  37197. * Error
  37198. */
  37199. ERROR = 3
  37200. }
  37201. /**
  37202. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  37203. */
  37204. abstract class AbstractAssetTask {
  37205. /**
  37206. * Task name
  37207. */ name: string;
  37208. /**
  37209. * Callback called when the task is successful
  37210. */
  37211. onSuccess: (task: any) => void;
  37212. /**
  37213. * Callback called when the task is not successful
  37214. */
  37215. onError: (task: any, message?: string, exception?: any) => void;
  37216. /**
  37217. * Creates a new AssetsManager
  37218. * @param name defines the name of the task
  37219. */
  37220. constructor(
  37221. /**
  37222. * Task name
  37223. */ name: string);
  37224. private _isCompleted;
  37225. private _taskState;
  37226. private _errorObject;
  37227. /**
  37228. * Get if the task is completed
  37229. */
  37230. readonly isCompleted: boolean;
  37231. /**
  37232. * Gets the current state of the task
  37233. */
  37234. readonly taskState: AssetTaskState;
  37235. /**
  37236. * Gets the current error object (if task is in error)
  37237. */
  37238. readonly errorObject: {
  37239. message?: string;
  37240. exception?: any;
  37241. };
  37242. /**
  37243. * Internal only
  37244. * @hidden
  37245. */
  37246. _setErrorObject(message?: string, exception?: any): void;
  37247. /**
  37248. * Execute the current task
  37249. * @param scene defines the scene where you want your assets to be loaded
  37250. * @param onSuccess is a callback called when the task is successfully executed
  37251. * @param onError is a callback called if an error occurs
  37252. */
  37253. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37254. /**
  37255. * Execute the current task
  37256. * @param scene defines the scene where you want your assets to be loaded
  37257. * @param onSuccess is a callback called when the task is successfully executed
  37258. * @param onError is a callback called if an error occurs
  37259. */
  37260. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37261. /**
  37262. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  37263. * This can be used with failed tasks that have the reason for failure fixed.
  37264. */
  37265. reset(): void;
  37266. private onErrorCallback;
  37267. private onDoneCallback;
  37268. }
  37269. /**
  37270. * Define the interface used by progress events raised during assets loading
  37271. */
  37272. interface IAssetsProgressEvent {
  37273. /**
  37274. * Defines the number of remaining tasks to process
  37275. */
  37276. remainingCount: number;
  37277. /**
  37278. * Defines the total number of tasks
  37279. */
  37280. totalCount: number;
  37281. /**
  37282. * Defines the task that was just processed
  37283. */
  37284. task: AbstractAssetTask;
  37285. }
  37286. /**
  37287. * Class used to share progress information about assets loading
  37288. */
  37289. class AssetsProgressEvent implements IAssetsProgressEvent {
  37290. /**
  37291. * Defines the number of remaining tasks to process
  37292. */
  37293. remainingCount: number;
  37294. /**
  37295. * Defines the total number of tasks
  37296. */
  37297. totalCount: number;
  37298. /**
  37299. * Defines the task that was just processed
  37300. */
  37301. task: AbstractAssetTask;
  37302. /**
  37303. * Creates a AssetsProgressEvent
  37304. * @param remainingCount defines the number of remaining tasks to process
  37305. * @param totalCount defines the total number of tasks
  37306. * @param task defines the task that was just processed
  37307. */
  37308. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  37309. }
  37310. /**
  37311. * Define a task used by AssetsManager to load meshes
  37312. */
  37313. class MeshAssetTask extends AbstractAssetTask {
  37314. /**
  37315. * Defines the name of the task
  37316. */
  37317. name: string;
  37318. /**
  37319. * Defines the list of mesh's names you want to load
  37320. */
  37321. meshesNames: any;
  37322. /**
  37323. * Defines the root url to use as a base to load your meshes and associated resources
  37324. */
  37325. rootUrl: string;
  37326. /**
  37327. * Defines the filename of the scene to load from
  37328. */
  37329. sceneFilename: string;
  37330. /**
  37331. * Gets the list of loaded meshes
  37332. */
  37333. loadedMeshes: Array<AbstractMesh>;
  37334. /**
  37335. * Gets the list of loaded particle systems
  37336. */
  37337. loadedParticleSystems: Array<IParticleSystem>;
  37338. /**
  37339. * Gets the list of loaded skeletons
  37340. */
  37341. loadedSkeletons: Array<Skeleton>;
  37342. /**
  37343. * Callback called when the task is successful
  37344. */
  37345. onSuccess: (task: MeshAssetTask) => void;
  37346. /**
  37347. * Callback called when the task is successful
  37348. */
  37349. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  37350. /**
  37351. * Creates a new MeshAssetTask
  37352. * @param name defines the name of the task
  37353. * @param meshesNames defines the list of mesh's names you want to load
  37354. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  37355. * @param sceneFilename defines the filename of the scene to load from
  37356. */
  37357. constructor(
  37358. /**
  37359. * Defines the name of the task
  37360. */
  37361. name: string,
  37362. /**
  37363. * Defines the list of mesh's names you want to load
  37364. */
  37365. meshesNames: any,
  37366. /**
  37367. * Defines the root url to use as a base to load your meshes and associated resources
  37368. */
  37369. rootUrl: string,
  37370. /**
  37371. * Defines the filename of the scene to load from
  37372. */
  37373. sceneFilename: string);
  37374. /**
  37375. * Execute the current task
  37376. * @param scene defines the scene where you want your assets to be loaded
  37377. * @param onSuccess is a callback called when the task is successfully executed
  37378. * @param onError is a callback called if an error occurs
  37379. */
  37380. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37381. }
  37382. /**
  37383. * Define a task used by AssetsManager to load text content
  37384. */
  37385. class TextFileAssetTask extends AbstractAssetTask {
  37386. /**
  37387. * Defines the name of the task
  37388. */
  37389. name: string;
  37390. /**
  37391. * Defines the location of the file to load
  37392. */
  37393. url: string;
  37394. /**
  37395. * Gets the loaded text string
  37396. */
  37397. text: string;
  37398. /**
  37399. * Callback called when the task is successful
  37400. */
  37401. onSuccess: (task: TextFileAssetTask) => void;
  37402. /**
  37403. * Callback called when the task is successful
  37404. */
  37405. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  37406. /**
  37407. * Creates a new TextFileAssetTask object
  37408. * @param name defines the name of the task
  37409. * @param url defines the location of the file to load
  37410. */
  37411. constructor(
  37412. /**
  37413. * Defines the name of the task
  37414. */
  37415. name: string,
  37416. /**
  37417. * Defines the location of the file to load
  37418. */
  37419. url: string);
  37420. /**
  37421. * Execute the current task
  37422. * @param scene defines the scene where you want your assets to be loaded
  37423. * @param onSuccess is a callback called when the task is successfully executed
  37424. * @param onError is a callback called if an error occurs
  37425. */
  37426. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37427. }
  37428. /**
  37429. * Define a task used by AssetsManager to load binary data
  37430. */
  37431. class BinaryFileAssetTask extends AbstractAssetTask {
  37432. /**
  37433. * Defines the name of the task
  37434. */
  37435. name: string;
  37436. /**
  37437. * Defines the location of the file to load
  37438. */
  37439. url: string;
  37440. /**
  37441. * Gets the lodaded data (as an array buffer)
  37442. */
  37443. data: ArrayBuffer;
  37444. /**
  37445. * Callback called when the task is successful
  37446. */
  37447. onSuccess: (task: BinaryFileAssetTask) => void;
  37448. /**
  37449. * Callback called when the task is successful
  37450. */
  37451. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  37452. /**
  37453. * Creates a new BinaryFileAssetTask object
  37454. * @param name defines the name of the new task
  37455. * @param url defines the location of the file to load
  37456. */
  37457. constructor(
  37458. /**
  37459. * Defines the name of the task
  37460. */
  37461. name: string,
  37462. /**
  37463. * Defines the location of the file to load
  37464. */
  37465. url: string);
  37466. /**
  37467. * Execute the current task
  37468. * @param scene defines the scene where you want your assets to be loaded
  37469. * @param onSuccess is a callback called when the task is successfully executed
  37470. * @param onError is a callback called if an error occurs
  37471. */
  37472. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37473. }
  37474. /**
  37475. * Define a task used by AssetsManager to load images
  37476. */
  37477. class ImageAssetTask extends AbstractAssetTask {
  37478. /**
  37479. * Defines the name of the task
  37480. */
  37481. name: string;
  37482. /**
  37483. * Defines the location of the image to load
  37484. */
  37485. url: string;
  37486. /**
  37487. * Gets the loaded images
  37488. */
  37489. image: HTMLImageElement;
  37490. /**
  37491. * Callback called when the task is successful
  37492. */
  37493. onSuccess: (task: ImageAssetTask) => void;
  37494. /**
  37495. * Callback called when the task is successful
  37496. */
  37497. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  37498. /**
  37499. * Creates a new ImageAssetTask
  37500. * @param name defines the name of the task
  37501. * @param url defines the location of the image to load
  37502. */
  37503. constructor(
  37504. /**
  37505. * Defines the name of the task
  37506. */
  37507. name: string,
  37508. /**
  37509. * Defines the location of the image to load
  37510. */
  37511. url: string);
  37512. /**
  37513. * Execute the current task
  37514. * @param scene defines the scene where you want your assets to be loaded
  37515. * @param onSuccess is a callback called when the task is successfully executed
  37516. * @param onError is a callback called if an error occurs
  37517. */
  37518. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37519. }
  37520. /**
  37521. * Defines the interface used by texture loading tasks
  37522. */
  37523. interface ITextureAssetTask<TEX extends BaseTexture> {
  37524. /**
  37525. * Gets the loaded texture
  37526. */
  37527. texture: TEX;
  37528. }
  37529. /**
  37530. * Define a task used by AssetsManager to load 2D textures
  37531. */
  37532. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  37533. /**
  37534. * Defines the name of the task
  37535. */
  37536. name: string;
  37537. /**
  37538. * Defines the location of the file to load
  37539. */
  37540. url: string;
  37541. /**
  37542. * Defines if mipmap should not be generated (default is false)
  37543. */
  37544. noMipmap?: boolean | undefined;
  37545. /**
  37546. * Defines if texture must be inverted on Y axis (default is false)
  37547. */
  37548. invertY?: boolean | undefined;
  37549. /**
  37550. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37551. */
  37552. samplingMode: number;
  37553. /**
  37554. * Gets the loaded texture
  37555. */
  37556. texture: Texture;
  37557. /**
  37558. * Callback called when the task is successful
  37559. */
  37560. onSuccess: (task: TextureAssetTask) => void;
  37561. /**
  37562. * Callback called when the task is successful
  37563. */
  37564. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  37565. /**
  37566. * Creates a new TextureAssetTask object
  37567. * @param name defines the name of the task
  37568. * @param url defines the location of the file to load
  37569. * @param noMipmap defines if mipmap should not be generated (default is false)
  37570. * @param invertY defines if texture must be inverted on Y axis (default is false)
  37571. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37572. */
  37573. constructor(
  37574. /**
  37575. * Defines the name of the task
  37576. */
  37577. name: string,
  37578. /**
  37579. * Defines the location of the file to load
  37580. */
  37581. url: string,
  37582. /**
  37583. * Defines if mipmap should not be generated (default is false)
  37584. */
  37585. noMipmap?: boolean | undefined,
  37586. /**
  37587. * Defines if texture must be inverted on Y axis (default is false)
  37588. */
  37589. invertY?: boolean | undefined,
  37590. /**
  37591. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37592. */
  37593. samplingMode?: number);
  37594. /**
  37595. * Execute the current task
  37596. * @param scene defines the scene where you want your assets to be loaded
  37597. * @param onSuccess is a callback called when the task is successfully executed
  37598. * @param onError is a callback called if an error occurs
  37599. */
  37600. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37601. }
  37602. /**
  37603. * Define a task used by AssetsManager to load cube textures
  37604. */
  37605. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37606. /**
  37607. * Defines the name of the task
  37608. */
  37609. name: string;
  37610. /**
  37611. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37612. */
  37613. url: string;
  37614. /**
  37615. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37616. */
  37617. extensions?: string[] | undefined;
  37618. /**
  37619. * Defines if mipmaps should not be generated (default is false)
  37620. */
  37621. noMipmap?: boolean | undefined;
  37622. /**
  37623. * Defines the explicit list of files (undefined by default)
  37624. */
  37625. files?: string[] | undefined;
  37626. /**
  37627. * Gets the loaded texture
  37628. */
  37629. texture: CubeTexture;
  37630. /**
  37631. * Callback called when the task is successful
  37632. */
  37633. onSuccess: (task: CubeTextureAssetTask) => void;
  37634. /**
  37635. * Callback called when the task is successful
  37636. */
  37637. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37638. /**
  37639. * Creates a new CubeTextureAssetTask
  37640. * @param name defines the name of the task
  37641. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37642. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37643. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37644. * @param files defines the explicit list of files (undefined by default)
  37645. */
  37646. constructor(
  37647. /**
  37648. * Defines the name of the task
  37649. */
  37650. name: string,
  37651. /**
  37652. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37653. */
  37654. url: string,
  37655. /**
  37656. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37657. */
  37658. extensions?: string[] | undefined,
  37659. /**
  37660. * Defines if mipmaps should not be generated (default is false)
  37661. */
  37662. noMipmap?: boolean | undefined,
  37663. /**
  37664. * Defines the explicit list of files (undefined by default)
  37665. */
  37666. files?: string[] | undefined);
  37667. /**
  37668. * Execute the current task
  37669. * @param scene defines the scene where you want your assets to be loaded
  37670. * @param onSuccess is a callback called when the task is successfully executed
  37671. * @param onError is a callback called if an error occurs
  37672. */
  37673. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37674. }
  37675. /**
  37676. * Define a task used by AssetsManager to load HDR cube textures
  37677. */
  37678. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37679. /**
  37680. * Defines the name of the task
  37681. */
  37682. name: string;
  37683. /**
  37684. * Defines the location of the file to load
  37685. */
  37686. url: string;
  37687. /**
  37688. * Defines the desired size (the more it increases the longer the generation will be)
  37689. */
  37690. size: number;
  37691. /**
  37692. * Defines if mipmaps should not be generated (default is false)
  37693. */
  37694. noMipmap: boolean;
  37695. /**
  37696. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37697. */
  37698. generateHarmonics: boolean;
  37699. /**
  37700. * 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)
  37701. */
  37702. gammaSpace: boolean;
  37703. /**
  37704. * Internal Use Only
  37705. */
  37706. reserved: boolean;
  37707. /**
  37708. * Gets the loaded texture
  37709. */
  37710. texture: HDRCubeTexture;
  37711. /**
  37712. * Callback called when the task is successful
  37713. */
  37714. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37715. /**
  37716. * Callback called when the task is successful
  37717. */
  37718. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37719. /**
  37720. * Creates a new HDRCubeTextureAssetTask object
  37721. * @param name defines the name of the task
  37722. * @param url defines the location of the file to load
  37723. * @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.
  37724. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37725. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37726. * @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)
  37727. * @param reserved Internal use only
  37728. */
  37729. constructor(
  37730. /**
  37731. * Defines the name of the task
  37732. */
  37733. name: string,
  37734. /**
  37735. * Defines the location of the file to load
  37736. */
  37737. url: string,
  37738. /**
  37739. * Defines the desired size (the more it increases the longer the generation will be)
  37740. */
  37741. size: number,
  37742. /**
  37743. * Defines if mipmaps should not be generated (default is false)
  37744. */
  37745. noMipmap?: boolean,
  37746. /**
  37747. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37748. */
  37749. generateHarmonics?: boolean,
  37750. /**
  37751. * 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)
  37752. */
  37753. gammaSpace?: boolean,
  37754. /**
  37755. * Internal Use Only
  37756. */
  37757. reserved?: boolean);
  37758. /**
  37759. * Execute the current task
  37760. * @param scene defines the scene where you want your assets to be loaded
  37761. * @param onSuccess is a callback called when the task is successfully executed
  37762. * @param onError is a callback called if an error occurs
  37763. */
  37764. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37765. }
  37766. /**
  37767. * This class can be used to easily import assets into a scene
  37768. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37769. */
  37770. class AssetsManager {
  37771. private _scene;
  37772. private _isLoading;
  37773. protected _tasks: AbstractAssetTask[];
  37774. protected _waitingTasksCount: number;
  37775. protected _totalTasksCount: number;
  37776. /**
  37777. * Callback called when all tasks are processed
  37778. */
  37779. onFinish: (tasks: AbstractAssetTask[]) => void;
  37780. /**
  37781. * Callback called when a task is successful
  37782. */
  37783. onTaskSuccess: (task: AbstractAssetTask) => void;
  37784. /**
  37785. * Callback called when a task had an error
  37786. */
  37787. onTaskError: (task: AbstractAssetTask) => void;
  37788. /**
  37789. * Callback called when a task is done (whatever the result is)
  37790. */
  37791. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37792. /**
  37793. * Observable called when all tasks are processed
  37794. */
  37795. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37796. /**
  37797. * Observable called when a task had an error
  37798. */
  37799. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37800. /**
  37801. * Observable called when a task is successful
  37802. */
  37803. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37804. /**
  37805. * Observable called when a task is done (whatever the result is)
  37806. */
  37807. onProgressObservable: Observable<IAssetsProgressEvent>;
  37808. /**
  37809. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37810. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37811. */
  37812. useDefaultLoadingScreen: boolean;
  37813. /**
  37814. * Creates a new AssetsManager
  37815. * @param scene defines the scene to work on
  37816. */
  37817. constructor(scene: Scene);
  37818. /**
  37819. * Add a MeshAssetTask to the list of active tasks
  37820. * @param taskName defines the name of the new task
  37821. * @param meshesNames defines the name of meshes to load
  37822. * @param rootUrl defines the root url to use to locate files
  37823. * @param sceneFilename defines the filename of the scene file
  37824. * @returns a new MeshAssetTask object
  37825. */
  37826. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37827. /**
  37828. * Add a TextFileAssetTask to the list of active tasks
  37829. * @param taskName defines the name of the new task
  37830. * @param url defines the url of the file to load
  37831. * @returns a new TextFileAssetTask object
  37832. */
  37833. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37834. /**
  37835. * Add a BinaryFileAssetTask to the list of active tasks
  37836. * @param taskName defines the name of the new task
  37837. * @param url defines the url of the file to load
  37838. * @returns a new BinaryFileAssetTask object
  37839. */
  37840. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37841. /**
  37842. * Add a ImageAssetTask to the list of active tasks
  37843. * @param taskName defines the name of the new task
  37844. * @param url defines the url of the file to load
  37845. * @returns a new ImageAssetTask object
  37846. */
  37847. addImageTask(taskName: string, url: string): ImageAssetTask;
  37848. /**
  37849. * Add a TextureAssetTask to the list of active tasks
  37850. * @param taskName defines the name of the new task
  37851. * @param url defines the url of the file to load
  37852. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37853. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37854. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37855. * @returns a new TextureAssetTask object
  37856. */
  37857. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  37858. /**
  37859. * Add a CubeTextureAssetTask to the list of active tasks
  37860. * @param taskName defines the name of the new task
  37861. * @param url defines the url of the file to load
  37862. * @param extensions defines the extension to use to load the cube map (can be null)
  37863. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37864. * @param files defines the list of files to load (can be null)
  37865. * @returns a new CubeTextureAssetTask object
  37866. */
  37867. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  37868. /**
  37869. *
  37870. * Add a HDRCubeTextureAssetTask to the list of active tasks
  37871. * @param taskName defines the name of the new task
  37872. * @param url defines the url of the file to load
  37873. * @param size defines the size you want for the cubemap (can be null)
  37874. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37875. * @param generateHarmonics defines if you want to automatically generate (true by default)
  37876. * @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)
  37877. * @param reserved Internal use only
  37878. * @returns a new HDRCubeTextureAssetTask object
  37879. */
  37880. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  37881. /**
  37882. * Remove a task from the assets manager.
  37883. * @param task the task to remove
  37884. */
  37885. removeTask(task: AbstractAssetTask): void;
  37886. private _decreaseWaitingTasksCount;
  37887. private _runTask;
  37888. /**
  37889. * Reset the AssetsManager and remove all tasks
  37890. * @return the current instance of the AssetsManager
  37891. */
  37892. reset(): AssetsManager;
  37893. /**
  37894. * Start the loading process
  37895. * @return the current instance of the AssetsManager
  37896. */
  37897. load(): AssetsManager;
  37898. }
  37899. }
  37900. declare module BABYLON {
  37901. /**
  37902. * Direct draw surface info
  37903. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  37904. */
  37905. interface DDSInfo {
  37906. /**
  37907. * Width of the texture
  37908. */
  37909. width: number;
  37910. /**
  37911. * Width of the texture
  37912. */
  37913. height: number;
  37914. /**
  37915. * Number of Mipmaps for the texture
  37916. * @see https://en.wikipedia.org/wiki/Mipmap
  37917. */
  37918. mipmapCount: number;
  37919. /**
  37920. * If the textures format is a known fourCC format
  37921. * @see https://www.fourcc.org/
  37922. */
  37923. isFourCC: boolean;
  37924. /**
  37925. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  37926. */
  37927. isRGB: boolean;
  37928. /**
  37929. * If the texture is a lumincance format
  37930. */
  37931. isLuminance: boolean;
  37932. /**
  37933. * If this is a cube texture
  37934. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  37935. */
  37936. isCube: boolean;
  37937. /**
  37938. * If the texture is a compressed format eg. FOURCC_DXT1
  37939. */
  37940. isCompressed: boolean;
  37941. /**
  37942. * The dxgiFormat of the texture
  37943. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  37944. */
  37945. dxgiFormat: number;
  37946. /**
  37947. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  37948. */
  37949. textureType: number;
  37950. /**
  37951. * Sphericle polynomial created for the dds texture
  37952. */
  37953. sphericalPolynomial?: SphericalPolynomial;
  37954. }
  37955. /**
  37956. * Class used to provide DDS decompression tools
  37957. */
  37958. class DDSTools {
  37959. /**
  37960. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  37961. */
  37962. static StoreLODInAlphaChannel: boolean;
  37963. /**
  37964. * Gets DDS information from an array buffer
  37965. * @param arrayBuffer defines the array buffer to read data from
  37966. * @returns the DDS information
  37967. */
  37968. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  37969. private static _FloatView;
  37970. private static _Int32View;
  37971. private static _ToHalfFloat;
  37972. private static _FromHalfFloat;
  37973. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  37974. private static _GetHalfFloatRGBAArrayBuffer;
  37975. private static _GetFloatRGBAArrayBuffer;
  37976. private static _GetFloatAsUIntRGBAArrayBuffer;
  37977. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  37978. private static _GetRGBAArrayBuffer;
  37979. private static _ExtractLongWordOrder;
  37980. private static _GetRGBArrayBuffer;
  37981. private static _GetLuminanceArrayBuffer;
  37982. /**
  37983. * Uploads DDS Levels to a Babylon Texture
  37984. * @hidden
  37985. */
  37986. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  37987. }
  37988. }
  37989. declare module BABYLON {
  37990. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37991. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37992. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37993. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37994. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37995. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37996. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37997. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37998. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37999. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38000. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38001. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38002. /**
  38003. * Decorator used to define property that can be serialized as reference to a camera
  38004. * @param sourceName defines the name of the property to decorate
  38005. */
  38006. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38007. /**
  38008. * Class used to help serialization objects
  38009. */
  38010. class SerializationHelper {
  38011. /**
  38012. * Static function used to serialized a specific entity
  38013. * @param entity defines the entity to serialize
  38014. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38015. * @returns a JSON compatible object representing the serialization of the entity
  38016. */
  38017. static Serialize<T>(entity: T, serializationObject?: any): any;
  38018. /**
  38019. * Creates a new entity from a serialization data object
  38020. * @param creationFunction defines a function used to instanciated the new entity
  38021. * @param source defines the source serialization data
  38022. * @param scene defines the hosting scene
  38023. * @param rootUrl defines the root url for resources
  38024. * @returns a new entity
  38025. */
  38026. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38027. /**
  38028. * Clones an object
  38029. * @param creationFunction defines the function used to instanciate the new object
  38030. * @param source defines the source object
  38031. * @returns the cloned object
  38032. */
  38033. static Clone<T>(creationFunction: () => T, source: T): T;
  38034. /**
  38035. * Instanciates a new object based on a source one (some data will be shared between both object)
  38036. * @param creationFunction defines the function used to instanciate the new object
  38037. * @param source defines the source object
  38038. * @returns the new object
  38039. */
  38040. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38041. }
  38042. }
  38043. declare module BABYLON {
  38044. /**
  38045. * Wrapper class for promise with external resolve and reject.
  38046. */
  38047. class Deferred<T> {
  38048. /**
  38049. * The promise associated with this deferred object.
  38050. */
  38051. readonly promise: Promise<T>;
  38052. private _resolve;
  38053. private _reject;
  38054. /**
  38055. * The resolve method of the promise associated with this deferred object.
  38056. */
  38057. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  38058. /**
  38059. * The reject method of the promise associated with this deferred object.
  38060. */
  38061. readonly reject: (reason?: any) => void;
  38062. /**
  38063. * Constructor for this deferred object.
  38064. */
  38065. constructor();
  38066. }
  38067. }
  38068. declare module BABYLON {
  38069. /**
  38070. * Raw texture data and descriptor sufficient for WebGL texture upload
  38071. */
  38072. interface EnvironmentTextureInfo {
  38073. /**
  38074. * Version of the environment map
  38075. */
  38076. version: number;
  38077. /**
  38078. * Width of image
  38079. */
  38080. width: number;
  38081. /**
  38082. * Irradiance information stored in the file.
  38083. */
  38084. irradiance: any;
  38085. /**
  38086. * Specular information stored in the file.
  38087. */
  38088. specular: any;
  38089. }
  38090. /**
  38091. * Sets of helpers addressing the serialization and deserialization of environment texture
  38092. * stored in a BabylonJS env file.
  38093. * Those files are usually stored as .env files.
  38094. */
  38095. class EnvironmentTextureTools {
  38096. /**
  38097. * Magic number identifying the env file.
  38098. */
  38099. private static _MagicBytes;
  38100. /**
  38101. * Gets the environment info from an env file.
  38102. * @param data The array buffer containing the .env bytes.
  38103. * @returns the environment file info (the json header) if successfully parsed.
  38104. */
  38105. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  38106. /**
  38107. * Creates an environment texture from a loaded cube texture.
  38108. * @param texture defines the cube texture to convert in env file
  38109. * @return a promise containing the environment data if succesfull.
  38110. */
  38111. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  38112. /**
  38113. * Creates a JSON representation of the spherical data.
  38114. * @param texture defines the texture containing the polynomials
  38115. * @return the JSON representation of the spherical info
  38116. */
  38117. private static _CreateEnvTextureIrradiance;
  38118. /**
  38119. * Uploads the texture info contained in the env file to the GPU.
  38120. * @param texture defines the internal texture to upload to
  38121. * @param arrayBuffer defines the buffer cotaining the data to load
  38122. * @param info defines the texture info retrieved through the GetEnvInfo method
  38123. * @returns a promise
  38124. */
  38125. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  38126. /**
  38127. * Uploads the levels of image data to the GPU.
  38128. * @param texture defines the internal texture to upload to
  38129. * @param imageData defines the array buffer views of image data [mipmap][face]
  38130. * @returns a promise
  38131. */
  38132. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  38133. /**
  38134. * Uploads spherical polynomials information to the texture.
  38135. * @param texture defines the texture we are trying to upload the information to
  38136. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  38137. */
  38138. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  38139. }
  38140. }
  38141. declare module BABYLON {
  38142. /**
  38143. * Class used to help managing file picking and drag'n'drop
  38144. */
  38145. class FilesInput {
  38146. /**
  38147. * List of files ready to be loaded
  38148. */
  38149. static FilesToLoad: {
  38150. [key: string]: File;
  38151. };
  38152. /**
  38153. * Callback called when a file is processed
  38154. */
  38155. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  38156. private _engine;
  38157. private _currentScene;
  38158. private _sceneLoadedCallback;
  38159. private _progressCallback;
  38160. private _additionalRenderLoopLogicCallback;
  38161. private _textureLoadingCallback;
  38162. private _startingProcessingFilesCallback;
  38163. private _onReloadCallback;
  38164. private _errorCallback;
  38165. private _elementToMonitor;
  38166. private _sceneFileToLoad;
  38167. private _filesToLoad;
  38168. /**
  38169. * Creates a new FilesInput
  38170. * @param engine defines the rendering engine
  38171. * @param scene defines the hosting scene
  38172. * @param sceneLoadedCallback callback called when scene is loaded
  38173. * @param progressCallback callback called to track progress
  38174. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  38175. * @param textureLoadingCallback callback called when a texture is loading
  38176. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  38177. * @param onReloadCallback callback called when a reload is requested
  38178. * @param errorCallback callback call if an error occurs
  38179. */
  38180. 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);
  38181. private _dragEnterHandler;
  38182. private _dragOverHandler;
  38183. private _dropHandler;
  38184. /**
  38185. * Calls this function to listen to drag'n'drop events on a specific DOM element
  38186. * @param elementToMonitor defines the DOM element to track
  38187. */
  38188. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  38189. /**
  38190. * Release all associated resources
  38191. */
  38192. dispose(): void;
  38193. private renderFunction;
  38194. private drag;
  38195. private drop;
  38196. private _traverseFolder;
  38197. private _processFiles;
  38198. /**
  38199. * Load files from a drop event
  38200. * @param event defines the drop event to use as source
  38201. */
  38202. loadFiles(event: any): void;
  38203. private _processReload;
  38204. /**
  38205. * Reload the current scene from the loaded files
  38206. */
  38207. reload(): void;
  38208. }
  38209. }
  38210. declare module BABYLON {
  38211. /**
  38212. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  38213. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  38214. */
  38215. class KhronosTextureContainer {
  38216. /** contents of the KTX container file */
  38217. arrayBuffer: any;
  38218. private static HEADER_LEN;
  38219. private static COMPRESSED_2D;
  38220. private static COMPRESSED_3D;
  38221. private static TEX_2D;
  38222. private static TEX_3D;
  38223. /**
  38224. * Gets the openGL type
  38225. */
  38226. glType: number;
  38227. /**
  38228. * Gets the openGL type size
  38229. */
  38230. glTypeSize: number;
  38231. /**
  38232. * Gets the openGL format
  38233. */
  38234. glFormat: number;
  38235. /**
  38236. * Gets the openGL internal format
  38237. */
  38238. glInternalFormat: number;
  38239. /**
  38240. * Gets the base internal format
  38241. */
  38242. glBaseInternalFormat: number;
  38243. /**
  38244. * Gets image width in pixel
  38245. */
  38246. pixelWidth: number;
  38247. /**
  38248. * Gets image height in pixel
  38249. */
  38250. pixelHeight: number;
  38251. /**
  38252. * Gets image depth in pixels
  38253. */
  38254. pixelDepth: number;
  38255. /**
  38256. * Gets the number of array elements
  38257. */
  38258. numberOfArrayElements: number;
  38259. /**
  38260. * Gets the number of faces
  38261. */
  38262. numberOfFaces: number;
  38263. /**
  38264. * Gets the number of mipmap levels
  38265. */
  38266. numberOfMipmapLevels: number;
  38267. /**
  38268. * Gets the bytes of key value data
  38269. */
  38270. bytesOfKeyValueData: number;
  38271. /**
  38272. * Gets the load type
  38273. */
  38274. loadType: number;
  38275. /**
  38276. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  38277. */
  38278. isInvalid: boolean;
  38279. /**
  38280. * Creates a new KhronosTextureContainer
  38281. * @param arrayBuffer contents of the KTX container file
  38282. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  38283. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  38284. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  38285. */
  38286. constructor(
  38287. /** contents of the KTX container file */
  38288. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  38289. /**
  38290. * Revert the endianness of a value.
  38291. * Not as fast hardware based, but will probably never need to use
  38292. * @param val defines the value to convert
  38293. * @returns the new value
  38294. */
  38295. switchEndianness(val: number): number;
  38296. /**
  38297. * Uploads KTX content to a Babylon Texture.
  38298. * It is assumed that the texture has already been created & is currently bound
  38299. * @hidden
  38300. */
  38301. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  38302. private _upload2DCompressedLevels;
  38303. }
  38304. }
  38305. declare module BABYLON {
  38306. /**
  38307. * A class serves as a medium between the observable and its observers
  38308. */
  38309. class EventState {
  38310. /**
  38311. * Create a new EventState
  38312. * @param mask defines the mask associated with this state
  38313. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38314. * @param target defines the original target of the state
  38315. * @param currentTarget defines the current target of the state
  38316. */
  38317. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  38318. /**
  38319. * Initialize the current event state
  38320. * @param mask defines the mask associated with this state
  38321. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38322. * @param target defines the original target of the state
  38323. * @param currentTarget defines the current target of the state
  38324. * @returns the current event state
  38325. */
  38326. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  38327. /**
  38328. * An Observer can set this property to true to prevent subsequent observers of being notified
  38329. */
  38330. skipNextObservers: boolean;
  38331. /**
  38332. * Get the mask value that were used to trigger the event corresponding to this EventState object
  38333. */
  38334. mask: number;
  38335. /**
  38336. * The object that originally notified the event
  38337. */
  38338. target?: any;
  38339. /**
  38340. * The current object in the bubbling phase
  38341. */
  38342. currentTarget?: any;
  38343. /**
  38344. * This will be populated with the return value of the last function that was executed.
  38345. * If it is the first function in the callback chain it will be the event data.
  38346. */
  38347. lastReturnValue?: any;
  38348. }
  38349. /**
  38350. * Represent an Observer registered to a given Observable object.
  38351. */
  38352. class Observer<T> {
  38353. /**
  38354. * Defines the callback to call when the observer is notified
  38355. */
  38356. callback: (eventData: T, eventState: EventState) => void;
  38357. /**
  38358. * Defines the mask of the observer (used to filter notifications)
  38359. */
  38360. mask: number;
  38361. /**
  38362. * Defines the current scope used to restore the JS context
  38363. */
  38364. scope: any;
  38365. /** @hidden */
  38366. _willBeUnregistered: boolean;
  38367. /**
  38368. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  38369. */
  38370. unregisterOnNextCall: boolean;
  38371. /**
  38372. * Creates a new observer
  38373. * @param callback defines the callback to call when the observer is notified
  38374. * @param mask defines the mask of the observer (used to filter notifications)
  38375. * @param scope defines the current scope used to restore the JS context
  38376. */
  38377. constructor(
  38378. /**
  38379. * Defines the callback to call when the observer is notified
  38380. */
  38381. callback: (eventData: T, eventState: EventState) => void,
  38382. /**
  38383. * Defines the mask of the observer (used to filter notifications)
  38384. */
  38385. mask: number,
  38386. /**
  38387. * Defines the current scope used to restore the JS context
  38388. */
  38389. scope?: any);
  38390. }
  38391. /**
  38392. * Represent a list of observers registered to multiple Observables object.
  38393. */
  38394. class MultiObserver<T> {
  38395. private _observers;
  38396. private _observables;
  38397. /**
  38398. * Release associated resources
  38399. */
  38400. dispose(): void;
  38401. /**
  38402. * Raise a callback when one of the observable will notify
  38403. * @param observables defines a list of observables to watch
  38404. * @param callback defines the callback to call on notification
  38405. * @param mask defines the mask used to filter notifications
  38406. * @param scope defines the current scope used to restore the JS context
  38407. * @returns the new MultiObserver
  38408. */
  38409. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  38410. }
  38411. /**
  38412. * The Observable class is a simple implementation of the Observable pattern.
  38413. *
  38414. * 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.
  38415. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  38416. * 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).
  38417. * 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.
  38418. */
  38419. class Observable<T> {
  38420. private _observers;
  38421. private _eventState;
  38422. private _onObserverAdded;
  38423. /**
  38424. * Creates a new observable
  38425. * @param onObserverAdded defines a callback to call when a new observer is added
  38426. */
  38427. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  38428. /**
  38429. * Create a new Observer with the specified callback
  38430. * @param callback the callback that will be executed for that Observer
  38431. * @param mask the mask used to filter observers
  38432. * @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.
  38433. * @param scope optional scope for the callback to be called from
  38434. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  38435. * @returns the new observer created for the callback
  38436. */
  38437. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  38438. /**
  38439. * Create a new Observer with the specified callback and unregisters after the next notification
  38440. * @param callback the callback that will be executed for that Observer
  38441. * @returns the new observer created for the callback
  38442. */
  38443. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  38444. /**
  38445. * Remove an Observer from the Observable object
  38446. * @param observer the instance of the Observer to remove
  38447. * @returns false if it doesn't belong to this Observable
  38448. */
  38449. remove(observer: Nullable<Observer<T>>): boolean;
  38450. /**
  38451. * Remove a callback from the Observable object
  38452. * @param callback the callback to remove
  38453. * @param scope optional scope. If used only the callbacks with this scope will be removed
  38454. * @returns false if it doesn't belong to this Observable
  38455. */
  38456. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  38457. private _deferUnregister;
  38458. private _remove;
  38459. /**
  38460. * Notify all Observers by calling their respective callback with the given data
  38461. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  38462. * @param eventData defines the data to send to all observers
  38463. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  38464. * @param target defines the original target of the state
  38465. * @param currentTarget defines the current target of the state
  38466. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  38467. */
  38468. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  38469. /**
  38470. * Calling this will execute each callback, expecting it to be a promise or return a value.
  38471. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  38472. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  38473. * and it is crucial that all callbacks will be executed.
  38474. * The order of the callbacks is kept, callbacks are not executed parallel.
  38475. *
  38476. * @param eventData The data to be sent to each callback
  38477. * @param mask is used to filter observers defaults to -1
  38478. * @param target defines the callback target (see EventState)
  38479. * @param currentTarget defines he current object in the bubbling phase
  38480. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  38481. */
  38482. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  38483. /**
  38484. * Notify a specific observer
  38485. * @param observer defines the observer to notify
  38486. * @param eventData defines the data to be sent to each callback
  38487. * @param mask is used to filter observers defaults to -1
  38488. */
  38489. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  38490. /**
  38491. * Gets a boolean indicating if the observable has at least one observer
  38492. * @returns true is the Observable has at least one Observer registered
  38493. */
  38494. hasObservers(): boolean;
  38495. /**
  38496. * Clear the list of observers
  38497. */
  38498. clear(): void;
  38499. /**
  38500. * Clone the current observable
  38501. * @returns a new observable
  38502. */
  38503. clone(): Observable<T>;
  38504. /**
  38505. * Does this observable handles observer registered with a given mask
  38506. * @param mask defines the mask to be tested
  38507. * @return whether or not one observer registered with the given mask is handeled
  38508. **/
  38509. hasSpecificMask(mask?: number): boolean;
  38510. }
  38511. }
  38512. declare module BABYLON {
  38513. /**
  38514. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38515. */
  38516. class PerformanceMonitor {
  38517. private _enabled;
  38518. private _rollingFrameTime;
  38519. private _lastFrameTimeMs;
  38520. /**
  38521. * constructor
  38522. * @param frameSampleSize The number of samples required to saturate the sliding window
  38523. */
  38524. constructor(frameSampleSize?: number);
  38525. /**
  38526. * Samples current frame
  38527. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38528. */
  38529. sampleFrame(timeMs?: number): void;
  38530. /**
  38531. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38532. */
  38533. readonly averageFrameTime: number;
  38534. /**
  38535. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38536. */
  38537. readonly averageFrameTimeVariance: number;
  38538. /**
  38539. * Returns the frame time of the most recent frame
  38540. */
  38541. readonly instantaneousFrameTime: number;
  38542. /**
  38543. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38544. */
  38545. readonly averageFPS: number;
  38546. /**
  38547. * Returns the average framerate in frames per second using the most recent frame time
  38548. */
  38549. readonly instantaneousFPS: number;
  38550. /**
  38551. * Returns true if enough samples have been taken to completely fill the sliding window
  38552. */
  38553. readonly isSaturated: boolean;
  38554. /**
  38555. * Enables contributions to the sliding window sample set
  38556. */
  38557. enable(): void;
  38558. /**
  38559. * Disables contributions to the sliding window sample set
  38560. * Samples will not be interpolated over the disabled period
  38561. */
  38562. disable(): void;
  38563. /**
  38564. * Returns true if sampling is enabled
  38565. */
  38566. readonly isEnabled: boolean;
  38567. /**
  38568. * Resets performance monitor
  38569. */
  38570. reset(): void;
  38571. }
  38572. /**
  38573. * RollingAverage
  38574. *
  38575. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38576. */
  38577. class RollingAverage {
  38578. /**
  38579. * Current average
  38580. */
  38581. average: number;
  38582. /**
  38583. * Current variance
  38584. */
  38585. variance: number;
  38586. protected _samples: Array<number>;
  38587. protected _sampleCount: number;
  38588. protected _pos: number;
  38589. protected _m2: number;
  38590. /**
  38591. * constructor
  38592. * @param length The number of samples required to saturate the sliding window
  38593. */
  38594. constructor(length: number);
  38595. /**
  38596. * Adds a sample to the sample set
  38597. * @param v The sample value
  38598. */
  38599. add(v: number): void;
  38600. /**
  38601. * Returns previously added values or null if outside of history or outside the sliding window domain
  38602. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38603. * @return Value previously recorded with add() or null if outside of range
  38604. */
  38605. history(i: number): number;
  38606. /**
  38607. * Returns true if enough samples have been taken to completely fill the sliding window
  38608. * @return true if sample-set saturated
  38609. */
  38610. isSaturated(): boolean;
  38611. /**
  38612. * Resets the rolling average (equivalent to 0 samples taken so far)
  38613. */
  38614. reset(): void;
  38615. /**
  38616. * Wraps a value around the sample range boundaries
  38617. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38618. * @return Wrapped position in sample range
  38619. */
  38620. protected _wrapPosition(i: number): number;
  38621. }
  38622. }
  38623. declare module BABYLON {
  38624. /**
  38625. * Helper class that provides a small promise polyfill
  38626. */
  38627. class PromisePolyfill {
  38628. /**
  38629. * Static function used to check if the polyfill is required
  38630. * If this is the case then the function will inject the polyfill to window.Promise
  38631. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38632. */
  38633. static Apply(force?: boolean): void;
  38634. }
  38635. }
  38636. declare module BABYLON {
  38637. /**
  38638. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38639. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38640. */
  38641. class SceneOptimization {
  38642. /**
  38643. * Defines the priority of this optimization (0 by default which means first in the list)
  38644. */
  38645. priority: number;
  38646. /**
  38647. * Gets a string describing the action executed by the current optimization
  38648. * @returns description string
  38649. */
  38650. getDescription(): string;
  38651. /**
  38652. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38653. * @param scene defines the current scene where to apply this optimization
  38654. * @param optimizer defines the current optimizer
  38655. * @returns true if everything that can be done was applied
  38656. */
  38657. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38658. /**
  38659. * Creates the SceneOptimization object
  38660. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38661. * @param desc defines the description associated with the optimization
  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. /**
  38670. * Defines an optimization used to reduce the size of render target textures
  38671. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38672. */
  38673. class TextureOptimization extends SceneOptimization {
  38674. /**
  38675. * Defines the priority of this optimization (0 by default which means first in the list)
  38676. */
  38677. priority: number;
  38678. /**
  38679. * 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
  38680. */
  38681. maximumSize: number;
  38682. /**
  38683. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38684. */
  38685. step: number;
  38686. /**
  38687. * Gets a string describing the action executed by the current optimization
  38688. * @returns description string
  38689. */
  38690. getDescription(): string;
  38691. /**
  38692. * Creates the TextureOptimization object
  38693. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38694. * @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
  38695. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38696. */
  38697. constructor(
  38698. /**
  38699. * Defines the priority of this optimization (0 by default which means first in the list)
  38700. */
  38701. priority?: number,
  38702. /**
  38703. * 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
  38704. */
  38705. maximumSize?: number,
  38706. /**
  38707. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38708. */
  38709. step?: number);
  38710. /**
  38711. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38712. * @param scene defines the current scene where to apply this optimization
  38713. * @param optimizer defines the current optimizer
  38714. * @returns true if everything that can be done was applied
  38715. */
  38716. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38717. }
  38718. /**
  38719. * Defines an optimization used to increase or decrease the rendering resolution
  38720. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38721. */
  38722. class HardwareScalingOptimization extends SceneOptimization {
  38723. /**
  38724. * Defines the priority of this optimization (0 by default which means first in the list)
  38725. */
  38726. priority: number;
  38727. /**
  38728. * Defines the maximum scale to use (2 by default)
  38729. */
  38730. maximumScale: number;
  38731. /**
  38732. * Defines the step to use between two passes (0.5 by default)
  38733. */
  38734. step: number;
  38735. private _currentScale;
  38736. private _directionOffset;
  38737. /**
  38738. * Gets a string describing the action executed by the current optimization
  38739. * @return description string
  38740. */
  38741. getDescription(): string;
  38742. /**
  38743. * Creates the HardwareScalingOptimization object
  38744. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38745. * @param maximumScale defines the maximum scale to use (2 by default)
  38746. * @param step defines the step to use between two passes (0.5 by default)
  38747. */
  38748. constructor(
  38749. /**
  38750. * Defines the priority of this optimization (0 by default which means first in the list)
  38751. */
  38752. priority?: number,
  38753. /**
  38754. * Defines the maximum scale to use (2 by default)
  38755. */
  38756. maximumScale?: number,
  38757. /**
  38758. * Defines the step to use between two passes (0.5 by default)
  38759. */
  38760. step?: number);
  38761. /**
  38762. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38763. * @param scene defines the current scene where to apply this optimization
  38764. * @param optimizer defines the current optimizer
  38765. * @returns true if everything that can be done was applied
  38766. */
  38767. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38768. }
  38769. /**
  38770. * Defines an optimization used to remove shadows
  38771. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38772. */
  38773. class ShadowsOptimization extends SceneOptimization {
  38774. /**
  38775. * Gets a string describing the action executed by the current optimization
  38776. * @return description string
  38777. */
  38778. getDescription(): string;
  38779. /**
  38780. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38781. * @param scene defines the current scene where to apply this optimization
  38782. * @param optimizer defines the current optimizer
  38783. * @returns true if everything that can be done was applied
  38784. */
  38785. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38786. }
  38787. /**
  38788. * Defines an optimization used to turn post-processes off
  38789. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38790. */
  38791. class PostProcessesOptimization extends SceneOptimization {
  38792. /**
  38793. * Gets a string describing the action executed by the current optimization
  38794. * @return description string
  38795. */
  38796. getDescription(): string;
  38797. /**
  38798. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38799. * @param scene defines the current scene where to apply this optimization
  38800. * @param optimizer defines the current optimizer
  38801. * @returns true if everything that can be done was applied
  38802. */
  38803. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38804. }
  38805. /**
  38806. * Defines an optimization used to turn lens flares off
  38807. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38808. */
  38809. class LensFlaresOptimization extends SceneOptimization {
  38810. /**
  38811. * Gets a string describing the action executed by the current optimization
  38812. * @return description string
  38813. */
  38814. getDescription(): string;
  38815. /**
  38816. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38817. * @param scene defines the current scene where to apply this optimization
  38818. * @param optimizer defines the current optimizer
  38819. * @returns true if everything that can be done was applied
  38820. */
  38821. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38822. }
  38823. /**
  38824. * Defines an optimization based on user defined callback.
  38825. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38826. */
  38827. class CustomOptimization extends SceneOptimization {
  38828. /**
  38829. * Callback called to apply the custom optimization.
  38830. */
  38831. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38832. /**
  38833. * Callback called to get custom description
  38834. */
  38835. onGetDescription: () => string;
  38836. /**
  38837. * Gets a string describing the action executed by the current optimization
  38838. * @returns description string
  38839. */
  38840. getDescription(): string;
  38841. /**
  38842. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38843. * @param scene defines the current scene where to apply this optimization
  38844. * @param optimizer defines the current optimizer
  38845. * @returns true if everything that can be done was applied
  38846. */
  38847. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38848. }
  38849. /**
  38850. * Defines an optimization used to turn particles off
  38851. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38852. */
  38853. class ParticlesOptimization extends SceneOptimization {
  38854. /**
  38855. * Gets a string describing the action executed by the current optimization
  38856. * @return description string
  38857. */
  38858. getDescription(): string;
  38859. /**
  38860. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38861. * @param scene defines the current scene where to apply this optimization
  38862. * @param optimizer defines the current optimizer
  38863. * @returns true if everything that can be done was applied
  38864. */
  38865. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38866. }
  38867. /**
  38868. * Defines an optimization used to turn render targets off
  38869. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38870. */
  38871. class RenderTargetsOptimization extends SceneOptimization {
  38872. /**
  38873. * Gets a string describing the action executed by the current optimization
  38874. * @return description string
  38875. */
  38876. getDescription(): string;
  38877. /**
  38878. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38879. * @param scene defines the current scene where to apply this optimization
  38880. * @param optimizer defines the current optimizer
  38881. * @returns true if everything that can be done was applied
  38882. */
  38883. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38884. }
  38885. /**
  38886. * Defines an optimization used to merge meshes with compatible materials
  38887. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38888. */
  38889. class MergeMeshesOptimization extends SceneOptimization {
  38890. private static _UpdateSelectionTree;
  38891. /**
  38892. * Gets or sets a boolean which defines if optimization octree has to be updated
  38893. */
  38894. /**
  38895. * Gets or sets a boolean which defines if optimization octree has to be updated
  38896. */
  38897. static UpdateSelectionTree: boolean;
  38898. /**
  38899. * Gets a string describing the action executed by the current optimization
  38900. * @return description string
  38901. */
  38902. getDescription(): string;
  38903. private _canBeMerged;
  38904. /**
  38905. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38906. * @param scene defines the current scene where to apply this optimization
  38907. * @param optimizer defines the current optimizer
  38908. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  38909. * @returns true if everything that can be done was applied
  38910. */
  38911. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  38912. }
  38913. /**
  38914. * Defines a list of options used by SceneOptimizer
  38915. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38916. */
  38917. class SceneOptimizerOptions {
  38918. /**
  38919. * Defines the target frame rate to reach (60 by default)
  38920. */
  38921. targetFrameRate: number;
  38922. /**
  38923. * Defines the interval between two checkes (2000ms by default)
  38924. */
  38925. trackerDuration: number;
  38926. /**
  38927. * Gets the list of optimizations to apply
  38928. */
  38929. optimizations: SceneOptimization[];
  38930. /**
  38931. * Creates a new list of options used by SceneOptimizer
  38932. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  38933. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  38934. */
  38935. constructor(
  38936. /**
  38937. * Defines the target frame rate to reach (60 by default)
  38938. */
  38939. targetFrameRate?: number,
  38940. /**
  38941. * Defines the interval between two checkes (2000ms by default)
  38942. */
  38943. trackerDuration?: number);
  38944. /**
  38945. * Add a new optimization
  38946. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  38947. * @returns the current SceneOptimizerOptions
  38948. */
  38949. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  38950. /**
  38951. * Add a new custom optimization
  38952. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  38953. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  38954. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38955. * @returns the current SceneOptimizerOptions
  38956. */
  38957. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  38958. /**
  38959. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  38960. * @param targetFrameRate defines the target frame rate (60 by default)
  38961. * @returns a SceneOptimizerOptions object
  38962. */
  38963. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38964. /**
  38965. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  38966. * @param targetFrameRate defines the target frame rate (60 by default)
  38967. * @returns a SceneOptimizerOptions object
  38968. */
  38969. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38970. /**
  38971. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  38972. * @param targetFrameRate defines the target frame rate (60 by default)
  38973. * @returns a SceneOptimizerOptions object
  38974. */
  38975. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38976. }
  38977. /**
  38978. * Class used to run optimizations in order to reach a target frame rate
  38979. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38980. */
  38981. class SceneOptimizer implements IDisposable {
  38982. private _isRunning;
  38983. private _options;
  38984. private _scene;
  38985. private _currentPriorityLevel;
  38986. private _targetFrameRate;
  38987. private _trackerDuration;
  38988. private _currentFrameRate;
  38989. private _sceneDisposeObserver;
  38990. private _improvementMode;
  38991. /**
  38992. * Defines an observable called when the optimizer reaches the target frame rate
  38993. */
  38994. onSuccessObservable: Observable<SceneOptimizer>;
  38995. /**
  38996. * Defines an observable called when the optimizer enables an optimization
  38997. */
  38998. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  38999. /**
  39000. * Defines an observable called when the optimizer is not able to reach the target frame rate
  39001. */
  39002. onFailureObservable: Observable<SceneOptimizer>;
  39003. /**
  39004. * Gets a boolean indicating if the optimizer is in improvement mode
  39005. */
  39006. readonly isInImprovementMode: boolean;
  39007. /**
  39008. * Gets the current priority level (0 at start)
  39009. */
  39010. readonly currentPriorityLevel: number;
  39011. /**
  39012. * Gets the current frame rate checked by the SceneOptimizer
  39013. */
  39014. readonly currentFrameRate: number;
  39015. /**
  39016. * Gets or sets the current target frame rate (60 by default)
  39017. */
  39018. /**
  39019. * Gets or sets the current target frame rate (60 by default)
  39020. */
  39021. targetFrameRate: number;
  39022. /**
  39023. * Gets or sets the current interval between two checks (every 2000ms by default)
  39024. */
  39025. /**
  39026. * Gets or sets the current interval between two checks (every 2000ms by default)
  39027. */
  39028. trackerDuration: number;
  39029. /**
  39030. * Gets the list of active optimizations
  39031. */
  39032. readonly optimizations: SceneOptimization[];
  39033. /**
  39034. * Creates a new SceneOptimizer
  39035. * @param scene defines the scene to work on
  39036. * @param options defines the options to use with the SceneOptimizer
  39037. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  39038. * @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)
  39039. */
  39040. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  39041. /**
  39042. * Stops the current optimizer
  39043. */
  39044. stop(): void;
  39045. /**
  39046. * Reset the optimizer to initial step (current priority level = 0)
  39047. */
  39048. reset(): void;
  39049. /**
  39050. * Start the optimizer. By default it will try to reach a specific framerate
  39051. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  39052. */
  39053. start(): void;
  39054. private _checkCurrentState;
  39055. /**
  39056. * Release all resources
  39057. */
  39058. dispose(): void;
  39059. /**
  39060. * Helper function to create a SceneOptimizer with one single line of code
  39061. * @param scene defines the scene to work on
  39062. * @param options defines the options to use with the SceneOptimizer
  39063. * @param onSuccess defines a callback to call on success
  39064. * @param onFailure defines a callback to call on failure
  39065. * @returns the new SceneOptimizer object
  39066. */
  39067. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  39068. }
  39069. }
  39070. declare module BABYLON {
  39071. /**
  39072. * Class used to serialize a scene into a string
  39073. */
  39074. class SceneSerializer {
  39075. /**
  39076. * Clear cache used by a previous serialization
  39077. */
  39078. static ClearCache(): void;
  39079. /**
  39080. * Serialize a scene into a JSON compatible object
  39081. * @param scene defines the scene to serialize
  39082. * @returns a JSON compatible object
  39083. */
  39084. static Serialize(scene: Scene): any;
  39085. /**
  39086. * Serialize a mesh into a JSON compatible object
  39087. * @param toSerialize defines the mesh to serialize
  39088. * @param withParents defines if parents must be serialized as well
  39089. * @param withChildren defines if children must be serialized as well
  39090. * @returns a JSON compatible object
  39091. */
  39092. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  39093. }
  39094. }
  39095. declare module BABYLON {
  39096. /**
  39097. * Defines an array and its length.
  39098. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  39099. */
  39100. interface ISmartArrayLike<T> {
  39101. /**
  39102. * The data of the array.
  39103. */
  39104. data: Array<T>;
  39105. /**
  39106. * The active length of the array.
  39107. */
  39108. length: number;
  39109. }
  39110. /**
  39111. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39112. */
  39113. class SmartArray<T> implements ISmartArrayLike<T> {
  39114. /**
  39115. * The full set of data from the array.
  39116. */
  39117. data: Array<T>;
  39118. /**
  39119. * The active length of the array.
  39120. */
  39121. length: number;
  39122. protected _id: number;
  39123. /**
  39124. * Instantiates a Smart Array.
  39125. * @param capacity defines the default capacity of the array.
  39126. */
  39127. constructor(capacity: number);
  39128. /**
  39129. * Pushes a value at the end of the active data.
  39130. * @param value defines the object to push in the array.
  39131. */
  39132. push(value: T): void;
  39133. /**
  39134. * Iterates over the active data and apply the lambda to them.
  39135. * @param func defines the action to apply on each value.
  39136. */
  39137. forEach(func: (content: T) => void): void;
  39138. /**
  39139. * Sorts the full sets of data.
  39140. * @param compareFn defines the comparison function to apply.
  39141. */
  39142. sort(compareFn: (a: T, b: T) => number): void;
  39143. /**
  39144. * Resets the active data to an empty array.
  39145. */
  39146. reset(): void;
  39147. /**
  39148. * Releases all the data from the array as well as the array.
  39149. */
  39150. dispose(): void;
  39151. /**
  39152. * Concats the active data with a given array.
  39153. * @param array defines the data to concatenate with.
  39154. */
  39155. concat(array: any): void;
  39156. /**
  39157. * Returns the position of a value in the active data.
  39158. * @param value defines the value to find the index for
  39159. * @returns the index if found in the active data otherwise -1
  39160. */
  39161. indexOf(value: T): number;
  39162. /**
  39163. * Returns whether an element is part of the active data.
  39164. * @param value defines the value to look for
  39165. * @returns true if found in the active data otherwise false
  39166. */
  39167. contains(value: T): boolean;
  39168. private static _GlobalId;
  39169. }
  39170. /**
  39171. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39172. * The data in this array can only be present once
  39173. */
  39174. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  39175. private _duplicateId;
  39176. /**
  39177. * Pushes a value at the end of the active data.
  39178. * THIS DOES NOT PREVENT DUPPLICATE DATA
  39179. * @param value defines the object to push in the array.
  39180. */
  39181. push(value: T): void;
  39182. /**
  39183. * Pushes a value at the end of the active data.
  39184. * If the data is already present, it won t be added again
  39185. * @param value defines the object to push in the array.
  39186. * @returns true if added false if it was already present
  39187. */
  39188. pushNoDuplicate(value: T): boolean;
  39189. /**
  39190. * Resets the active data to an empty array.
  39191. */
  39192. reset(): void;
  39193. /**
  39194. * Concats the active data with a given array.
  39195. * This ensures no dupplicate will be present in the result.
  39196. * @param array defines the data to concatenate with.
  39197. */
  39198. concatWithNoDuplicate(array: any): void;
  39199. }
  39200. }
  39201. declare module BABYLON {
  39202. /**
  39203. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39204. * The underlying implementation relies on an associative array to ensure the best performances.
  39205. * The value can be anything including 'null' but except 'undefined'
  39206. */
  39207. class StringDictionary<T> {
  39208. /**
  39209. * This will clear this dictionary and copy the content from the 'source' one.
  39210. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39211. * @param source the dictionary to take the content from and copy to this dictionary
  39212. */
  39213. copyFrom(source: StringDictionary<T>): void;
  39214. /**
  39215. * Get a value based from its key
  39216. * @param key the given key to get the matching value from
  39217. * @return the value if found, otherwise undefined is returned
  39218. */
  39219. get(key: string): T | undefined;
  39220. /**
  39221. * Get a value from its key or add it if it doesn't exist.
  39222. * This method will ensure you that a given key/data will be present in the dictionary.
  39223. * @param key the given key to get the matching value from
  39224. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39225. * The factory will only be invoked if there's no data for the given key.
  39226. * @return the value corresponding to the key.
  39227. */
  39228. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39229. /**
  39230. * Get a value from its key if present in the dictionary otherwise add it
  39231. * @param key the key to get the value from
  39232. * @param val if there's no such key/value pair in the dictionary add it with this value
  39233. * @return the value corresponding to the key
  39234. */
  39235. getOrAdd(key: string, val: T): T;
  39236. /**
  39237. * Check if there's a given key in the dictionary
  39238. * @param key the key to check for
  39239. * @return true if the key is present, false otherwise
  39240. */
  39241. contains(key: string): boolean;
  39242. /**
  39243. * Add a new key and its corresponding value
  39244. * @param key the key to add
  39245. * @param value the value corresponding to the key
  39246. * @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
  39247. */
  39248. add(key: string, value: T): boolean;
  39249. /**
  39250. * Update a specific value associated to a key
  39251. * @param key defines the key to use
  39252. * @param value defines the value to store
  39253. * @returns true if the value was updated (or false if the key was not found)
  39254. */
  39255. set(key: string, value: T): boolean;
  39256. /**
  39257. * Get the element of the given key and remove it from the dictionary
  39258. * @param key defines the key to search
  39259. * @returns the value associated with the key or null if not found
  39260. */
  39261. getAndRemove(key: string): Nullable<T>;
  39262. /**
  39263. * Remove a key/value from the dictionary.
  39264. * @param key the key to remove
  39265. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39266. */
  39267. remove(key: string): boolean;
  39268. /**
  39269. * Clear the whole content of the dictionary
  39270. */
  39271. clear(): void;
  39272. /**
  39273. * Gets the current count
  39274. */
  39275. readonly count: number;
  39276. /**
  39277. * Execute a callback on each key/val of the dictionary.
  39278. * Note that you can remove any element in this dictionary in the callback implementation
  39279. * @param callback the callback to execute on a given key/value pair
  39280. */
  39281. forEach(callback: (key: string, val: T) => void): void;
  39282. /**
  39283. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39284. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39285. * Note that you can remove any element in this dictionary in the callback implementation
  39286. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39287. * @returns the first item
  39288. */
  39289. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39290. private _count;
  39291. private _data;
  39292. }
  39293. }
  39294. declare module BABYLON {
  39295. /**
  39296. * Class used to store custom tags
  39297. */
  39298. class Tags {
  39299. /**
  39300. * Adds support for tags on the given object
  39301. * @param obj defines the object to use
  39302. */
  39303. static EnableFor(obj: any): void;
  39304. /**
  39305. * Removes tags support
  39306. * @param obj defines the object to use
  39307. */
  39308. static DisableFor(obj: any): void;
  39309. /**
  39310. * Gets a boolean indicating if the given object has tags
  39311. * @param obj defines the object to use
  39312. * @returns a boolean
  39313. */
  39314. static HasTags(obj: any): boolean;
  39315. /**
  39316. * Gets the tags available on a given object
  39317. * @param obj defines the object to use
  39318. * @param asString defines if the tags must be returned as a string instead of an array of strings
  39319. * @returns the tags
  39320. */
  39321. static GetTags(obj: any, asString?: boolean): any;
  39322. /**
  39323. * Adds tags to an object
  39324. * @param obj defines the object to use
  39325. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  39326. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  39327. */
  39328. static AddTagsTo(obj: any, tagsString: string): void;
  39329. /**
  39330. * @hidden
  39331. */
  39332. static _AddTagTo(obj: any, tag: string): void;
  39333. /**
  39334. * Removes specific tags from a specific object
  39335. * @param obj defines the object to use
  39336. * @param tagsString defines the tags to remove
  39337. */
  39338. static RemoveTagsFrom(obj: any, tagsString: string): void;
  39339. /**
  39340. * @hidden
  39341. */
  39342. static _RemoveTagFrom(obj: any, tag: string): void;
  39343. /**
  39344. * Defines if tags hosted on an object match a given query
  39345. * @param obj defines the object to use
  39346. * @param tagsQuery defines the tag query
  39347. * @returns a boolean
  39348. */
  39349. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  39350. }
  39351. }
  39352. declare module BABYLON {
  39353. /**
  39354. * Class used to host texture specific utilities
  39355. */
  39356. class TextureTools {
  39357. /**
  39358. * Uses the GPU to create a copy texture rescaled at a given size
  39359. * @param texture Texture to copy from
  39360. * @param width defines the desired width
  39361. * @param height defines the desired height
  39362. * @param useBilinearMode defines if bilinear mode has to be used
  39363. * @return the generated texture
  39364. */
  39365. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  39366. /**
  39367. * Gets an environment BRDF texture for a given scene
  39368. * @param scene defines the hosting scene
  39369. * @returns the environment BRDF texture
  39370. */
  39371. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  39372. private static _environmentBRDFBase64Texture;
  39373. }
  39374. }
  39375. declare module BABYLON {
  39376. /**
  39377. * Based on jsTGALoader - Javascript loader for TGA file
  39378. * By Vincent Thibault
  39379. * @see http://blog.robrowser.com/javascript-tga-loader.html
  39380. */
  39381. class TGATools {
  39382. private static _TYPE_INDEXED;
  39383. private static _TYPE_RGB;
  39384. private static _TYPE_GREY;
  39385. private static _TYPE_RLE_INDEXED;
  39386. private static _TYPE_RLE_RGB;
  39387. private static _TYPE_RLE_GREY;
  39388. private static _ORIGIN_MASK;
  39389. private static _ORIGIN_SHIFT;
  39390. private static _ORIGIN_BL;
  39391. private static _ORIGIN_BR;
  39392. private static _ORIGIN_UL;
  39393. private static _ORIGIN_UR;
  39394. /**
  39395. * Gets the header of a TGA file
  39396. * @param data defines the TGA data
  39397. * @returns the header
  39398. */
  39399. static GetTGAHeader(data: Uint8Array): any;
  39400. /**
  39401. * Uploads TGA content to a Babylon Texture
  39402. * @hidden
  39403. */
  39404. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  39405. /** @hidden */
  39406. 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;
  39407. /** @hidden */
  39408. 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;
  39409. /** @hidden */
  39410. 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;
  39411. /** @hidden */
  39412. 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;
  39413. /** @hidden */
  39414. 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;
  39415. /** @hidden */
  39416. 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;
  39417. }
  39418. }
  39419. declare module BABYLON {
  39420. /**
  39421. * Interface for any object that can request an animation frame
  39422. */
  39423. interface ICustomAnimationFrameRequester {
  39424. /**
  39425. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  39426. */
  39427. renderFunction?: Function;
  39428. /**
  39429. * Called to request the next frame to render to
  39430. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  39431. */
  39432. requestAnimationFrame: Function;
  39433. /**
  39434. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  39435. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  39436. */
  39437. requestID?: number;
  39438. }
  39439. /**
  39440. * Interface containing an array of animations
  39441. */
  39442. interface IAnimatable {
  39443. /**
  39444. * Array of animations
  39445. */
  39446. animations: Array<Animation>;
  39447. }
  39448. /** Interface used by value gradients (color, factor, ...) */
  39449. interface IValueGradient {
  39450. /**
  39451. * Gets or sets the gradient value (between 0 and 1)
  39452. */
  39453. gradient: number;
  39454. }
  39455. /** Class used to store color4 gradient */
  39456. class ColorGradient implements IValueGradient {
  39457. /**
  39458. * Gets or sets the gradient value (between 0 and 1)
  39459. */
  39460. gradient: number;
  39461. /**
  39462. * Gets or sets first associated color
  39463. */
  39464. color1: Color4;
  39465. /**
  39466. * Gets or sets second associated color
  39467. */
  39468. color2?: Color4;
  39469. /**
  39470. * Will get a color picked randomly between color1 and color2.
  39471. * If color2 is undefined then color1 will be used
  39472. * @param result defines the target Color4 to store the result in
  39473. */
  39474. getColorToRef(result: Color4): void;
  39475. }
  39476. /** Class used to store color 3 gradient */
  39477. class Color3Gradient implements IValueGradient {
  39478. /**
  39479. * Gets or sets the gradient value (between 0 and 1)
  39480. */
  39481. gradient: number;
  39482. /**
  39483. * Gets or sets the associated color
  39484. */
  39485. color: Color3;
  39486. }
  39487. /** Class used to store factor gradient */
  39488. class FactorGradient implements IValueGradient {
  39489. /**
  39490. * Gets or sets the gradient value (between 0 and 1)
  39491. */
  39492. gradient: number;
  39493. /**
  39494. * Gets or sets first associated factor
  39495. */
  39496. factor1: number;
  39497. /**
  39498. * Gets or sets second associated factor
  39499. */
  39500. factor2?: number;
  39501. /**
  39502. * Will get a number picked randomly between factor1 and factor2.
  39503. * If factor2 is undefined then factor1 will be used
  39504. * @returns the picked number
  39505. */
  39506. getFactor(): number;
  39507. }
  39508. /**
  39509. * @ignore
  39510. * Application error to support additional information when loading a file
  39511. */
  39512. class LoadFileError extends Error {
  39513. /** defines the optional XHR request */
  39514. request?: XMLHttpRequest | undefined;
  39515. private static _setPrototypeOf;
  39516. /**
  39517. * Creates a new LoadFileError
  39518. * @param message defines the message of the error
  39519. * @param request defines the optional XHR request
  39520. */
  39521. constructor(message: string,
  39522. /** defines the optional XHR request */
  39523. request?: XMLHttpRequest | undefined);
  39524. }
  39525. /**
  39526. * Class used to define a retry strategy when error happens while loading assets
  39527. */
  39528. class RetryStrategy {
  39529. /**
  39530. * Function used to defines an exponential back off strategy
  39531. * @param maxRetries defines the maximum number of retries (3 by default)
  39532. * @param baseInterval defines the interval between retries
  39533. * @returns the strategy function to use
  39534. */
  39535. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39536. }
  39537. /**
  39538. * File request interface
  39539. */
  39540. interface IFileRequest {
  39541. /**
  39542. * Raised when the request is complete (success or error).
  39543. */
  39544. onCompleteObservable: Observable<IFileRequest>;
  39545. /**
  39546. * Aborts the request for a file.
  39547. */
  39548. abort: () => void;
  39549. }
  39550. /**
  39551. * Class containing a set of static utilities functions
  39552. */
  39553. class Tools {
  39554. /**
  39555. * Gets or sets the base URL to use to load assets
  39556. */
  39557. static BaseUrl: string;
  39558. /**
  39559. * Enable/Disable Custom HTTP Request Headers globally.
  39560. * default = false
  39561. * @see CustomRequestHeaders
  39562. */
  39563. static UseCustomRequestHeaders: boolean;
  39564. /**
  39565. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39566. * i.e. when loading files, where the server/service expects an Authorization header.
  39567. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  39568. */
  39569. static CustomRequestHeaders: {
  39570. [key: string]: string;
  39571. };
  39572. /**
  39573. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39574. */
  39575. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39576. /**
  39577. * Default behaviour for cors in the application.
  39578. * It can be a string if the expected behavior is identical in the entire app.
  39579. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39580. */
  39581. static CorsBehavior: string | ((url: string | string[]) => string);
  39582. /**
  39583. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39584. * @ignorenaming
  39585. */
  39586. static UseFallbackTexture: boolean;
  39587. /**
  39588. * Use this object to register external classes like custom textures or material
  39589. * to allow the laoders to instantiate them
  39590. */
  39591. static RegisteredExternalClasses: {
  39592. [key: string]: Object;
  39593. };
  39594. /**
  39595. * Texture content used if a texture cannot loaded
  39596. * @ignorenaming
  39597. */
  39598. static fallbackTexture: string;
  39599. /**
  39600. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39601. * @param u defines the coordinate on X axis
  39602. * @param v defines the coordinate on Y axis
  39603. * @param width defines the width of the source data
  39604. * @param height defines the height of the source data
  39605. * @param pixels defines the source byte array
  39606. * @param color defines the output color
  39607. */
  39608. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39609. /**
  39610. * Interpolates between a and b via alpha
  39611. * @param a The lower value (returned when alpha = 0)
  39612. * @param b The upper value (returned when alpha = 1)
  39613. * @param alpha The interpolation-factor
  39614. * @return The mixed value
  39615. */
  39616. static Mix(a: number, b: number, alpha: number): number;
  39617. /**
  39618. * Tries to instantiate a new object from a given class name
  39619. * @param className defines the class name to instantiate
  39620. * @returns the new object or null if the system was not able to do the instantiation
  39621. */
  39622. static Instantiate(className: string): any;
  39623. /**
  39624. * Provides a slice function that will work even on IE
  39625. * @param data defines the array to slice
  39626. * @param start defines the start of the data (optional)
  39627. * @param end defines the end of the data (optional)
  39628. * @returns the new sliced array
  39629. */
  39630. static Slice<T>(data: T, start?: number, end?: number): T;
  39631. /**
  39632. * Polyfill for setImmediate
  39633. * @param action defines the action to execute after the current execution block
  39634. */
  39635. static SetImmediate(action: () => void): void;
  39636. /**
  39637. * Function indicating if a number is an exponent of 2
  39638. * @param value defines the value to test
  39639. * @returns true if the value is an exponent of 2
  39640. */
  39641. static IsExponentOfTwo(value: number): boolean;
  39642. private static _tmpFloatArray;
  39643. /**
  39644. * Returns the nearest 32-bit single precision float representation of a Number
  39645. * @param value A Number. If the parameter is of a different type, it will get converted
  39646. * to a number or to NaN if it cannot be converted
  39647. * @returns number
  39648. */
  39649. static FloatRound(value: number): number;
  39650. /**
  39651. * Find the next highest power of two.
  39652. * @param x Number to start search from.
  39653. * @return Next highest power of two.
  39654. */
  39655. static CeilingPOT(x: number): number;
  39656. /**
  39657. * Find the next lowest power of two.
  39658. * @param x Number to start search from.
  39659. * @return Next lowest power of two.
  39660. */
  39661. static FloorPOT(x: number): number;
  39662. /**
  39663. * Find the nearest power of two.
  39664. * @param x Number to start search from.
  39665. * @return Next nearest power of two.
  39666. */
  39667. static NearestPOT(x: number): number;
  39668. /**
  39669. * Get the closest exponent of two
  39670. * @param value defines the value to approximate
  39671. * @param max defines the maximum value to return
  39672. * @param mode defines how to define the closest value
  39673. * @returns closest exponent of two of the given value
  39674. */
  39675. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39676. /**
  39677. * Extracts the filename from a path
  39678. * @param path defines the path to use
  39679. * @returns the filename
  39680. */
  39681. static GetFilename(path: string): string;
  39682. /**
  39683. * Extracts the "folder" part of a path (everything before the filename).
  39684. * @param uri The URI to extract the info from
  39685. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39686. * @returns The "folder" part of the path
  39687. */
  39688. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39689. /**
  39690. * Extracts text content from a DOM element hierarchy
  39691. * @param element defines the root element
  39692. * @returns a string
  39693. */
  39694. static GetDOMTextContent(element: HTMLElement): string;
  39695. /**
  39696. * Convert an angle in radians to degrees
  39697. * @param angle defines the angle to convert
  39698. * @returns the angle in degrees
  39699. */
  39700. static ToDegrees(angle: number): number;
  39701. /**
  39702. * Convert an angle in degrees to radians
  39703. * @param angle defines the angle to convert
  39704. * @returns the angle in radians
  39705. */
  39706. static ToRadians(angle: number): number;
  39707. /**
  39708. * Encode a buffer to a base64 string
  39709. * @param buffer defines the buffer to encode
  39710. * @returns the encoded string
  39711. */
  39712. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39713. /**
  39714. * Extracts minimum and maximum values from a list of indexed positions
  39715. * @param positions defines the positions to use
  39716. * @param indices defines the indices to the positions
  39717. * @param indexStart defines the start index
  39718. * @param indexCount defines the end index
  39719. * @param bias defines bias value to add to the result
  39720. * @return minimum and maximum values
  39721. */
  39722. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39723. minimum: Vector3;
  39724. maximum: Vector3;
  39725. };
  39726. /**
  39727. * Extracts minimum and maximum values from a list of positions
  39728. * @param positions defines the positions to use
  39729. * @param start defines the start index in the positions array
  39730. * @param count defines the number of positions to handle
  39731. * @param bias defines bias value to add to the result
  39732. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39733. * @return minimum and maximum values
  39734. */
  39735. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39736. minimum: Vector3;
  39737. maximum: Vector3;
  39738. };
  39739. /**
  39740. * Returns an array if obj is not an array
  39741. * @param obj defines the object to evaluate as an array
  39742. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39743. * @returns either obj directly if obj is an array or a new array containing obj
  39744. */
  39745. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39746. /**
  39747. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39748. * @param size the number of element to construct and put in the array
  39749. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39750. * @returns a new array filled with new objects
  39751. */
  39752. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39753. /**
  39754. * Gets the pointer prefix to use
  39755. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39756. */
  39757. static GetPointerPrefix(): string;
  39758. /**
  39759. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39760. * @param func - the function to be called
  39761. * @param requester - the object that will request the next frame. Falls back to window.
  39762. * @returns frame number
  39763. */
  39764. static QueueNewFrame(func: () => void, requester?: any): number;
  39765. /**
  39766. * Ask the browser to promote the current element to fullscreen rendering mode
  39767. * @param element defines the DOM element to promote
  39768. */
  39769. static RequestFullscreen(element: HTMLElement): void;
  39770. /**
  39771. * Asks the browser to exit fullscreen mode
  39772. */
  39773. static ExitFullscreen(): void;
  39774. /**
  39775. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39776. * @param url define the url we are trying
  39777. * @param element define the dom element where to configure the cors policy
  39778. */
  39779. static SetCorsBehavior(url: string | string[], element: {
  39780. crossOrigin: string | null;
  39781. }): void;
  39782. /**
  39783. * Removes unwanted characters from an url
  39784. * @param url defines the url to clean
  39785. * @returns the cleaned url
  39786. */
  39787. static CleanUrl(url: string): string;
  39788. /**
  39789. * Gets or sets a function used to pre-process url before using them to load assets
  39790. */
  39791. static PreprocessUrl: (url: string) => string;
  39792. /**
  39793. * Loads an image as an HTMLImageElement.
  39794. * @param input url string, ArrayBuffer, or Blob to load
  39795. * @param onLoad callback called when the image successfully loads
  39796. * @param onError callback called when the image fails to load
  39797. * @param offlineProvider offline provider for caching
  39798. * @returns the HTMLImageElement of the loaded image
  39799. */
  39800. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39801. /**
  39802. * Loads a file
  39803. * @param url url string, ArrayBuffer, or Blob to load
  39804. * @param onSuccess callback called when the file successfully loads
  39805. * @param onProgress callback called while file is loading (if the server supports this mode)
  39806. * @param offlineProvider defines the offline provider for caching
  39807. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39808. * @param onError callback called when the file fails to load
  39809. * @returns a file request object
  39810. */
  39811. 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;
  39812. /**
  39813. * Load a script (identified by an url). When the url returns, the
  39814. * content of this file is added into a new script element, attached to the DOM (body element)
  39815. * @param scriptUrl defines the url of the script to laod
  39816. * @param onSuccess defines the callback called when the script is loaded
  39817. * @param onError defines the callback to call if an error occurs
  39818. */
  39819. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39820. /**
  39821. * Loads a file from a blob
  39822. * @param fileToLoad defines the blob to use
  39823. * @param callback defines the callback to call when data is loaded
  39824. * @param progressCallback defines the callback to call during loading process
  39825. * @returns a file request object
  39826. */
  39827. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39828. /**
  39829. * Loads a file
  39830. * @param fileToLoad defines the file to load
  39831. * @param callback defines the callback to call when data is loaded
  39832. * @param progressCallBack defines the callback to call during loading process
  39833. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39834. * @returns a file request object
  39835. */
  39836. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39837. /**
  39838. * Creates a data url from a given string content
  39839. * @param content defines the content to convert
  39840. * @returns the new data url link
  39841. */
  39842. static FileAsURL(content: string): string;
  39843. /**
  39844. * Format the given number to a specific decimal format
  39845. * @param value defines the number to format
  39846. * @param decimals defines the number of decimals to use
  39847. * @returns the formatted string
  39848. */
  39849. static Format(value: number, decimals?: number): string;
  39850. /**
  39851. * Checks if a given vector is inside a specific range
  39852. * @param v defines the vector to test
  39853. * @param min defines the minimum range
  39854. * @param max defines the maximum range
  39855. */
  39856. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39857. /**
  39858. * Tries to copy an object by duplicating every property
  39859. * @param source defines the source object
  39860. * @param destination defines the target object
  39861. * @param doNotCopyList defines a list of properties to avoid
  39862. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39863. */
  39864. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39865. /**
  39866. * Gets a boolean indicating if the given object has no own property
  39867. * @param obj defines the object to test
  39868. * @returns true if object has no own property
  39869. */
  39870. static IsEmpty(obj: any): boolean;
  39871. /**
  39872. * Function used to register events at window level
  39873. * @param events defines the events to register
  39874. */
  39875. static RegisterTopRootEvents(events: {
  39876. name: string;
  39877. handler: Nullable<(e: FocusEvent) => any>;
  39878. }[]): void;
  39879. /**
  39880. * Function used to unregister events from window level
  39881. * @param events defines the events to unregister
  39882. */
  39883. static UnregisterTopRootEvents(events: {
  39884. name: string;
  39885. handler: Nullable<(e: FocusEvent) => any>;
  39886. }[]): void;
  39887. /**
  39888. * Dumps the current bound framebuffer
  39889. * @param width defines the rendering width
  39890. * @param height defines the rendering height
  39891. * @param engine defines the hosting engine
  39892. * @param successCallback defines the callback triggered once the data are available
  39893. * @param mimeType defines the mime type of the result
  39894. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39895. */
  39896. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39897. /**
  39898. * Converts the canvas data to blob.
  39899. * This acts as a polyfill for browsers not supporting the to blob function.
  39900. * @param canvas Defines the canvas to extract the data from
  39901. * @param successCallback Defines the callback triggered once the data are available
  39902. * @param mimeType Defines the mime type of the result
  39903. */
  39904. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39905. /**
  39906. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39907. * @param successCallback defines the callback triggered once the data are available
  39908. * @param mimeType defines the mime type of the result
  39909. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39910. */
  39911. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39912. /**
  39913. * Downloads a blob in the browser
  39914. * @param blob defines the blob to download
  39915. * @param fileName defines the name of the downloaded file
  39916. */
  39917. static Download(blob: Blob, fileName: string): void;
  39918. /**
  39919. * Captures a screenshot of the current rendering
  39920. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39921. * @param engine defines the rendering engine
  39922. * @param camera defines the source camera
  39923. * @param size This parameter can be set to a single number or to an object with the
  39924. * following (optional) properties: precision, width, height. If a single number is passed,
  39925. * it will be used for both width and height. If an object is passed, the screenshot size
  39926. * will be derived from the parameters. The precision property is a multiplier allowing
  39927. * rendering at a higher or lower resolution
  39928. * @param successCallback defines the callback receives a single parameter which contains the
  39929. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39930. * src parameter of an <img> to display it
  39931. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39932. * Check your browser for supported MIME types
  39933. */
  39934. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  39935. /**
  39936. * Generates an image screenshot from the specified camera.
  39937. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39938. * @param engine The engine to use for rendering
  39939. * @param camera The camera to use for rendering
  39940. * @param size This parameter can be set to a single number or to an object with the
  39941. * following (optional) properties: precision, width, height. If a single number is passed,
  39942. * it will be used for both width and height. If an object is passed, the screenshot size
  39943. * will be derived from the parameters. The precision property is a multiplier allowing
  39944. * rendering at a higher or lower resolution
  39945. * @param successCallback The callback receives a single parameter which contains the
  39946. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39947. * src parameter of an <img> to display it
  39948. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39949. * Check your browser for supported MIME types
  39950. * @param samples Texture samples (default: 1)
  39951. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39952. * @param fileName A name for for the downloaded file.
  39953. */
  39954. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39955. /**
  39956. * Validates if xhr data is correct
  39957. * @param xhr defines the request to validate
  39958. * @param dataType defines the expected data type
  39959. * @returns true if data is correct
  39960. */
  39961. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  39962. /**
  39963. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39964. * Be aware Math.random() could cause collisions, but:
  39965. * "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"
  39966. * @returns a pseudo random id
  39967. */
  39968. static RandomId(): string;
  39969. /**
  39970. * Test if the given uri is a base64 string
  39971. * @param uri The uri to test
  39972. * @return True if the uri is a base64 string or false otherwise
  39973. */
  39974. static IsBase64(uri: string): boolean;
  39975. /**
  39976. * Decode the given base64 uri.
  39977. * @param uri The uri to decode
  39978. * @return The decoded base64 data.
  39979. */
  39980. static DecodeBase64(uri: string): ArrayBuffer;
  39981. /**
  39982. * No log
  39983. */
  39984. static readonly NoneLogLevel: number;
  39985. /**
  39986. * Only message logs
  39987. */
  39988. static readonly MessageLogLevel: number;
  39989. /**
  39990. * Only warning logs
  39991. */
  39992. static readonly WarningLogLevel: number;
  39993. /**
  39994. * Only error logs
  39995. */
  39996. static readonly ErrorLogLevel: number;
  39997. /**
  39998. * All logs
  39999. */
  40000. static readonly AllLogLevel: number;
  40001. private static _LogCache;
  40002. /**
  40003. * Gets a value indicating the number of loading errors
  40004. * @ignorenaming
  40005. */
  40006. static errorsCount: number;
  40007. /**
  40008. * Callback called when a new log is added
  40009. */
  40010. static OnNewCacheEntry: (entry: string) => void;
  40011. private static _AddLogEntry;
  40012. private static _FormatMessage;
  40013. private static _LogDisabled;
  40014. private static _LogEnabled;
  40015. private static _WarnDisabled;
  40016. private static _WarnEnabled;
  40017. private static _ErrorDisabled;
  40018. private static _ErrorEnabled;
  40019. /**
  40020. * Log a message to the console
  40021. */
  40022. static Log: (message: string) => void;
  40023. /**
  40024. * Write a warning message to the console
  40025. */
  40026. static Warn: (message: string) => void;
  40027. /**
  40028. * Write an error message to the console
  40029. */
  40030. static Error: (message: string) => void;
  40031. /**
  40032. * Gets current log cache (list of logs)
  40033. */
  40034. static readonly LogCache: string;
  40035. /**
  40036. * Clears the log cache
  40037. */
  40038. static ClearLogCache(): void;
  40039. /**
  40040. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40041. */
  40042. static LogLevels: number;
  40043. /**
  40044. * Checks if the loaded document was accessed via `file:`-Protocol.
  40045. * @returns boolean
  40046. */
  40047. static IsFileURL(): boolean;
  40048. /**
  40049. * Checks if the window object exists
  40050. * @returns true if the window object exists
  40051. */
  40052. static IsWindowObjectExist(): boolean;
  40053. /**
  40054. * No performance log
  40055. */
  40056. static readonly PerformanceNoneLogLevel: number;
  40057. /**
  40058. * Use user marks to log performance
  40059. */
  40060. static readonly PerformanceUserMarkLogLevel: number;
  40061. /**
  40062. * Log performance to the console
  40063. */
  40064. static readonly PerformanceConsoleLogLevel: number;
  40065. private static _performance;
  40066. /**
  40067. * Sets the current performance log level
  40068. */
  40069. static PerformanceLogLevel: number;
  40070. private static _StartPerformanceCounterDisabled;
  40071. private static _EndPerformanceCounterDisabled;
  40072. private static _StartUserMark;
  40073. private static _EndUserMark;
  40074. private static _StartPerformanceConsole;
  40075. private static _EndPerformanceConsole;
  40076. /**
  40077. * Injects the @see CustomRequestHeaders into the given request
  40078. * @param request the request that should be used for injection
  40079. */
  40080. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  40081. /**
  40082. * Starts a performance counter
  40083. */
  40084. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40085. /**
  40086. * Ends a specific performance coutner
  40087. */
  40088. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40089. /**
  40090. * Gets either window.performance.now() if supported or Date.now() else
  40091. */
  40092. static readonly Now: number;
  40093. /**
  40094. * This method will return the name of the class used to create the instance of the given object.
  40095. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40096. * @param object the object to get the class name from
  40097. * @param isType defines if the object is actually a type
  40098. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40099. */
  40100. static GetClassName(object: any, isType?: boolean): string;
  40101. /**
  40102. * Gets the first element of an array satisfying a given predicate
  40103. * @param array defines the array to browse
  40104. * @param predicate defines the predicate to use
  40105. * @returns null if not found or the element
  40106. */
  40107. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40108. /**
  40109. * This method will return the name of the full name of the class, including its owning module (if any).
  40110. * 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).
  40111. * @param object the object to get the class name from
  40112. * @param isType defines if the object is actually a type
  40113. * @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.
  40114. * @ignorenaming
  40115. */
  40116. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40117. /**
  40118. * Returns a promise that resolves after the given amount of time.
  40119. * @param delay Number of milliseconds to delay
  40120. * @returns Promise that resolves after the given amount of time
  40121. */
  40122. static DelayAsync(delay: number): Promise<void>;
  40123. /**
  40124. * Gets the current gradient from an array of IValueGradient
  40125. * @param ratio defines the current ratio to get
  40126. * @param gradients defines the array of IValueGradient
  40127. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  40128. */
  40129. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  40130. }
  40131. /**
  40132. * This class is used to track a performance counter which is number based.
  40133. * The user has access to many properties which give statistics of different nature.
  40134. *
  40135. * The implementer can track two kinds of Performance Counter: time and count.
  40136. * 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.
  40137. * 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.
  40138. */
  40139. class PerfCounter {
  40140. /**
  40141. * Gets or sets a global boolean to turn on and off all the counters
  40142. */
  40143. static Enabled: boolean;
  40144. /**
  40145. * Returns the smallest value ever
  40146. */
  40147. readonly min: number;
  40148. /**
  40149. * Returns the biggest value ever
  40150. */
  40151. readonly max: number;
  40152. /**
  40153. * Returns the average value since the performance counter is running
  40154. */
  40155. readonly average: number;
  40156. /**
  40157. * Returns the average value of the last second the counter was monitored
  40158. */
  40159. readonly lastSecAverage: number;
  40160. /**
  40161. * Returns the current value
  40162. */
  40163. readonly current: number;
  40164. /**
  40165. * Gets the accumulated total
  40166. */
  40167. readonly total: number;
  40168. /**
  40169. * Gets the total value count
  40170. */
  40171. readonly count: number;
  40172. /**
  40173. * Creates a new counter
  40174. */
  40175. constructor();
  40176. /**
  40177. * Call this method to start monitoring a new frame.
  40178. * 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.
  40179. */
  40180. fetchNewFrame(): void;
  40181. /**
  40182. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40183. * @param newCount the count value to add to the monitored count
  40184. * @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.
  40185. */
  40186. addCount(newCount: number, fetchResult: boolean): void;
  40187. /**
  40188. * Start monitoring this performance counter
  40189. */
  40190. beginMonitoring(): void;
  40191. /**
  40192. * Compute the time lapsed since the previous beginMonitoring() call.
  40193. * @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
  40194. */
  40195. endMonitoring(newFrame?: boolean): void;
  40196. private _fetchResult;
  40197. private _startMonitoringTime;
  40198. private _min;
  40199. private _max;
  40200. private _average;
  40201. private _current;
  40202. private _totalValueCount;
  40203. private _totalAccumulated;
  40204. private _lastSecAverage;
  40205. private _lastSecAccumulated;
  40206. private _lastSecTime;
  40207. private _lastSecValueCount;
  40208. }
  40209. /**
  40210. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40211. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40212. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40213. * @param name The name of the class, case should be preserved
  40214. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40215. */
  40216. function className(name: string, module?: string): (target: Object) => void;
  40217. /**
  40218. * An implementation of a loop for asynchronous functions.
  40219. */
  40220. class AsyncLoop {
  40221. /**
  40222. * Defines the number of iterations for the loop
  40223. */
  40224. iterations: number;
  40225. /**
  40226. * Defines the current index of the loop.
  40227. */
  40228. index: number;
  40229. private _done;
  40230. private _fn;
  40231. private _successCallback;
  40232. /**
  40233. * Constructor.
  40234. * @param iterations the number of iterations.
  40235. * @param func the function to run each iteration
  40236. * @param successCallback the callback that will be called upon succesful execution
  40237. * @param offset starting offset.
  40238. */
  40239. constructor(
  40240. /**
  40241. * Defines the number of iterations for the loop
  40242. */
  40243. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40244. /**
  40245. * Execute the next iteration. Must be called after the last iteration was finished.
  40246. */
  40247. executeNext(): void;
  40248. /**
  40249. * Break the loop and run the success callback.
  40250. */
  40251. breakLoop(): void;
  40252. /**
  40253. * Create and run an async loop.
  40254. * @param iterations the number of iterations.
  40255. * @param fn the function to run each iteration
  40256. * @param successCallback the callback that will be called upon succesful execution
  40257. * @param offset starting offset.
  40258. * @returns the created async loop object
  40259. */
  40260. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40261. /**
  40262. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40263. * @param iterations total number of iterations
  40264. * @param syncedIterations number of synchronous iterations in each async iteration.
  40265. * @param fn the function to call each iteration.
  40266. * @param callback a success call back that will be called when iterating stops.
  40267. * @param breakFunction a break condition (optional)
  40268. * @param timeout timeout settings for the setTimeout function. default - 0.
  40269. * @returns the created async loop object
  40270. */
  40271. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40272. }
  40273. }
  40274. interface HTMLCanvasElement {
  40275. /** Track wether a record is in progress */
  40276. isRecording: boolean;
  40277. /** Capture Stream method defined by some browsers */
  40278. captureStream(fps?: number): MediaStream;
  40279. }
  40280. interface MediaRecorder {
  40281. /** Starts recording */
  40282. start(timeSlice: number): void;
  40283. /** Stops recording */
  40284. stop(): void;
  40285. /** Event raised when an error arised. */
  40286. onerror: (event: ErrorEvent) => void;
  40287. /** Event raised when the recording stops. */
  40288. onstop: (event: Event) => void;
  40289. /** Event raised when a new chunk of data is available and should be tracked. */
  40290. ondataavailable: (event: Event) => void;
  40291. }
  40292. interface MediaRecorderOptions {
  40293. /** The mime type you want to use as the recording container for the new MediaRecorder */
  40294. mimeType?: string;
  40295. /** The chosen bitrate for the audio component of the media. */
  40296. audioBitsPerSecond?: number;
  40297. /** The chosen bitrate for the video component of the media. */
  40298. videoBitsPerSecond?: number;
  40299. /** 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. */
  40300. bitsPerSecond?: number;
  40301. }
  40302. interface MediaRecorderConstructor {
  40303. /**
  40304. * A reference to the prototype.
  40305. */
  40306. readonly prototype: MediaRecorder;
  40307. /**
  40308. * Creates a new MediaRecorder.
  40309. * @param stream Defines the stream to record.
  40310. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  40311. */
  40312. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  40313. }
  40314. /**
  40315. * MediaRecoreder object available in some browsers.
  40316. */
  40317. declare var MediaRecorder: MediaRecorderConstructor;
  40318. declare module BABYLON {
  40319. /**
  40320. * This represents the different options avilable for the video capture.
  40321. */
  40322. interface VideoRecorderOptions {
  40323. /** Defines the mime type of the video */
  40324. mimeType: string;
  40325. /** Defines the video the video should be recorded at */
  40326. fps: number;
  40327. /** Defines the chunk size for the recording data */
  40328. recordChunckSize: number;
  40329. }
  40330. /**
  40331. * This can helps recording videos from BabylonJS.
  40332. * This is based on the available WebRTC functionalities of the browser.
  40333. *
  40334. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  40335. */
  40336. class VideoRecorder {
  40337. private static readonly _defaultOptions;
  40338. /**
  40339. * Returns wehther or not the VideoRecorder is available in your browser.
  40340. * @param engine Defines the Babylon Engine to check the support for
  40341. * @returns true if supported otherwise false
  40342. */
  40343. static IsSupported(engine: Engine): boolean;
  40344. private readonly _options;
  40345. private _canvas;
  40346. private _mediaRecorder;
  40347. private _recordedChunks;
  40348. private _fileName;
  40349. private _resolve;
  40350. private _reject;
  40351. /**
  40352. * True wether a recording is already in progress.
  40353. */
  40354. readonly isRecording: boolean;
  40355. /**
  40356. * Create a new VideoCapture object which can help converting what you see in Babylon to
  40357. * a video file.
  40358. * @param engine Defines the BabylonJS Engine you wish to record
  40359. * @param options Defines options that can be used to customized the capture
  40360. */
  40361. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  40362. /**
  40363. * Stops the current recording before the default capture timeout passed in the startRecording
  40364. * functions.
  40365. */
  40366. stopRecording(): void;
  40367. /**
  40368. * Starts recording the canvas for a max duration specified in parameters.
  40369. * @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.
  40370. * @param maxDuration Defines the maximum recording time in seconds.
  40371. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  40372. * @return a promise callback at the end of the recording with the video data in Blob.
  40373. */
  40374. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  40375. /**
  40376. * Releases internal resources used during the recording.
  40377. */
  40378. dispose(): void;
  40379. private _handleDataAvailable;
  40380. private _handleError;
  40381. private _handleStop;
  40382. }
  40383. }
  40384. declare module BABYLON {
  40385. /**
  40386. * Defines the potential axis of a Joystick
  40387. */
  40388. enum JoystickAxis {
  40389. /** X axis */
  40390. X = 0,
  40391. /** Y axis */
  40392. Y = 1,
  40393. /** Z axis */
  40394. Z = 2
  40395. }
  40396. /**
  40397. * Class used to define virtual joystick (used in touch mode)
  40398. */
  40399. class VirtualJoystick {
  40400. /**
  40401. * Gets or sets a boolean indicating that left and right values must be inverted
  40402. */
  40403. reverseLeftRight: boolean;
  40404. /**
  40405. * Gets or sets a boolean indicating that up and down values must be inverted
  40406. */
  40407. reverseUpDown: boolean;
  40408. /**
  40409. * Gets the offset value for the position (ie. the change of the position value)
  40410. */
  40411. deltaPosition: Vector3;
  40412. /**
  40413. * Gets a boolean indicating if the virtual joystick was pressed
  40414. */
  40415. pressed: boolean;
  40416. /**
  40417. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40418. */
  40419. static Canvas: Nullable<HTMLCanvasElement>;
  40420. private static _globalJoystickIndex;
  40421. private static vjCanvasContext;
  40422. private static vjCanvasWidth;
  40423. private static vjCanvasHeight;
  40424. private static halfWidth;
  40425. private _action;
  40426. private _axisTargetedByLeftAndRight;
  40427. private _axisTargetedByUpAndDown;
  40428. private _joystickSensibility;
  40429. private _inversedSensibility;
  40430. private _joystickPointerID;
  40431. private _joystickColor;
  40432. private _joystickPointerPos;
  40433. private _joystickPreviousPointerPos;
  40434. private _joystickPointerStartPos;
  40435. private _deltaJoystickVector;
  40436. private _leftJoystick;
  40437. private _touches;
  40438. private _onPointerDownHandlerRef;
  40439. private _onPointerMoveHandlerRef;
  40440. private _onPointerUpHandlerRef;
  40441. private _onResize;
  40442. /**
  40443. * Creates a new virtual joystick
  40444. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40445. */
  40446. constructor(leftJoystick?: boolean);
  40447. /**
  40448. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40449. * @param newJoystickSensibility defines the new sensibility
  40450. */
  40451. setJoystickSensibility(newJoystickSensibility: number): void;
  40452. private _onPointerDown;
  40453. private _onPointerMove;
  40454. private _onPointerUp;
  40455. /**
  40456. * Change the color of the virtual joystick
  40457. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40458. */
  40459. setJoystickColor(newColor: string): void;
  40460. /**
  40461. * Defines a callback to call when the joystick is touched
  40462. * @param action defines the callback
  40463. */
  40464. setActionOnTouch(action: () => any): void;
  40465. /**
  40466. * Defines which axis you'd like to control for left & right
  40467. * @param axis defines the axis to use
  40468. */
  40469. setAxisForLeftRight(axis: JoystickAxis): void;
  40470. /**
  40471. * Defines which axis you'd like to control for up & down
  40472. * @param axis defines the axis to use
  40473. */
  40474. setAxisForUpDown(axis: JoystickAxis): void;
  40475. private _drawVirtualJoystick;
  40476. /**
  40477. * Release internal HTML canvas
  40478. */
  40479. releaseCanvas(): void;
  40480. }
  40481. }
  40482. declare module BABYLON {
  40483. /**
  40484. * Helper class to push actions to a pool of workers.
  40485. */
  40486. class WorkerPool implements IDisposable {
  40487. private _workerInfos;
  40488. private _pendingActions;
  40489. /**
  40490. * Constructor
  40491. * @param workers Array of workers to use for actions
  40492. */
  40493. constructor(workers: Array<Worker>);
  40494. /**
  40495. * Terminates all workers and clears any pending actions.
  40496. */
  40497. dispose(): void;
  40498. /**
  40499. * Pushes an action to the worker pool. If all the workers are active, the action will be
  40500. * pended until a worker has completed its action.
  40501. * @param action The action to perform. Call onComplete when the action is complete.
  40502. */
  40503. push(action: (worker: Worker, onComplete: () => void) => void): void;
  40504. private _execute;
  40505. }
  40506. }
  40507. declare module BABYLON {
  40508. /**
  40509. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40510. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40511. */
  40512. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40513. /**
  40514. * Gets the name of the behavior.
  40515. */
  40516. readonly name: string;
  40517. private _zoomStopsAnimation;
  40518. private _idleRotationSpeed;
  40519. private _idleRotationWaitTime;
  40520. private _idleRotationSpinupTime;
  40521. /**
  40522. * Sets the flag that indicates if user zooming should stop animation.
  40523. */
  40524. /**
  40525. * Gets the flag that indicates if user zooming should stop animation.
  40526. */
  40527. zoomStopsAnimation: boolean;
  40528. /**
  40529. * Sets the default speed at which the camera rotates around the model.
  40530. */
  40531. /**
  40532. * Gets the default speed at which the camera rotates around the model.
  40533. */
  40534. idleRotationSpeed: number;
  40535. /**
  40536. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40537. */
  40538. /**
  40539. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40540. */
  40541. idleRotationWaitTime: number;
  40542. /**
  40543. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40544. */
  40545. /**
  40546. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40547. */
  40548. idleRotationSpinupTime: number;
  40549. /**
  40550. * Gets a value indicating if the camera is currently rotating because of this behavior
  40551. */
  40552. readonly rotationInProgress: boolean;
  40553. private _onPrePointerObservableObserver;
  40554. private _onAfterCheckInputsObserver;
  40555. private _attachedCamera;
  40556. private _isPointerDown;
  40557. private _lastFrameTime;
  40558. private _lastInteractionTime;
  40559. private _cameraRotationSpeed;
  40560. /**
  40561. * Initializes the behavior.
  40562. */
  40563. init(): void;
  40564. /**
  40565. * Attaches the behavior to its arc rotate camera.
  40566. * @param camera Defines the camera to attach the behavior to
  40567. */
  40568. attach(camera: ArcRotateCamera): void;
  40569. /**
  40570. * Detaches the behavior from its current arc rotate camera.
  40571. */
  40572. detach(): void;
  40573. /**
  40574. * Returns true if user is scrolling.
  40575. * @return true if user is scrolling.
  40576. */
  40577. private _userIsZooming;
  40578. private _lastFrameRadius;
  40579. private _shouldAnimationStopForInteraction;
  40580. /**
  40581. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40582. */
  40583. private _applyUserInteraction;
  40584. private _userIsMoving;
  40585. }
  40586. }
  40587. declare module BABYLON {
  40588. /**
  40589. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40590. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40591. */
  40592. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40593. /**
  40594. * Gets the name of the behavior.
  40595. */
  40596. readonly name: string;
  40597. /**
  40598. * The easing function used by animations
  40599. */
  40600. static EasingFunction: BackEase;
  40601. /**
  40602. * The easing mode used by animations
  40603. */
  40604. static EasingMode: number;
  40605. /**
  40606. * The duration of the animation, in milliseconds
  40607. */
  40608. transitionDuration: number;
  40609. /**
  40610. * Length of the distance animated by the transition when lower radius is reached
  40611. */
  40612. lowerRadiusTransitionRange: number;
  40613. /**
  40614. * Length of the distance animated by the transition when upper radius is reached
  40615. */
  40616. upperRadiusTransitionRange: number;
  40617. private _autoTransitionRange;
  40618. /**
  40619. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40620. */
  40621. /**
  40622. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40623. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40624. */
  40625. autoTransitionRange: boolean;
  40626. private _attachedCamera;
  40627. private _onAfterCheckInputsObserver;
  40628. private _onMeshTargetChangedObserver;
  40629. /**
  40630. * Initializes the behavior.
  40631. */
  40632. init(): void;
  40633. /**
  40634. * Attaches the behavior to its arc rotate camera.
  40635. * @param camera Defines the camera to attach the behavior to
  40636. */
  40637. attach(camera: ArcRotateCamera): void;
  40638. /**
  40639. * Detaches the behavior from its current arc rotate camera.
  40640. */
  40641. detach(): void;
  40642. private _radiusIsAnimating;
  40643. private _radiusBounceTransition;
  40644. private _animatables;
  40645. private _cachedWheelPrecision;
  40646. /**
  40647. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40648. * @param radiusLimit The limit to check against.
  40649. * @return Bool to indicate if at limit.
  40650. */
  40651. private _isRadiusAtLimit;
  40652. /**
  40653. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40654. * @param radiusDelta The delta by which to animate to. Can be negative.
  40655. */
  40656. private _applyBoundRadiusAnimation;
  40657. /**
  40658. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40659. */
  40660. protected _clearAnimationLocks(): void;
  40661. /**
  40662. * Stops and removes all animations that have been applied to the camera
  40663. */
  40664. stopAllAnimations(): void;
  40665. }
  40666. }
  40667. declare module BABYLON {
  40668. /**
  40669. * 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.
  40670. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40671. */
  40672. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40673. /**
  40674. * Gets the name of the behavior.
  40675. */
  40676. readonly name: string;
  40677. private _mode;
  40678. private _radiusScale;
  40679. private _positionScale;
  40680. private _defaultElevation;
  40681. private _elevationReturnTime;
  40682. private _elevationReturnWaitTime;
  40683. private _zoomStopsAnimation;
  40684. private _framingTime;
  40685. /**
  40686. * The easing function used by animations
  40687. */
  40688. static EasingFunction: ExponentialEase;
  40689. /**
  40690. * The easing mode used by animations
  40691. */
  40692. static EasingMode: number;
  40693. /**
  40694. * Sets the current mode used by the behavior
  40695. */
  40696. /**
  40697. * Gets current mode used by the behavior.
  40698. */
  40699. mode: number;
  40700. /**
  40701. * Sets the scale applied to the radius (1 by default)
  40702. */
  40703. /**
  40704. * Gets the scale applied to the radius
  40705. */
  40706. radiusScale: number;
  40707. /**
  40708. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40709. */
  40710. /**
  40711. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40712. */
  40713. positionScale: number;
  40714. /**
  40715. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40716. * behaviour is triggered, in radians.
  40717. */
  40718. /**
  40719. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40720. * behaviour is triggered, in radians.
  40721. */
  40722. defaultElevation: number;
  40723. /**
  40724. * Sets the time (in milliseconds) taken to return to the default beta position.
  40725. * Negative value indicates camera should not return to default.
  40726. */
  40727. /**
  40728. * Gets the time (in milliseconds) taken to return to the default beta position.
  40729. * Negative value indicates camera should not return to default.
  40730. */
  40731. elevationReturnTime: number;
  40732. /**
  40733. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40734. */
  40735. /**
  40736. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40737. */
  40738. elevationReturnWaitTime: number;
  40739. /**
  40740. * Sets the flag that indicates if user zooming should stop animation.
  40741. */
  40742. /**
  40743. * Gets the flag that indicates if user zooming should stop animation.
  40744. */
  40745. zoomStopsAnimation: boolean;
  40746. /**
  40747. * Sets the transition time when framing the mesh, in milliseconds
  40748. */
  40749. /**
  40750. * Gets the transition time when framing the mesh, in milliseconds
  40751. */
  40752. framingTime: number;
  40753. /**
  40754. * Define if the behavior should automatically change the configured
  40755. * camera limits and sensibilities.
  40756. */
  40757. autoCorrectCameraLimitsAndSensibility: boolean;
  40758. private _onPrePointerObservableObserver;
  40759. private _onAfterCheckInputsObserver;
  40760. private _onMeshTargetChangedObserver;
  40761. private _attachedCamera;
  40762. private _isPointerDown;
  40763. private _lastInteractionTime;
  40764. /**
  40765. * Initializes the behavior.
  40766. */
  40767. init(): void;
  40768. /**
  40769. * Attaches the behavior to its arc rotate camera.
  40770. * @param camera Defines the camera to attach the behavior to
  40771. */
  40772. attach(camera: ArcRotateCamera): void;
  40773. /**
  40774. * Detaches the behavior from its current arc rotate camera.
  40775. */
  40776. detach(): void;
  40777. private _animatables;
  40778. private _betaIsAnimating;
  40779. private _betaTransition;
  40780. private _radiusTransition;
  40781. private _vectorTransition;
  40782. /**
  40783. * Targets the given mesh and updates zoom level accordingly.
  40784. * @param mesh The mesh to target.
  40785. * @param radius Optional. If a cached radius position already exists, overrides default.
  40786. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40787. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40788. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40789. */
  40790. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40791. /**
  40792. * Targets the given mesh with its children and updates zoom level accordingly.
  40793. * @param mesh The mesh to target.
  40794. * @param radius Optional. If a cached radius position already exists, overrides default.
  40795. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40796. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40797. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40798. */
  40799. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40800. /**
  40801. * Targets the given meshes with their children and updates zoom level accordingly.
  40802. * @param meshes The mesh to target.
  40803. * @param radius Optional. If a cached radius position already exists, overrides default.
  40804. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40805. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40806. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40807. */
  40808. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40809. /**
  40810. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40811. * @param minimumWorld Determines the smaller position of the bounding box extend
  40812. * @param maximumWorld Determines the bigger position of the bounding box extend
  40813. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40814. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40815. */
  40816. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40817. /**
  40818. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40819. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40820. * frustum width.
  40821. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40822. * to fully enclose the mesh in the viewing frustum.
  40823. */
  40824. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40825. /**
  40826. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40827. * is automatically returned to its default position (expected to be above ground plane).
  40828. */
  40829. private _maintainCameraAboveGround;
  40830. /**
  40831. * Returns the frustum slope based on the canvas ratio and camera FOV
  40832. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40833. */
  40834. private _getFrustumSlope;
  40835. /**
  40836. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40837. */
  40838. private _clearAnimationLocks;
  40839. /**
  40840. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40841. */
  40842. private _applyUserInteraction;
  40843. /**
  40844. * Stops and removes all animations that have been applied to the camera
  40845. */
  40846. stopAllAnimations(): void;
  40847. /**
  40848. * Gets a value indicating if the user is moving the camera
  40849. */
  40850. readonly isUserIsMoving: boolean;
  40851. /**
  40852. * The camera can move all the way towards the mesh.
  40853. */
  40854. static IgnoreBoundsSizeMode: number;
  40855. /**
  40856. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40857. */
  40858. static FitFrustumSidesMode: number;
  40859. }
  40860. }
  40861. declare module BABYLON {
  40862. /**
  40863. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40864. */
  40865. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  40866. private ui;
  40867. /**
  40868. * The name of the behavior
  40869. */
  40870. name: string;
  40871. /**
  40872. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40873. */
  40874. distanceAwayFromFace: number;
  40875. /**
  40876. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40877. */
  40878. distanceAwayFromBottomOfFace: number;
  40879. private _faceVectors;
  40880. private _target;
  40881. private _scene;
  40882. private _onRenderObserver;
  40883. private _tmpMatrix;
  40884. private _tmpVector;
  40885. /**
  40886. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40887. * @param ui The transform node that should be attched to the mesh
  40888. */
  40889. constructor(ui: BABYLON.TransformNode);
  40890. /**
  40891. * Initializes the behavior
  40892. */
  40893. init(): void;
  40894. private _closestFace;
  40895. private _zeroVector;
  40896. private _lookAtTmpMatrix;
  40897. private _lookAtToRef;
  40898. /**
  40899. * Attaches the AttachToBoxBehavior to the passed in mesh
  40900. * @param target The mesh that the specified node will be attached to
  40901. */
  40902. attach(target: BABYLON.Mesh): void;
  40903. /**
  40904. * Detaches the behavior from the mesh
  40905. */
  40906. detach(): void;
  40907. }
  40908. }
  40909. declare module BABYLON {
  40910. /**
  40911. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40912. */
  40913. class FadeInOutBehavior implements Behavior<Mesh> {
  40914. /**
  40915. * Time in milliseconds to delay before fading in (Default: 0)
  40916. */
  40917. delay: number;
  40918. /**
  40919. * Time in milliseconds for the mesh to fade in (Default: 300)
  40920. */
  40921. fadeInTime: number;
  40922. private _millisecondsPerFrame;
  40923. private _hovered;
  40924. private _hoverValue;
  40925. private _ownerNode;
  40926. /**
  40927. * Instatiates the FadeInOutBehavior
  40928. */
  40929. constructor();
  40930. /**
  40931. * The name of the behavior
  40932. */
  40933. readonly name: string;
  40934. /**
  40935. * Initializes the behavior
  40936. */
  40937. init(): void;
  40938. /**
  40939. * Attaches the fade behavior on the passed in mesh
  40940. * @param ownerNode The mesh that will be faded in/out once attached
  40941. */
  40942. attach(ownerNode: Mesh): void;
  40943. /**
  40944. * Detaches the behavior from the mesh
  40945. */
  40946. detach(): void;
  40947. /**
  40948. * Triggers the mesh to begin fading in or out
  40949. * @param value if the object should fade in or out (true to fade in)
  40950. */
  40951. fadeIn(value: boolean): void;
  40952. private _update;
  40953. private _setAllVisibility;
  40954. }
  40955. }
  40956. declare module BABYLON {
  40957. /**
  40958. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40959. */
  40960. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40961. private _dragBehaviorA;
  40962. private _dragBehaviorB;
  40963. private _startDistance;
  40964. private _initialScale;
  40965. private _targetScale;
  40966. private _ownerNode;
  40967. private _sceneRenderObserver;
  40968. /**
  40969. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40970. */
  40971. constructor();
  40972. /**
  40973. * The name of the behavior
  40974. */
  40975. readonly name: string;
  40976. /**
  40977. * Initializes the behavior
  40978. */
  40979. init(): void;
  40980. private _getCurrentDistance;
  40981. /**
  40982. * Attaches the scale behavior the passed in mesh
  40983. * @param ownerNode The mesh that will be scaled around once attached
  40984. */
  40985. attach(ownerNode: Mesh): void;
  40986. /**
  40987. * Detaches the behavior from the mesh
  40988. */
  40989. detach(): void;
  40990. }
  40991. }
  40992. declare module BABYLON {
  40993. /**
  40994. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40995. */
  40996. class PointerDragBehavior implements Behavior<AbstractMesh> {
  40997. private static _AnyMouseID;
  40998. private _attachedNode;
  40999. private _dragPlane;
  41000. private _scene;
  41001. private _pointerObserver;
  41002. private _beforeRenderObserver;
  41003. private static _planeScene;
  41004. /**
  41005. * 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)
  41006. */
  41007. maxDragAngle: number;
  41008. /**
  41009. * @hidden
  41010. */
  41011. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  41012. /**
  41013. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41014. */
  41015. currentDraggingPointerID: number;
  41016. /**
  41017. * The last position where the pointer hit the drag plane in world space
  41018. */
  41019. lastDragPosition: Vector3;
  41020. /**
  41021. * If the behavior is currently in a dragging state
  41022. */
  41023. dragging: boolean;
  41024. /**
  41025. * 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)
  41026. */
  41027. dragDeltaRatio: number;
  41028. /**
  41029. * If the drag plane orientation should be updated during the dragging (Default: true)
  41030. */
  41031. updateDragPlane: boolean;
  41032. private _debugMode;
  41033. private _moving;
  41034. /**
  41035. * Fires each time the attached mesh is dragged with the pointer
  41036. * * delta between last drag position and current drag position in world space
  41037. * * dragDistance along the drag axis
  41038. * * dragPlaneNormal normal of the current drag plane used during the drag
  41039. * * dragPlanePoint in world space where the drag intersects the drag plane
  41040. */
  41041. onDragObservable: Observable<{
  41042. delta: Vector3;
  41043. dragPlanePoint: Vector3;
  41044. dragPlaneNormal: Vector3;
  41045. dragDistance: number;
  41046. pointerId: number;
  41047. }>;
  41048. /**
  41049. * Fires each time a drag begins (eg. mouse down on mesh)
  41050. */
  41051. onDragStartObservable: Observable<{
  41052. dragPlanePoint: Vector3;
  41053. pointerId: number;
  41054. }>;
  41055. /**
  41056. * Fires each time a drag ends (eg. mouse release after drag)
  41057. */
  41058. onDragEndObservable: Observable<{
  41059. dragPlanePoint: Vector3;
  41060. pointerId: number;
  41061. }>;
  41062. /**
  41063. * If the attached mesh should be moved when dragged
  41064. */
  41065. moveAttached: boolean;
  41066. /**
  41067. * If the drag behavior will react to drag events (Default: true)
  41068. */
  41069. enabled: boolean;
  41070. /**
  41071. * If camera controls should be detached during the drag
  41072. */
  41073. detachCameraControls: boolean;
  41074. /**
  41075. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  41076. */
  41077. useObjectOrienationForDragging: boolean;
  41078. private _options;
  41079. /**
  41080. * Creates a pointer drag behavior that can be attached to a mesh
  41081. * @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)
  41082. */
  41083. constructor(options?: {
  41084. dragAxis?: Vector3;
  41085. dragPlaneNormal?: Vector3;
  41086. });
  41087. /**
  41088. * The name of the behavior
  41089. */
  41090. readonly name: string;
  41091. /**
  41092. * Initializes the behavior
  41093. */
  41094. init(): void;
  41095. private _tmpVector;
  41096. private _alternatePickedPoint;
  41097. private _worldDragAxis;
  41098. private _targetPosition;
  41099. private _attachedElement;
  41100. /**
  41101. * Attaches the drag behavior the passed in mesh
  41102. * @param ownerNode The mesh that will be dragged around once attached
  41103. */
  41104. attach(ownerNode: AbstractMesh): void;
  41105. /**
  41106. * Force relase the drag action by code.
  41107. */
  41108. releaseDrag(): void;
  41109. private _startDragRay;
  41110. private _lastPointerRay;
  41111. /**
  41112. * Simulates the start of a pointer drag event on the behavior
  41113. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41114. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41115. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41116. */
  41117. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41118. private _startDrag;
  41119. private _dragDelta;
  41120. private _moveDrag;
  41121. private _pickWithRayOnDragPlane;
  41122. private _pointA;
  41123. private _pointB;
  41124. private _pointC;
  41125. private _lineA;
  41126. private _lineB;
  41127. private _localAxis;
  41128. private _lookAt;
  41129. private _updateDragPlanePosition;
  41130. /**
  41131. * Detaches the behavior from the mesh
  41132. */
  41133. detach(): void;
  41134. }
  41135. }
  41136. declare module BABYLON {
  41137. /**
  41138. * 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
  41139. */
  41140. class SixDofDragBehavior implements Behavior<Mesh> {
  41141. private static _virtualScene;
  41142. private _ownerNode;
  41143. private _sceneRenderObserver;
  41144. private _scene;
  41145. private _targetPosition;
  41146. private _virtualOriginMesh;
  41147. private _virtualDragMesh;
  41148. private _pointerObserver;
  41149. private _moving;
  41150. private _startingOrientation;
  41151. /**
  41152. * 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)
  41153. */
  41154. private zDragFactor;
  41155. /**
  41156. * If the behavior is currently in a dragging state
  41157. */
  41158. dragging: boolean;
  41159. /**
  41160. * 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)
  41161. */
  41162. dragDeltaRatio: number;
  41163. /**
  41164. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41165. */
  41166. currentDraggingPointerID: number;
  41167. /**
  41168. * If camera controls should be detached during the drag
  41169. */
  41170. detachCameraControls: boolean;
  41171. /**
  41172. * Fires each time a drag starts
  41173. */
  41174. onDragStartObservable: Observable<{}>;
  41175. /**
  41176. * Fires each time a drag ends (eg. mouse release after drag)
  41177. */
  41178. onDragEndObservable: Observable<{}>;
  41179. /**
  41180. * 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
  41181. */
  41182. constructor();
  41183. /**
  41184. * The name of the behavior
  41185. */
  41186. readonly name: string;
  41187. /**
  41188. * Initializes the behavior
  41189. */
  41190. init(): void;
  41191. /**
  41192. * Attaches the scale behavior the passed in mesh
  41193. * @param ownerNode The mesh that will be scaled around once attached
  41194. */
  41195. attach(ownerNode: Mesh): void;
  41196. /**
  41197. * Detaches the behavior from the mesh
  41198. */
  41199. detach(): void;
  41200. }
  41201. }
  41202. declare module BABYLON {
  41203. /**
  41204. * Contains an array of blocks representing the octree
  41205. */
  41206. interface IOctreeContainer<T> {
  41207. /**
  41208. * Blocks within the octree
  41209. */
  41210. blocks: Array<OctreeBlock<T>>;
  41211. }
  41212. /**
  41213. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41214. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41215. */
  41216. class Octree<T> {
  41217. /** 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.) */
  41218. maxDepth: number;
  41219. /**
  41220. * Blocks within the octree containing objects
  41221. */
  41222. blocks: Array<OctreeBlock<T>>;
  41223. /**
  41224. * Content stored in the octree
  41225. */
  41226. dynamicContent: T[];
  41227. private _maxBlockCapacity;
  41228. private _selectionContent;
  41229. private _creationFunc;
  41230. /**
  41231. * Creates a octree
  41232. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41233. * @param creationFunc function to be used to instatiate the octree
  41234. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41235. * @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.)
  41236. */
  41237. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41238. /** 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.) */
  41239. maxDepth?: number);
  41240. /**
  41241. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41242. * @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);
  41243. * @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);
  41244. * @param entries meshes to be added to the octree blocks
  41245. */
  41246. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41247. /**
  41248. * Adds a mesh to the octree
  41249. * @param entry Mesh to add to the octree
  41250. */
  41251. addMesh(entry: T): void;
  41252. /**
  41253. * Selects an array of meshes within the frustum
  41254. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41255. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41256. * @returns array of meshes within the frustum
  41257. */
  41258. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41259. /**
  41260. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41261. * @param sphereCenter defines the bounding sphere center
  41262. * @param sphereRadius defines the bounding sphere radius
  41263. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41264. * @returns an array of objects that intersect the sphere
  41265. */
  41266. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41267. /**
  41268. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41269. * @param ray defines the ray to test with
  41270. * @returns array of intersected objects
  41271. */
  41272. intersectsRay(ray: Ray): SmartArray<T>;
  41273. /**
  41274. * @hidden
  41275. */
  41276. 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;
  41277. /**
  41278. * Adds a mesh into the octree block if it intersects the block
  41279. */
  41280. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41281. /**
  41282. * Adds a submesh into the octree block if it intersects the block
  41283. */
  41284. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41285. }
  41286. }
  41287. declare module BABYLON {
  41288. /**
  41289. * Class used to store a cell in an octree
  41290. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41291. */
  41292. class OctreeBlock<T> {
  41293. /**
  41294. * Gets the content of the current block
  41295. */
  41296. entries: T[];
  41297. /**
  41298. * Gets the list of block children
  41299. */
  41300. blocks: Array<OctreeBlock<T>>;
  41301. private _depth;
  41302. private _maxDepth;
  41303. private _capacity;
  41304. private _minPoint;
  41305. private _maxPoint;
  41306. private _boundingVectors;
  41307. private _creationFunc;
  41308. /**
  41309. * Creates a new block
  41310. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41311. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41312. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41313. * @param depth defines the current depth of this block in the octree
  41314. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41315. * @param creationFunc defines a callback to call when an element is added to the block
  41316. */
  41317. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41318. /**
  41319. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41320. */
  41321. readonly capacity: number;
  41322. /**
  41323. * Gets the minimum vector (in world space) of the block's bounding box
  41324. */
  41325. readonly minPoint: Vector3;
  41326. /**
  41327. * Gets the maximum vector (in world space) of the block's bounding box
  41328. */
  41329. readonly maxPoint: Vector3;
  41330. /**
  41331. * Add a new element to this block
  41332. * @param entry defines the element to add
  41333. */
  41334. addEntry(entry: T): void;
  41335. /**
  41336. * Add an array of elements to this block
  41337. * @param entries defines the array of elements to add
  41338. */
  41339. addEntries(entries: T[]): void;
  41340. /**
  41341. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41342. * @param frustumPlanes defines the frustum planes to test
  41343. * @param selection defines the array to store current content if selection is positive
  41344. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41345. */
  41346. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41347. /**
  41348. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41349. * @param sphereCenter defines the bounding sphere center
  41350. * @param sphereRadius defines the bounding sphere radius
  41351. * @param selection defines the array to store current content if selection is positive
  41352. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41353. */
  41354. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41355. /**
  41356. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41357. * @param ray defines the ray to test with
  41358. * @param selection defines the array to store current content if selection is positive
  41359. */
  41360. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41361. /**
  41362. * Subdivide the content into child blocks (this block will then be empty)
  41363. */
  41364. createInnerBlocks(): void;
  41365. }
  41366. }
  41367. declare module BABYLON {
  41368. interface Scene {
  41369. /**
  41370. * @hidden
  41371. * Backing Filed
  41372. */
  41373. _selectionOctree: Octree<AbstractMesh>;
  41374. /**
  41375. * Gets the octree used to boost mesh selection (picking)
  41376. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41377. */
  41378. selectionOctree: Octree<AbstractMesh>;
  41379. /**
  41380. * Creates or updates the octree used to boost selection (picking)
  41381. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41382. * @param maxCapacity defines the maximum capacity per leaf
  41383. * @param maxDepth defines the maximum depth of the octree
  41384. * @returns an octree of AbstractMesh
  41385. */
  41386. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41387. }
  41388. interface AbstractMesh {
  41389. /**
  41390. * @hidden
  41391. * Backing Field
  41392. */
  41393. _submeshesOctree: Octree<SubMesh>;
  41394. /**
  41395. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41396. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41397. * @param maxCapacity defines the maximum size of each block (64 by default)
  41398. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41399. * @returns the new octree
  41400. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41401. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41402. */
  41403. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41404. }
  41405. /**
  41406. * Defines the octree scene component responsible to manage any octrees
  41407. * in a given scene.
  41408. */
  41409. class OctreeSceneComponent {
  41410. /**
  41411. * The component name helpfull to identify the component in the list of scene components.
  41412. */
  41413. readonly name: string;
  41414. /**
  41415. * The scene the component belongs to.
  41416. */
  41417. scene: Scene;
  41418. /**
  41419. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41420. */
  41421. readonly checksIsEnabled: boolean;
  41422. /**
  41423. * Creates a new instance of the component for the given scene
  41424. * @param scene Defines the scene to register the component in
  41425. */
  41426. constructor(scene: Scene);
  41427. /**
  41428. * Registers the component in a given scene
  41429. */
  41430. register(): void;
  41431. /**
  41432. * Return the list of active meshes
  41433. * @returns the list of active meshes
  41434. */
  41435. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41436. /**
  41437. * Return the list of active sub meshes
  41438. * @param mesh The mesh to get the candidates sub meshes from
  41439. * @returns the list of active sub meshes
  41440. */
  41441. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41442. private _tempRay;
  41443. /**
  41444. * Return the list of sub meshes intersecting with a given local ray
  41445. * @param mesh defines the mesh to find the submesh for
  41446. * @param localRay defines the ray in local space
  41447. * @returns the list of intersecting sub meshes
  41448. */
  41449. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41450. /**
  41451. * Return the list of sub meshes colliding with a collider
  41452. * @param mesh defines the mesh to find the submesh for
  41453. * @param collider defines the collider to evaluate the collision against
  41454. * @returns the list of colliding sub meshes
  41455. */
  41456. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41457. /**
  41458. * Rebuilds the elements related to this component in case of
  41459. * context lost for instance.
  41460. */
  41461. rebuild(): void;
  41462. /**
  41463. * Disposes the component and the associated ressources.
  41464. */
  41465. dispose(): void;
  41466. }
  41467. }
  41468. declare module BABYLON {
  41469. /**
  41470. * Manage the gamepad inputs to control an arc rotate camera.
  41471. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41472. */
  41473. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41474. /**
  41475. * Defines the camera the input is attached to.
  41476. */
  41477. camera: ArcRotateCamera;
  41478. /**
  41479. * Defines the gamepad the input is gathering event from.
  41480. */
  41481. gamepad: Nullable<Gamepad>;
  41482. /**
  41483. * Defines the gamepad rotation sensiblity.
  41484. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41485. */
  41486. gamepadRotationSensibility: number;
  41487. /**
  41488. * Defines the gamepad move sensiblity.
  41489. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41490. */
  41491. gamepadMoveSensibility: number;
  41492. private _onGamepadConnectedObserver;
  41493. private _onGamepadDisconnectedObserver;
  41494. /**
  41495. * Attach the input controls to a specific dom element to get the input from.
  41496. * @param element Defines the element the controls should be listened from
  41497. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41498. */
  41499. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41500. /**
  41501. * Detach the current controls from the specified dom element.
  41502. * @param element Defines the element to stop listening the inputs from
  41503. */
  41504. detachControl(element: Nullable<HTMLElement>): void;
  41505. /**
  41506. * Update the current camera state depending on the inputs that have been used this frame.
  41507. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41508. */
  41509. checkInputs(): void;
  41510. /**
  41511. * Gets the class name of the current intput.
  41512. * @returns the class name
  41513. */
  41514. getClassName(): string;
  41515. /**
  41516. * Get the friendly name associated with the input class.
  41517. * @returns the input friendly name
  41518. */
  41519. getSimpleName(): string;
  41520. }
  41521. }
  41522. declare module BABYLON {
  41523. /**
  41524. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41525. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41526. */
  41527. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41528. /**
  41529. * Defines the camera the input is attached to.
  41530. */
  41531. camera: ArcRotateCamera;
  41532. /**
  41533. * Defines the list of key codes associated with the up action (increase alpha)
  41534. */
  41535. keysUp: number[];
  41536. /**
  41537. * Defines the list of key codes associated with the down action (decrease alpha)
  41538. */
  41539. keysDown: number[];
  41540. /**
  41541. * Defines the list of key codes associated with the left action (increase beta)
  41542. */
  41543. keysLeft: number[];
  41544. /**
  41545. * Defines the list of key codes associated with the right action (decrease beta)
  41546. */
  41547. keysRight: number[];
  41548. /**
  41549. * Defines the list of key codes associated with the reset action.
  41550. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41551. */
  41552. keysReset: number[];
  41553. /**
  41554. * Defines the panning sensibility of the inputs.
  41555. * (How fast is the camera paning)
  41556. */
  41557. panningSensibility: number;
  41558. /**
  41559. * Defines the zooming sensibility of the inputs.
  41560. * (How fast is the camera zooming)
  41561. */
  41562. zoomingSensibility: number;
  41563. /**
  41564. * Defines wether maintaining the alt key down switch the movement mode from
  41565. * orientation to zoom.
  41566. */
  41567. useAltToZoom: boolean;
  41568. /**
  41569. * Rotation speed of the camera
  41570. */
  41571. angularSpeed: number;
  41572. private _keys;
  41573. private _ctrlPressed;
  41574. private _altPressed;
  41575. private _onCanvasBlurObserver;
  41576. private _onKeyboardObserver;
  41577. private _engine;
  41578. private _scene;
  41579. /**
  41580. * Attach the input controls to a specific dom element to get the input from.
  41581. * @param element Defines the element the controls should be listened from
  41582. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41583. */
  41584. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41585. /**
  41586. * Detach the current controls from the specified dom element.
  41587. * @param element Defines the element to stop listening the inputs from
  41588. */
  41589. detachControl(element: Nullable<HTMLElement>): void;
  41590. /**
  41591. * Update the current camera state depending on the inputs that have been used this frame.
  41592. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41593. */
  41594. checkInputs(): void;
  41595. /**
  41596. * Gets the class name of the current intput.
  41597. * @returns the class name
  41598. */
  41599. getClassName(): string;
  41600. /**
  41601. * Get the friendly name associated with the input class.
  41602. * @returns the input friendly name
  41603. */
  41604. getSimpleName(): string;
  41605. }
  41606. }
  41607. declare module BABYLON {
  41608. /**
  41609. * Manage the mouse wheel inputs to control an arc rotate camera.
  41610. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41611. */
  41612. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41613. /**
  41614. * Defines the camera the input is attached to.
  41615. */
  41616. camera: ArcRotateCamera;
  41617. /**
  41618. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41619. */
  41620. wheelPrecision: number;
  41621. /**
  41622. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41623. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41624. */
  41625. wheelDeltaPercentage: number;
  41626. private _wheel;
  41627. private _observer;
  41628. /**
  41629. * Attach the input controls to a specific dom element to get the input from.
  41630. * @param element Defines the element the controls should be listened from
  41631. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41632. */
  41633. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41634. /**
  41635. * Detach the current controls from the specified dom element.
  41636. * @param element Defines the element to stop listening the inputs from
  41637. */
  41638. detachControl(element: Nullable<HTMLElement>): void;
  41639. /**
  41640. * Gets the class name of the current intput.
  41641. * @returns the class name
  41642. */
  41643. getClassName(): string;
  41644. /**
  41645. * Get the friendly name associated with the input class.
  41646. * @returns the input friendly name
  41647. */
  41648. getSimpleName(): string;
  41649. }
  41650. }
  41651. declare module BABYLON {
  41652. /**
  41653. * Manage the pointers inputs to control an arc rotate camera.
  41654. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41655. */
  41656. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  41657. /**
  41658. * Defines the camera the input is attached to.
  41659. */
  41660. camera: ArcRotateCamera;
  41661. /**
  41662. * Defines the buttons associated with the input to handle camera move.
  41663. */
  41664. buttons: number[];
  41665. /**
  41666. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41667. */
  41668. angularSensibilityX: number;
  41669. /**
  41670. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41671. */
  41672. angularSensibilityY: number;
  41673. /**
  41674. * Defines the pointer pinch precision or how fast is the camera zooming.
  41675. */
  41676. pinchPrecision: number;
  41677. /**
  41678. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  41679. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41680. */
  41681. pinchDeltaPercentage: number;
  41682. /**
  41683. * Defines the pointer panning sensibility or how fast is the camera moving.
  41684. */
  41685. panningSensibility: number;
  41686. /**
  41687. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41688. */
  41689. multiTouchPanning: boolean;
  41690. /**
  41691. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  41692. */
  41693. multiTouchPanAndZoom: boolean;
  41694. /**
  41695. * Revers pinch action direction.
  41696. */
  41697. pinchInwards: boolean;
  41698. private _isPanClick;
  41699. private _pointerInput;
  41700. private _observer;
  41701. private _onMouseMove;
  41702. private _onGestureStart;
  41703. private _onGesture;
  41704. private _MSGestureHandler;
  41705. private _onLostFocus;
  41706. private _onContextMenu;
  41707. /**
  41708. * Attach the input controls to a specific dom element to get the input from.
  41709. * @param element Defines the element the controls should be listened from
  41710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41711. */
  41712. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41713. /**
  41714. * Detach the current controls from the specified dom element.
  41715. * @param element Defines the element to stop listening the inputs from
  41716. */
  41717. detachControl(element: Nullable<HTMLElement>): void;
  41718. /**
  41719. * Gets the class name of the current intput.
  41720. * @returns the class name
  41721. */
  41722. getClassName(): string;
  41723. /**
  41724. * Get the friendly name associated with the input class.
  41725. * @returns the input friendly name
  41726. */
  41727. getSimpleName(): string;
  41728. }
  41729. }
  41730. declare module BABYLON {
  41731. /**
  41732. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41733. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41734. */
  41735. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41736. /**
  41737. * Defines the camera the input is attached to.
  41738. */
  41739. camera: ArcRotateCamera;
  41740. /**
  41741. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41742. */
  41743. alphaCorrection: number;
  41744. /**
  41745. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41746. */
  41747. gammaCorrection: number;
  41748. private _alpha;
  41749. private _gamma;
  41750. private _dirty;
  41751. private _deviceOrientationHandler;
  41752. /**
  41753. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41754. */
  41755. constructor();
  41756. /**
  41757. * Attach the input controls to a specific dom element to get the input from.
  41758. * @param element Defines the element the controls should be listened from
  41759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41760. */
  41761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41762. /** @hidden */
  41763. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41764. /**
  41765. * Update the current camera state depending on the inputs that have been used this frame.
  41766. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41767. */
  41768. checkInputs(): void;
  41769. /**
  41770. * Detach the current controls from the specified dom element.
  41771. * @param element Defines the element to stop listening the inputs from
  41772. */
  41773. detachControl(element: Nullable<HTMLElement>): void;
  41774. /**
  41775. * Gets the class name of the current intput.
  41776. * @returns the class name
  41777. */
  41778. getClassName(): string;
  41779. /**
  41780. * Get the friendly name associated with the input class.
  41781. * @returns the input friendly name
  41782. */
  41783. getSimpleName(): string;
  41784. }
  41785. }
  41786. declare module BABYLON {
  41787. /**
  41788. * Listen to keyboard events to control the camera.
  41789. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41790. */
  41791. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41792. /**
  41793. * Defines the camera the input is attached to.
  41794. */
  41795. camera: FlyCamera;
  41796. /**
  41797. * The list of keyboard keys used to control the forward move of the camera.
  41798. */
  41799. keysForward: number[];
  41800. /**
  41801. * The list of keyboard keys used to control the backward move of the camera.
  41802. */
  41803. keysBackward: number[];
  41804. /**
  41805. * The list of keyboard keys used to control the forward move of the camera.
  41806. */
  41807. keysUp: number[];
  41808. /**
  41809. * The list of keyboard keys used to control the backward move of the camera.
  41810. */
  41811. keysDown: number[];
  41812. /**
  41813. * The list of keyboard keys used to control the right strafe move of the camera.
  41814. */
  41815. keysRight: number[];
  41816. /**
  41817. * The list of keyboard keys used to control the left strafe move of the camera.
  41818. */
  41819. keysLeft: number[];
  41820. private _keys;
  41821. private _onCanvasBlurObserver;
  41822. private _onKeyboardObserver;
  41823. private _engine;
  41824. private _scene;
  41825. /**
  41826. * Attach the input controls to a specific dom element to get the input from.
  41827. * @param element Defines the element the controls should be listened from
  41828. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41829. */
  41830. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41831. /**
  41832. * Detach the current controls from the specified dom element.
  41833. * @param element Defines the element to stop listening the inputs from
  41834. */
  41835. detachControl(element: Nullable<HTMLElement>): void;
  41836. /**
  41837. * Gets the class name of the current intput.
  41838. * @returns the class name
  41839. */
  41840. getClassName(): string;
  41841. /** @hidden */
  41842. _onLostFocus(e: FocusEvent): void;
  41843. /**
  41844. * Get the friendly name associated with the input class.
  41845. * @returns the input friendly name
  41846. */
  41847. getSimpleName(): string;
  41848. /**
  41849. * Update the current camera state depending on the inputs that have been used this frame.
  41850. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41851. */
  41852. checkInputs(): void;
  41853. }
  41854. }
  41855. declare module BABYLON {
  41856. /**
  41857. * Listen to mouse events to control the camera.
  41858. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41859. */
  41860. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41861. /**
  41862. * Defines the camera the input is attached to.
  41863. */
  41864. camera: FlyCamera;
  41865. /**
  41866. * Defines if touch is enabled. (Default is true.)
  41867. */
  41868. touchEnabled: boolean;
  41869. /**
  41870. * Defines the buttons associated with the input to handle camera rotation.
  41871. */
  41872. buttons: number[];
  41873. /**
  41874. * Assign buttons for Yaw control.
  41875. */
  41876. buttonsYaw: number[];
  41877. /**
  41878. * Assign buttons for Pitch control.
  41879. */
  41880. buttonsPitch: number[];
  41881. /**
  41882. * Assign buttons for Roll control.
  41883. */
  41884. buttonsRoll: number[];
  41885. /**
  41886. * Detect if any button is being pressed while mouse is moved.
  41887. * -1 = Mouse locked.
  41888. * 0 = Left button.
  41889. * 1 = Middle Button.
  41890. * 2 = Right Button.
  41891. */
  41892. activeButton: number;
  41893. /**
  41894. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41895. * Higher values reduce its sensitivity.
  41896. */
  41897. angularSensibility: number;
  41898. private _mousemoveCallback;
  41899. private _observer;
  41900. private _rollObserver;
  41901. private previousPosition;
  41902. private noPreventDefault;
  41903. private element;
  41904. /**
  41905. * Listen to mouse events to control the camera.
  41906. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41907. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41908. */
  41909. constructor(touchEnabled?: boolean);
  41910. /**
  41911. * Attach the mouse control to the HTML DOM element.
  41912. * @param element Defines the element that listens to the input events.
  41913. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41914. */
  41915. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41916. /**
  41917. * Detach the current controls from the specified dom element.
  41918. * @param element Defines the element to stop listening the inputs from
  41919. */
  41920. detachControl(element: Nullable<HTMLElement>): void;
  41921. /**
  41922. * Gets the class name of the current input.
  41923. * @returns the class name.
  41924. */
  41925. getClassName(): string;
  41926. /**
  41927. * Get the friendly name associated with the input class.
  41928. * @returns the input's friendly name.
  41929. */
  41930. getSimpleName(): string;
  41931. private _pointerInput;
  41932. private _onMouseMove;
  41933. /**
  41934. * Rotate camera by mouse offset.
  41935. */
  41936. private rotateCamera;
  41937. }
  41938. }
  41939. declare module BABYLON {
  41940. /**
  41941. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41942. * Screen rotation is taken into account.
  41943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41944. */
  41945. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41946. private _camera;
  41947. private _screenOrientationAngle;
  41948. private _constantTranform;
  41949. private _screenQuaternion;
  41950. private _alpha;
  41951. private _beta;
  41952. private _gamma;
  41953. /**
  41954. * Instantiates a new input
  41955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41956. */
  41957. constructor();
  41958. /**
  41959. * Define the camera controlled by the input.
  41960. */
  41961. camera: FreeCamera;
  41962. /**
  41963. * Attach the input controls to a specific dom element to get the input from.
  41964. * @param element Defines the element the controls should be listened from
  41965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41966. */
  41967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41968. private _orientationChanged;
  41969. private _deviceOrientation;
  41970. /**
  41971. * Detach the current controls from the specified dom element.
  41972. * @param element Defines the element to stop listening the inputs from
  41973. */
  41974. detachControl(element: Nullable<HTMLElement>): void;
  41975. /**
  41976. * Update the current camera state depending on the inputs that have been used this frame.
  41977. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41978. */
  41979. checkInputs(): void;
  41980. /**
  41981. * Gets the class name of the current intput.
  41982. * @returns the class name
  41983. */
  41984. getClassName(): string;
  41985. /**
  41986. * Get the friendly name associated with the input class.
  41987. * @returns the input friendly name
  41988. */
  41989. getSimpleName(): string;
  41990. }
  41991. }
  41992. declare module BABYLON {
  41993. /**
  41994. * Manage the gamepad inputs to control a free camera.
  41995. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41996. */
  41997. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41998. /**
  41999. * Define the camera the input is attached to.
  42000. */
  42001. camera: FreeCamera;
  42002. /**
  42003. * Define the Gamepad controlling the input
  42004. */
  42005. gamepad: Nullable<Gamepad>;
  42006. /**
  42007. * Defines the gamepad rotation sensiblity.
  42008. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42009. */
  42010. gamepadAngularSensibility: number;
  42011. /**
  42012. * Defines the gamepad move sensiblity.
  42013. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42014. */
  42015. gamepadMoveSensibility: number;
  42016. private _onGamepadConnectedObserver;
  42017. private _onGamepadDisconnectedObserver;
  42018. private _cameraTransform;
  42019. private _deltaTransform;
  42020. private _vector3;
  42021. private _vector2;
  42022. /**
  42023. * Attach the input controls to a specific dom element to get the input from.
  42024. * @param element Defines the element the controls should be listened from
  42025. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42026. */
  42027. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42028. /**
  42029. * Detach the current controls from the specified dom element.
  42030. * @param element Defines the element to stop listening the inputs from
  42031. */
  42032. detachControl(element: Nullable<HTMLElement>): void;
  42033. /**
  42034. * Update the current camera state depending on the inputs that have been used this frame.
  42035. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42036. */
  42037. checkInputs(): void;
  42038. /**
  42039. * Gets the class name of the current intput.
  42040. * @returns the class name
  42041. */
  42042. getClassName(): string;
  42043. /**
  42044. * Get the friendly name associated with the input class.
  42045. * @returns the input friendly name
  42046. */
  42047. getSimpleName(): string;
  42048. }
  42049. }
  42050. declare module BABYLON {
  42051. /**
  42052. * Manage the keyboard inputs to control the movement of a free camera.
  42053. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42054. */
  42055. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  42056. /**
  42057. * Defines the camera the input is attached to.
  42058. */
  42059. camera: FreeCamera;
  42060. /**
  42061. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  42062. */
  42063. keysUp: number[];
  42064. /**
  42065. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  42066. */
  42067. keysDown: number[];
  42068. /**
  42069. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  42070. */
  42071. keysLeft: number[];
  42072. /**
  42073. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  42074. */
  42075. keysRight: number[];
  42076. private _keys;
  42077. private _onCanvasBlurObserver;
  42078. private _onKeyboardObserver;
  42079. private _engine;
  42080. private _scene;
  42081. /**
  42082. * Attach the input controls to a specific dom element to get the input from.
  42083. * @param element Defines the element the controls should be listened from
  42084. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42085. */
  42086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42087. /**
  42088. * Detach the current controls from the specified dom element.
  42089. * @param element Defines the element to stop listening the inputs from
  42090. */
  42091. detachControl(element: Nullable<HTMLElement>): void;
  42092. /**
  42093. * Update the current camera state depending on the inputs that have been used this frame.
  42094. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42095. */
  42096. checkInputs(): void;
  42097. /**
  42098. * Gets the class name of the current intput.
  42099. * @returns the class name
  42100. */
  42101. getClassName(): string;
  42102. /** @hidden */
  42103. _onLostFocus(e: FocusEvent): void;
  42104. /**
  42105. * Get the friendly name associated with the input class.
  42106. * @returns the input friendly name
  42107. */
  42108. getSimpleName(): string;
  42109. }
  42110. }
  42111. declare module BABYLON {
  42112. /**
  42113. * Manage the mouse inputs to control the movement of a free camera.
  42114. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42115. */
  42116. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  42117. /**
  42118. * Define if touch is enabled in the mouse input
  42119. */
  42120. touchEnabled: boolean;
  42121. /**
  42122. * Defines the camera the input is attached to.
  42123. */
  42124. camera: FreeCamera;
  42125. /**
  42126. * Defines the buttons associated with the input to handle camera move.
  42127. */
  42128. buttons: number[];
  42129. /**
  42130. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  42131. */
  42132. angularSensibility: number;
  42133. private _pointerInput;
  42134. private _onMouseMove;
  42135. private _observer;
  42136. private previousPosition;
  42137. /**
  42138. * Manage the mouse inputs to control the movement of a free camera.
  42139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42140. * @param touchEnabled Defines if touch is enabled or not
  42141. */
  42142. constructor(
  42143. /**
  42144. * Define if touch is enabled in the mouse input
  42145. */
  42146. touchEnabled?: boolean);
  42147. /**
  42148. * Attach the input controls to a specific dom element to get the input from.
  42149. * @param element Defines the element the controls should be listened from
  42150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42151. */
  42152. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42153. /**
  42154. * Detach the current controls from the specified dom element.
  42155. * @param element Defines the element to stop listening the inputs from
  42156. */
  42157. detachControl(element: Nullable<HTMLElement>): void;
  42158. /**
  42159. * Gets the class name of the current intput.
  42160. * @returns the class name
  42161. */
  42162. getClassName(): string;
  42163. /**
  42164. * Get the friendly name associated with the input class.
  42165. * @returns the input friendly name
  42166. */
  42167. getSimpleName(): string;
  42168. }
  42169. }
  42170. declare module BABYLON {
  42171. /**
  42172. * Manage the touch inputs to control the movement of a free camera.
  42173. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42174. */
  42175. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  42176. /**
  42177. * Defines the camera the input is attached to.
  42178. */
  42179. camera: FreeCamera;
  42180. /**
  42181. * Defines the touch sensibility for rotation.
  42182. * The higher the faster.
  42183. */
  42184. touchAngularSensibility: number;
  42185. /**
  42186. * Defines the touch sensibility for move.
  42187. * The higher the faster.
  42188. */
  42189. touchMoveSensibility: number;
  42190. private _offsetX;
  42191. private _offsetY;
  42192. private _pointerPressed;
  42193. private _pointerInput;
  42194. private _observer;
  42195. private _onLostFocus;
  42196. /**
  42197. * Attach the input controls to a specific dom element to get the input from.
  42198. * @param element Defines the element the controls should be listened from
  42199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42200. */
  42201. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42202. /**
  42203. * Detach the current controls from the specified dom element.
  42204. * @param element Defines the element to stop listening the inputs from
  42205. */
  42206. detachControl(element: Nullable<HTMLElement>): void;
  42207. /**
  42208. * Update the current camera state depending on the inputs that have been used this frame.
  42209. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42210. */
  42211. checkInputs(): void;
  42212. /**
  42213. * Gets the class name of the current intput.
  42214. * @returns the class name
  42215. */
  42216. getClassName(): string;
  42217. /**
  42218. * Get the friendly name associated with the input class.
  42219. * @returns the input friendly name
  42220. */
  42221. getSimpleName(): string;
  42222. }
  42223. }
  42224. declare module BABYLON {
  42225. /**
  42226. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42227. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42228. */
  42229. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42230. /**
  42231. * Defines the camera the input is attached to.
  42232. */
  42233. camera: FreeCamera;
  42234. private _leftjoystick;
  42235. private _rightjoystick;
  42236. /**
  42237. * Gets the left stick of the virtual joystick.
  42238. * @returns The virtual Joystick
  42239. */
  42240. getLeftJoystick(): VirtualJoystick;
  42241. /**
  42242. * Gets the right stick of the virtual joystick.
  42243. * @returns The virtual Joystick
  42244. */
  42245. getRightJoystick(): VirtualJoystick;
  42246. /**
  42247. * Update the current camera state depending on the inputs that have been used this frame.
  42248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42249. */
  42250. checkInputs(): void;
  42251. /**
  42252. * Attach the input controls to a specific dom element to get the input from.
  42253. * @param element Defines the element the controls should be listened from
  42254. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42255. */
  42256. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42257. /**
  42258. * Detach the current controls from the specified dom element.
  42259. * @param element Defines the element to stop listening the inputs from
  42260. */
  42261. detachControl(element: Nullable<HTMLElement>): void;
  42262. /**
  42263. * Gets the class name of the current intput.
  42264. * @returns the class name
  42265. */
  42266. getClassName(): string;
  42267. /**
  42268. * Get the friendly name associated with the input class.
  42269. * @returns the input friendly name
  42270. */
  42271. getSimpleName(): string;
  42272. }
  42273. }
  42274. declare module BABYLON {
  42275. /**
  42276. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42277. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42278. */
  42279. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42280. /**
  42281. * Creates a new AnaglyphArcRotateCamera
  42282. * @param name defines camera name
  42283. * @param alpha defines alpha angle (in radians)
  42284. * @param beta defines beta angle (in radians)
  42285. * @param radius defines radius
  42286. * @param target defines camera target
  42287. * @param interaxialDistance defines distance between each color axis
  42288. * @param scene defines the hosting scene
  42289. */
  42290. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42291. /**
  42292. * Gets camera class name
  42293. * @returns AnaglyphArcRotateCamera
  42294. */
  42295. getClassName(): string;
  42296. }
  42297. }
  42298. declare module BABYLON {
  42299. /**
  42300. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42301. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42302. */
  42303. class AnaglyphFreeCamera extends FreeCamera {
  42304. /**
  42305. * Creates a new AnaglyphFreeCamera
  42306. * @param name defines camera name
  42307. * @param position defines initial position
  42308. * @param interaxialDistance defines distance between each color axis
  42309. * @param scene defines the hosting scene
  42310. */
  42311. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42312. /**
  42313. * Gets camera class name
  42314. * @returns AnaglyphFreeCamera
  42315. */
  42316. getClassName(): string;
  42317. }
  42318. }
  42319. declare module BABYLON {
  42320. /**
  42321. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42322. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42323. */
  42324. class AnaglyphGamepadCamera extends GamepadCamera {
  42325. /**
  42326. * Creates a new AnaglyphGamepadCamera
  42327. * @param name defines camera name
  42328. * @param position defines initial position
  42329. * @param interaxialDistance defines distance between each color axis
  42330. * @param scene defines the hosting scene
  42331. */
  42332. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42333. /**
  42334. * Gets camera class name
  42335. * @returns AnaglyphGamepadCamera
  42336. */
  42337. getClassName(): string;
  42338. }
  42339. }
  42340. declare module BABYLON {
  42341. /**
  42342. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42343. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42344. */
  42345. class AnaglyphUniversalCamera extends UniversalCamera {
  42346. /**
  42347. * Creates a new AnaglyphUniversalCamera
  42348. * @param name defines camera name
  42349. * @param position defines initial position
  42350. * @param interaxialDistance defines distance between each color axis
  42351. * @param scene defines the hosting scene
  42352. */
  42353. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42354. /**
  42355. * Gets camera class name
  42356. * @returns AnaglyphUniversalCamera
  42357. */
  42358. getClassName(): string;
  42359. }
  42360. }
  42361. declare module BABYLON {
  42362. /**
  42363. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42364. * @see http://doc.babylonjs.com/features/cameras
  42365. */
  42366. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42367. /**
  42368. * Creates a new StereoscopicArcRotateCamera
  42369. * @param name defines camera name
  42370. * @param alpha defines alpha angle (in radians)
  42371. * @param beta defines beta angle (in radians)
  42372. * @param radius defines radius
  42373. * @param target defines camera target
  42374. * @param interaxialDistance defines distance between each color axis
  42375. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42376. * @param scene defines the hosting scene
  42377. */
  42378. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42379. /**
  42380. * Gets camera class name
  42381. * @returns StereoscopicArcRotateCamera
  42382. */
  42383. getClassName(): string;
  42384. }
  42385. }
  42386. declare module BABYLON {
  42387. /**
  42388. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42389. * @see http://doc.babylonjs.com/features/cameras
  42390. */
  42391. class StereoscopicFreeCamera extends FreeCamera {
  42392. /**
  42393. * Creates a new StereoscopicFreeCamera
  42394. * @param name defines camera name
  42395. * @param position defines initial position
  42396. * @param interaxialDistance defines distance between each color axis
  42397. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42398. * @param scene defines the hosting scene
  42399. */
  42400. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42401. /**
  42402. * Gets camera class name
  42403. * @returns StereoscopicFreeCamera
  42404. */
  42405. getClassName(): string;
  42406. }
  42407. }
  42408. declare module BABYLON {
  42409. /**
  42410. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42411. * @see http://doc.babylonjs.com/features/cameras
  42412. */
  42413. class StereoscopicGamepadCamera extends GamepadCamera {
  42414. /**
  42415. * Creates a new StereoscopicGamepadCamera
  42416. * @param name defines camera name
  42417. * @param position defines initial position
  42418. * @param interaxialDistance defines distance between each color axis
  42419. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42420. * @param scene defines the hosting scene
  42421. */
  42422. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42423. /**
  42424. * Gets camera class name
  42425. * @returns StereoscopicGamepadCamera
  42426. */
  42427. getClassName(): string;
  42428. }
  42429. }
  42430. declare module BABYLON {
  42431. /**
  42432. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42433. * @see http://doc.babylonjs.com/features/cameras
  42434. */
  42435. class StereoscopicUniversalCamera extends UniversalCamera {
  42436. /**
  42437. * Creates a new StereoscopicUniversalCamera
  42438. * @param name defines camera name
  42439. * @param position defines initial position
  42440. * @param interaxialDistance defines distance between each color axis
  42441. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42442. * @param scene defines the hosting scene
  42443. */
  42444. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42445. /**
  42446. * Gets camera class name
  42447. * @returns StereoscopicUniversalCamera
  42448. */
  42449. getClassName(): string;
  42450. }
  42451. }
  42452. declare module BABYLON {
  42453. /**
  42454. * This represents all the required metrics to create a VR camera.
  42455. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42456. */
  42457. class VRCameraMetrics {
  42458. /**
  42459. * Define the horizontal resolution off the screen.
  42460. */
  42461. hResolution: number;
  42462. /**
  42463. * Define the vertical resolution off the screen.
  42464. */
  42465. vResolution: number;
  42466. /**
  42467. * Define the horizontal screen size.
  42468. */
  42469. hScreenSize: number;
  42470. /**
  42471. * Define the vertical screen size.
  42472. */
  42473. vScreenSize: number;
  42474. /**
  42475. * Define the vertical screen center position.
  42476. */
  42477. vScreenCenter: number;
  42478. /**
  42479. * Define the distance of the eyes to the screen.
  42480. */
  42481. eyeToScreenDistance: number;
  42482. /**
  42483. * Define the distance between both lenses
  42484. */
  42485. lensSeparationDistance: number;
  42486. /**
  42487. * Define the distance between both viewer's eyes.
  42488. */
  42489. interpupillaryDistance: number;
  42490. /**
  42491. * Define the distortion factor of the VR postprocess.
  42492. * Please, touch with care.
  42493. */
  42494. distortionK: number[];
  42495. /**
  42496. * Define the chromatic aberration correction factors for the VR post process.
  42497. */
  42498. chromaAbCorrection: number[];
  42499. /**
  42500. * Define the scale factor of the post process.
  42501. * The smaller the better but the slower.
  42502. */
  42503. postProcessScaleFactor: number;
  42504. /**
  42505. * Define an offset for the lens center.
  42506. */
  42507. lensCenterOffset: number;
  42508. /**
  42509. * Define if the current vr camera should compensate the distortion of the lense or not.
  42510. */
  42511. compensateDistortion: boolean;
  42512. /**
  42513. * Gets the rendering aspect ratio based on the provided resolutions.
  42514. */
  42515. readonly aspectRatio: number;
  42516. /**
  42517. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42518. */
  42519. readonly aspectRatioFov: number;
  42520. /**
  42521. * @hidden
  42522. */
  42523. readonly leftHMatrix: Matrix;
  42524. /**
  42525. * @hidden
  42526. */
  42527. readonly rightHMatrix: Matrix;
  42528. /**
  42529. * @hidden
  42530. */
  42531. readonly leftPreViewMatrix: Matrix;
  42532. /**
  42533. * @hidden
  42534. */
  42535. readonly rightPreViewMatrix: Matrix;
  42536. /**
  42537. * Get the default VRMetrics based on the most generic setup.
  42538. * @returns the default vr metrics
  42539. */
  42540. static GetDefault(): VRCameraMetrics;
  42541. }
  42542. }
  42543. declare module BABYLON {
  42544. /**
  42545. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42546. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42547. */
  42548. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42549. /**
  42550. * Creates a new VRDeviceOrientationArcRotateCamera
  42551. * @param name defines camera name
  42552. * @param alpha defines the camera rotation along the logitudinal axis
  42553. * @param beta defines the camera rotation along the latitudinal axis
  42554. * @param radius defines the camera distance from its target
  42555. * @param target defines the camera target
  42556. * @param scene defines the scene the camera belongs to
  42557. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42558. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42559. */
  42560. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42561. /**
  42562. * Gets camera class name
  42563. * @returns VRDeviceOrientationArcRotateCamera
  42564. */
  42565. getClassName(): string;
  42566. }
  42567. }
  42568. declare module BABYLON {
  42569. /**
  42570. * Camera used to simulate VR rendering (based on FreeCamera)
  42571. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42572. */
  42573. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42574. /**
  42575. * Creates a new VRDeviceOrientationFreeCamera
  42576. * @param name defines camera name
  42577. * @param position defines the start position of the camera
  42578. * @param scene defines the scene the camera belongs to
  42579. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42580. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42581. */
  42582. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42583. /**
  42584. * Gets camera class name
  42585. * @returns VRDeviceOrientationFreeCamera
  42586. */
  42587. getClassName(): string;
  42588. }
  42589. }
  42590. declare module BABYLON {
  42591. /**
  42592. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42593. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42594. */
  42595. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42596. /**
  42597. * Creates a new VRDeviceOrientationGamepadCamera
  42598. * @param name defines camera name
  42599. * @param position defines the start position of the camera
  42600. * @param scene defines the scene the camera belongs to
  42601. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42602. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42603. */
  42604. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42605. /**
  42606. * Gets camera class name
  42607. * @returns VRDeviceOrientationGamepadCamera
  42608. */
  42609. getClassName(): string;
  42610. }
  42611. }
  42612. declare module BABYLON {
  42613. /**
  42614. * Options to modify the vr teleportation behavior.
  42615. */
  42616. interface VRTeleportationOptions {
  42617. /**
  42618. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42619. */
  42620. floorMeshName?: string;
  42621. /**
  42622. * A list of meshes to be used as the teleportation floor. (default: empty)
  42623. */
  42624. floorMeshes?: Mesh[];
  42625. }
  42626. /**
  42627. * Options to modify the vr experience helper's behavior.
  42628. */
  42629. interface VRExperienceHelperOptions extends WebVROptions {
  42630. /**
  42631. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42632. */
  42633. createDeviceOrientationCamera?: boolean;
  42634. /**
  42635. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42636. */
  42637. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42638. /**
  42639. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42640. */
  42641. laserToggle?: boolean;
  42642. /**
  42643. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42644. */
  42645. floorMeshes?: Mesh[];
  42646. }
  42647. /**
  42648. * Helps to quickly add VR support to an existing scene.
  42649. * See http://doc.babylonjs.com/how_to/webvr_helper
  42650. */
  42651. class VRExperienceHelper {
  42652. /** Options to modify the vr experience helper's behavior. */
  42653. webVROptions: VRExperienceHelperOptions;
  42654. private _scene;
  42655. private _position;
  42656. private _btnVR;
  42657. private _btnVRDisplayed;
  42658. private _webVRsupported;
  42659. private _webVRready;
  42660. private _webVRrequesting;
  42661. private _webVRpresenting;
  42662. private _hasEnteredVR;
  42663. private _fullscreenVRpresenting;
  42664. private _canvas;
  42665. private _webVRCamera;
  42666. private _vrDeviceOrientationCamera;
  42667. private _deviceOrientationCamera;
  42668. private _existingCamera;
  42669. private _onKeyDown;
  42670. private _onVrDisplayPresentChange;
  42671. private _onVRDisplayChanged;
  42672. private _onVRRequestPresentStart;
  42673. private _onVRRequestPresentComplete;
  42674. /**
  42675. * Observable raised when entering VR.
  42676. */
  42677. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42678. /**
  42679. * Observable raised when exiting VR.
  42680. */
  42681. onExitingVRObservable: Observable<VRExperienceHelper>;
  42682. /**
  42683. * Observable raised when controller mesh is loaded.
  42684. */
  42685. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42686. /** Return this.onEnteringVRObservable
  42687. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42688. */
  42689. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42690. /** Return this.onExitingVRObservable
  42691. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42692. */
  42693. readonly onExitingVR: Observable<VRExperienceHelper>;
  42694. /** Return this.onControllerMeshLoadedObservable
  42695. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42696. */
  42697. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42698. private _rayLength;
  42699. private _useCustomVRButton;
  42700. private _teleportationRequested;
  42701. private _teleportActive;
  42702. private _floorMeshName;
  42703. private _floorMeshesCollection;
  42704. private _rotationAllowed;
  42705. private _teleportBackwardsVector;
  42706. private _teleportationTarget;
  42707. private _isDefaultTeleportationTarget;
  42708. private _postProcessMove;
  42709. private _teleportationFillColor;
  42710. private _teleportationBorderColor;
  42711. private _rotationAngle;
  42712. private _haloCenter;
  42713. private _cameraGazer;
  42714. private _padSensibilityUp;
  42715. private _padSensibilityDown;
  42716. private _leftController;
  42717. private _rightController;
  42718. /**
  42719. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42720. */
  42721. onNewMeshSelected: Observable<AbstractMesh>;
  42722. /**
  42723. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42724. */
  42725. onNewMeshPicked: Observable<PickingInfo>;
  42726. private _circleEase;
  42727. /**
  42728. * Observable raised before camera teleportation
  42729. */
  42730. onBeforeCameraTeleport: Observable<Vector3>;
  42731. /**
  42732. * Observable raised after camera teleportation
  42733. */
  42734. onAfterCameraTeleport: Observable<Vector3>;
  42735. /**
  42736. * Observable raised when current selected mesh gets unselected
  42737. */
  42738. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42739. private _raySelectionPredicate;
  42740. /**
  42741. * To be optionaly changed by user to define custom ray selection
  42742. */
  42743. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42744. /**
  42745. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42746. */
  42747. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42748. /**
  42749. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42750. */
  42751. teleportationEnabled: boolean;
  42752. private _defaultHeight;
  42753. private _teleportationInitialized;
  42754. private _interactionsEnabled;
  42755. private _interactionsRequested;
  42756. private _displayGaze;
  42757. private _displayLaserPointer;
  42758. /**
  42759. * The mesh used to display where the user is going to teleport.
  42760. */
  42761. /**
  42762. * Sets the mesh to be used to display where the user is going to teleport.
  42763. */
  42764. teleportationTarget: Mesh;
  42765. /**
  42766. * 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
  42767. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42768. * See http://doc.babylonjs.com/resources/baking_transformations
  42769. */
  42770. gazeTrackerMesh: Mesh;
  42771. /**
  42772. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42773. */
  42774. updateGazeTrackerScale: boolean;
  42775. /**
  42776. * The gaze tracking mesh corresponding to the left controller
  42777. */
  42778. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42779. /**
  42780. * The gaze tracking mesh corresponding to the right controller
  42781. */
  42782. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42783. /**
  42784. * If the ray of the gaze should be displayed.
  42785. */
  42786. /**
  42787. * Sets if the ray of the gaze should be displayed.
  42788. */
  42789. displayGaze: boolean;
  42790. /**
  42791. * If the ray of the LaserPointer should be displayed.
  42792. */
  42793. /**
  42794. * Sets if the ray of the LaserPointer should be displayed.
  42795. */
  42796. displayLaserPointer: boolean;
  42797. /**
  42798. * The deviceOrientationCamera used as the camera when not in VR.
  42799. */
  42800. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42801. /**
  42802. * Based on the current WebVR support, returns the current VR camera used.
  42803. */
  42804. readonly currentVRCamera: Nullable<Camera>;
  42805. /**
  42806. * The webVRCamera which is used when in VR.
  42807. */
  42808. readonly webVRCamera: WebVRFreeCamera;
  42809. /**
  42810. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42811. */
  42812. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42813. private readonly _teleportationRequestInitiated;
  42814. /**
  42815. * Instantiates a VRExperienceHelper.
  42816. * Helps to quickly add VR support to an existing scene.
  42817. * @param scene The scene the VRExperienceHelper belongs to.
  42818. * @param webVROptions Options to modify the vr experience helper's behavior.
  42819. */
  42820. constructor(scene: Scene,
  42821. /** Options to modify the vr experience helper's behavior. */
  42822. webVROptions?: VRExperienceHelperOptions);
  42823. private _onDefaultMeshLoaded;
  42824. private _onResize;
  42825. private _onFullscreenChange;
  42826. /**
  42827. * Gets a value indicating if we are currently in VR mode.
  42828. */
  42829. readonly isInVRMode: boolean;
  42830. private onVrDisplayPresentChange;
  42831. private onVRDisplayChanged;
  42832. private moveButtonToBottomRight;
  42833. private displayVRButton;
  42834. private updateButtonVisibility;
  42835. private _cachedAngularSensibility;
  42836. /**
  42837. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42838. * Otherwise, will use the fullscreen API.
  42839. */
  42840. enterVR(): void;
  42841. /**
  42842. * Attempt to exit VR, or fullscreen.
  42843. */
  42844. exitVR(): void;
  42845. /**
  42846. * The position of the vr experience helper.
  42847. */
  42848. /**
  42849. * Sets the position of the vr experience helper.
  42850. */
  42851. position: Vector3;
  42852. /**
  42853. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42854. */
  42855. enableInteractions(): void;
  42856. private readonly _noControllerIsActive;
  42857. private beforeRender;
  42858. private _isTeleportationFloor;
  42859. /**
  42860. * Adds a floor mesh to be used for teleportation.
  42861. * @param floorMesh the mesh to be used for teleportation.
  42862. */
  42863. addFloorMesh(floorMesh: Mesh): void;
  42864. /**
  42865. * Removes a floor mesh from being used for teleportation.
  42866. * @param floorMesh the mesh to be removed.
  42867. */
  42868. removeFloorMesh(floorMesh: Mesh): void;
  42869. /**
  42870. * Enables interactions and teleportation using the VR controllers and gaze.
  42871. * @param vrTeleportationOptions options to modify teleportation behavior.
  42872. */
  42873. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42874. private _onNewGamepadConnected;
  42875. private _tryEnableInteractionOnController;
  42876. private _onNewGamepadDisconnected;
  42877. private _enableInteractionOnController;
  42878. private _checkTeleportWithRay;
  42879. private _checkRotate;
  42880. private _checkTeleportBackwards;
  42881. private _enableTeleportationOnController;
  42882. private _createTeleportationCircles;
  42883. private _displayTeleportationTarget;
  42884. private _hideTeleportationTarget;
  42885. private _rotateCamera;
  42886. private _moveTeleportationSelectorTo;
  42887. private _workingVector;
  42888. private _workingQuaternion;
  42889. private _workingMatrix;
  42890. /**
  42891. * Teleports the users feet to the desired location
  42892. * @param location The location where the user's feet should be placed
  42893. */
  42894. teleportCamera(location: Vector3): void;
  42895. private _convertNormalToDirectionOfRay;
  42896. private _castRayAndSelectObject;
  42897. private _notifySelectedMeshUnselected;
  42898. /**
  42899. * Sets the color of the laser ray from the vr controllers.
  42900. * @param color new color for the ray.
  42901. */
  42902. changeLaserColor(color: Color3): void;
  42903. /**
  42904. * Sets the color of the ray from the vr headsets gaze.
  42905. * @param color new color for the ray.
  42906. */
  42907. changeGazeColor(color: Color3): void;
  42908. /**
  42909. * Exits VR and disposes of the vr experience helper
  42910. */
  42911. dispose(): void;
  42912. /**
  42913. * Gets the name of the VRExperienceHelper class
  42914. * @returns "VRExperienceHelper"
  42915. */
  42916. getClassName(): string;
  42917. }
  42918. }
  42919. declare module BABYLON {
  42920. /**
  42921. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  42922. * IMPORTANT!! The data is right-hand data.
  42923. * @export
  42924. * @interface DevicePose
  42925. */
  42926. interface DevicePose {
  42927. /**
  42928. * The position of the device, values in array are [x,y,z].
  42929. */
  42930. readonly position: Nullable<Float32Array>;
  42931. /**
  42932. * The linearVelocity of the device, values in array are [x,y,z].
  42933. */
  42934. readonly linearVelocity: Nullable<Float32Array>;
  42935. /**
  42936. * The linearAcceleration of the device, values in array are [x,y,z].
  42937. */
  42938. readonly linearAcceleration: Nullable<Float32Array>;
  42939. /**
  42940. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  42941. */
  42942. readonly orientation: Nullable<Float32Array>;
  42943. /**
  42944. * The angularVelocity of the device, values in array are [x,y,z].
  42945. */
  42946. readonly angularVelocity: Nullable<Float32Array>;
  42947. /**
  42948. * The angularAcceleration of the device, values in array are [x,y,z].
  42949. */
  42950. readonly angularAcceleration: Nullable<Float32Array>;
  42951. }
  42952. /**
  42953. * Interface representing a pose controlled object in Babylon.
  42954. * A pose controlled object has both regular pose values as well as pose values
  42955. * from an external device such as a VR head mounted display
  42956. */
  42957. interface PoseControlled {
  42958. /**
  42959. * The position of the object in babylon space.
  42960. */
  42961. position: Vector3;
  42962. /**
  42963. * The rotation quaternion of the object in babylon space.
  42964. */
  42965. rotationQuaternion: Quaternion;
  42966. /**
  42967. * The position of the device in babylon space.
  42968. */
  42969. devicePosition?: Vector3;
  42970. /**
  42971. * The rotation quaternion of the device in babylon space.
  42972. */
  42973. deviceRotationQuaternion: Quaternion;
  42974. /**
  42975. * The raw pose coming from the device.
  42976. */
  42977. rawPose: Nullable<DevicePose>;
  42978. /**
  42979. * The scale of the device to be used when translating from device space to babylon space.
  42980. */
  42981. deviceScaleFactor: number;
  42982. /**
  42983. * Updates the poseControlled values based on the input device pose.
  42984. * @param poseData the pose data to update the object with
  42985. */
  42986. updateFromDevice(poseData: DevicePose): void;
  42987. }
  42988. /**
  42989. * Set of options to customize the webVRCamera
  42990. */
  42991. interface WebVROptions {
  42992. /**
  42993. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  42994. */
  42995. trackPosition?: boolean;
  42996. /**
  42997. * Sets the scale of the vrDevice in babylon space. (default: 1)
  42998. */
  42999. positionScale?: number;
  43000. /**
  43001. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  43002. */
  43003. displayName?: string;
  43004. /**
  43005. * Should the native controller meshes be initialized. (default: true)
  43006. */
  43007. controllerMeshes?: boolean;
  43008. /**
  43009. * Creating a default HemiLight only on controllers. (default: true)
  43010. */
  43011. defaultLightingOnControllers?: boolean;
  43012. /**
  43013. * If you don't want to use the default VR button of the helper. (default: false)
  43014. */
  43015. useCustomVRButton?: boolean;
  43016. /**
  43017. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  43018. */
  43019. customVRButton?: HTMLButtonElement;
  43020. /**
  43021. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  43022. */
  43023. rayLength?: number;
  43024. /**
  43025. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  43026. */
  43027. defaultHeight?: number;
  43028. }
  43029. /**
  43030. * This represents a WebVR camera.
  43031. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  43032. * @example http://doc.babylonjs.com/how_to/webvr_camera
  43033. */
  43034. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  43035. private webVROptions;
  43036. /**
  43037. * @hidden
  43038. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  43039. */
  43040. _vrDevice: any;
  43041. /**
  43042. * The rawPose of the vrDevice.
  43043. */
  43044. rawPose: Nullable<DevicePose>;
  43045. private _onVREnabled;
  43046. private _specsVersion;
  43047. private _attached;
  43048. private _frameData;
  43049. protected _descendants: Array<Node>;
  43050. private _deviceRoomPosition;
  43051. /** @hidden */
  43052. _deviceRoomRotationQuaternion: Quaternion;
  43053. private _standingMatrix;
  43054. /**
  43055. * Represents device position in babylon space.
  43056. */
  43057. devicePosition: Vector3;
  43058. /**
  43059. * Represents device rotation in babylon space.
  43060. */
  43061. deviceRotationQuaternion: Quaternion;
  43062. /**
  43063. * The scale of the device to be used when translating from device space to babylon space.
  43064. */
  43065. deviceScaleFactor: number;
  43066. private _deviceToWorld;
  43067. private _worldToDevice;
  43068. /**
  43069. * References to the webVR controllers for the vrDevice.
  43070. */
  43071. controllers: Array<WebVRController>;
  43072. /**
  43073. * Emits an event when a controller is attached.
  43074. */
  43075. onControllersAttachedObservable: Observable<WebVRController[]>;
  43076. /**
  43077. * Emits an event when a controller's mesh has been loaded;
  43078. */
  43079. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43080. /**
  43081. * Emits an event when the HMD's pose has been updated.
  43082. */
  43083. onPoseUpdatedFromDeviceObservable: Observable<any>;
  43084. private _poseSet;
  43085. /**
  43086. * If the rig cameras be used as parent instead of this camera.
  43087. */
  43088. rigParenting: boolean;
  43089. private _lightOnControllers;
  43090. private _defaultHeight?;
  43091. /**
  43092. * Instantiates a WebVRFreeCamera.
  43093. * @param name The name of the WebVRFreeCamera
  43094. * @param position The starting anchor position for the camera
  43095. * @param scene The scene the camera belongs to
  43096. * @param webVROptions a set of customizable options for the webVRCamera
  43097. */
  43098. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  43099. /**
  43100. * Gets the device distance from the ground in meters.
  43101. * @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.
  43102. */
  43103. deviceDistanceToRoomGround(): number;
  43104. /**
  43105. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  43106. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  43107. */
  43108. useStandingMatrix(callback?: (bool: boolean) => void): void;
  43109. /**
  43110. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  43111. * @returns A promise with a boolean set to if the standing matrix is supported.
  43112. */
  43113. useStandingMatrixAsync(): Promise<boolean>;
  43114. /**
  43115. * Disposes the camera
  43116. */
  43117. dispose(): void;
  43118. /**
  43119. * Gets a vrController by name.
  43120. * @param name The name of the controller to retreive
  43121. * @returns the controller matching the name specified or null if not found
  43122. */
  43123. getControllerByName(name: string): Nullable<WebVRController>;
  43124. private _leftController;
  43125. /**
  43126. * The controller corrisponding to the users left hand.
  43127. */
  43128. readonly leftController: Nullable<WebVRController>;
  43129. private _rightController;
  43130. /**
  43131. * The controller corrisponding to the users right hand.
  43132. */
  43133. readonly rightController: Nullable<WebVRController>;
  43134. /**
  43135. * Casts a ray forward from the vrCamera's gaze.
  43136. * @param length Length of the ray (default: 100)
  43137. * @returns the ray corrisponding to the gaze
  43138. */
  43139. getForwardRay(length?: number): Ray;
  43140. /**
  43141. * @hidden
  43142. * Updates the camera based on device's frame data
  43143. */
  43144. _checkInputs(): void;
  43145. /**
  43146. * Updates the poseControlled values based on the input device pose.
  43147. * @param poseData Pose coming from the device
  43148. */
  43149. updateFromDevice(poseData: DevicePose): void;
  43150. private _htmlElementAttached;
  43151. private _detachIfAttached;
  43152. /**
  43153. * WebVR's attach control will start broadcasting frames to the device.
  43154. * Note that in certain browsers (chrome for example) this function must be called
  43155. * within a user-interaction callback. Example:
  43156. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  43157. *
  43158. * @param element html element to attach the vrDevice to
  43159. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  43160. */
  43161. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43162. /**
  43163. * Detaches the camera from the html element and disables VR
  43164. *
  43165. * @param element html element to detach from
  43166. */
  43167. detachControl(element: HTMLElement): void;
  43168. /**
  43169. * @returns the name of this class
  43170. */
  43171. getClassName(): string;
  43172. /**
  43173. * Calls resetPose on the vrDisplay
  43174. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  43175. */
  43176. resetToCurrentRotation(): void;
  43177. /**
  43178. * @hidden
  43179. * Updates the rig cameras (left and right eye)
  43180. */
  43181. _updateRigCameras(): void;
  43182. private _workingVector;
  43183. private _oneVector;
  43184. private _workingMatrix;
  43185. private updateCacheCalled;
  43186. private _correctPositionIfNotTrackPosition;
  43187. /**
  43188. * @hidden
  43189. * Updates the cached values of the camera
  43190. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  43191. */
  43192. _updateCache(ignoreParentClass?: boolean): void;
  43193. /**
  43194. * @hidden
  43195. * Get current device position in babylon world
  43196. */
  43197. _computeDevicePosition(): void;
  43198. /**
  43199. * Updates the current device position and rotation in the babylon world
  43200. */
  43201. update(): void;
  43202. /**
  43203. * @hidden
  43204. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  43205. * @returns an identity matrix
  43206. */
  43207. _getViewMatrix(): Matrix;
  43208. private _tmpMatrix;
  43209. /**
  43210. * This function is called by the two RIG cameras.
  43211. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  43212. */
  43213. protected _getWebVRViewMatrix(): Matrix;
  43214. protected _getWebVRProjectionMatrix(): Matrix;
  43215. private _onGamepadConnectedObserver;
  43216. private _onGamepadDisconnectedObserver;
  43217. private _updateCacheWhenTrackingDisabledObserver;
  43218. /**
  43219. * Initializes the controllers and their meshes
  43220. */
  43221. initControllers(): void;
  43222. }
  43223. }
  43224. declare module BABYLON {
  43225. /**
  43226. * WebXR Camera which holds the views for the xrSession
  43227. * @see https://doc.babylonjs.com/how_to/webxr
  43228. */
  43229. class WebXRCamera extends FreeCamera {
  43230. private static _TmpMatrix;
  43231. /**
  43232. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43233. * @param name the name of the camera
  43234. * @param scene the scene to add the camera to
  43235. */
  43236. constructor(name: string, scene: BABYLON.Scene);
  43237. private _updateNumberOfRigCameras;
  43238. /** @hidden */
  43239. _updateForDualEyeDebugging(pupilDistance?: number): void;
  43240. /**
  43241. * Updates the cameras position from the current pose information of the XR session
  43242. * @param xrSessionManager the session containing pose information
  43243. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43244. */
  43245. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43246. }
  43247. }
  43248. declare module BABYLON {
  43249. /**
  43250. * Button which can be used to enter a different mode of XR
  43251. */
  43252. class WebXREnterExitUIButton {
  43253. /** button element */
  43254. element: HTMLElement;
  43255. /** XR initialization options for the button */
  43256. initializationOptions: XRSessionCreationOptions;
  43257. /**
  43258. * Creates a WebXREnterExitUIButton
  43259. * @param element button element
  43260. * @param initializationOptions XR initialization options for the button
  43261. */
  43262. constructor(
  43263. /** button element */
  43264. element: HTMLElement,
  43265. /** XR initialization options for the button */
  43266. initializationOptions: XRSessionCreationOptions);
  43267. /**
  43268. * Overwritable function which can be used to update the button's visuals when the state changes
  43269. * @param activeButton the current active button in the UI
  43270. */
  43271. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43272. }
  43273. /**
  43274. * Options to create the webXR UI
  43275. */
  43276. class WebXREnterExitUIOptions {
  43277. /**
  43278. * Context to enter xr with
  43279. */
  43280. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  43281. /**
  43282. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43283. */
  43284. customButtons?: Array<WebXREnterExitUIButton>;
  43285. }
  43286. /**
  43287. * UI to allow the user to enter/exit XR mode
  43288. */
  43289. class WebXREnterExitUI implements IDisposable {
  43290. private scene;
  43291. private _overlay;
  43292. private _buttons;
  43293. private _activeButton;
  43294. /**
  43295. * Fired every time the active button is changed.
  43296. *
  43297. * When xr is entered via a button that launches xr that button will be the callback parameter
  43298. *
  43299. * When exiting xr the callback parameter will be null)
  43300. */
  43301. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43302. /**
  43303. * Creates UI to allow the user to enter/exit XR mode
  43304. * @param scene the scene to add the ui to
  43305. * @param helper the xr experience helper to enter/exit xr with
  43306. * @param options options to configure the UI
  43307. * @returns the created ui
  43308. */
  43309. static CreateAsync(scene: BABYLON.Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43310. private constructor();
  43311. private _updateButtons;
  43312. /**
  43313. * Disposes of the object
  43314. */
  43315. dispose(): void;
  43316. }
  43317. }
  43318. declare module BABYLON {
  43319. /**
  43320. * States of the webXR experience
  43321. */
  43322. enum WebXRState {
  43323. /**
  43324. * Transitioning to being in XR mode
  43325. */
  43326. ENTERING_XR = 0,
  43327. /**
  43328. * Transitioning to non XR mode
  43329. */
  43330. EXITING_XR = 1,
  43331. /**
  43332. * In XR mode and presenting
  43333. */
  43334. IN_XR = 2,
  43335. /**
  43336. * Not entered XR mode
  43337. */
  43338. NOT_IN_XR = 3
  43339. }
  43340. /**
  43341. * Helper class used to enable XR
  43342. * @see https://doc.babylonjs.com/how_to/webxr
  43343. */
  43344. class WebXRExperienceHelper implements IDisposable {
  43345. private scene;
  43346. /**
  43347. * 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
  43348. */
  43349. container: AbstractMesh;
  43350. /**
  43351. * Camera used to render xr content
  43352. */
  43353. camera: WebXRCamera;
  43354. /**
  43355. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43356. */
  43357. state: WebXRState;
  43358. private _setState;
  43359. private static _TmpVector;
  43360. /**
  43361. * Fires when the state of the experience helper has changed
  43362. */
  43363. onStateChangedObservable: Observable<WebXRState>;
  43364. /** @hidden */
  43365. _sessionManager: WebXRSessionManager;
  43366. private _nonVRCamera;
  43367. private _originalSceneAutoClear;
  43368. private _supported;
  43369. /**
  43370. * Creates the experience helper
  43371. * @param scene the scene to attach the experience helper to
  43372. * @returns a promise for the experience helper
  43373. */
  43374. static CreateAsync(scene: BABYLON.Scene): Promise<WebXRExperienceHelper>;
  43375. /**
  43376. * Creates a WebXRExperienceHelper
  43377. * @param scene The scene the helper should be created in
  43378. */
  43379. private constructor();
  43380. /**
  43381. * Exits XR mode and returns the scene to its original state
  43382. * @returns promise that resolves after xr mode has exited
  43383. */
  43384. exitXRAsync(): Promise<void>;
  43385. /**
  43386. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43387. * @param sessionCreationOptions options for the XR session
  43388. * @param frameOfReference frame of reference of the XR session
  43389. * @returns promise that resolves after xr mode has entered
  43390. */
  43391. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  43392. /**
  43393. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43394. * @param ray ray to cast into the environment
  43395. * @returns Promise which resolves with a collision point in the environment if it exists
  43396. */
  43397. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43398. /**
  43399. * Updates the global position of the camera by moving the camera's container
  43400. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43401. * @param position The desired global position of the camera
  43402. */
  43403. setPositionOfCameraUsingContainer(position: Vector3): void;
  43404. /**
  43405. * Rotates the xr camera by rotating the camera's container around the camera's position
  43406. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43407. * @param rotation the desired quaternion rotation to apply to the camera
  43408. */
  43409. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43410. /**
  43411. * Checks if the creation options are supported by the xr session
  43412. * @param options creation options
  43413. * @returns true if supported
  43414. */
  43415. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43416. /**
  43417. * Disposes of the experience helper
  43418. */
  43419. dispose(): void;
  43420. }
  43421. }
  43422. declare module BABYLON {
  43423. /**
  43424. * Represents an XR input
  43425. */
  43426. class WebXRController {
  43427. /**
  43428. * 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
  43429. */
  43430. grip?: BABYLON.AbstractMesh;
  43431. /**
  43432. * Pointer which can be used to select objects or attach a visible laser to
  43433. */
  43434. pointer: BABYLON.AbstractMesh;
  43435. /**
  43436. * Creates the controller
  43437. * @see https://doc.babylonjs.com/how_to/webxr
  43438. * @param scene the scene which the controller should be associated to
  43439. */
  43440. constructor(scene: BABYLON.Scene);
  43441. /**
  43442. * Disposes of the object
  43443. */
  43444. dispose(): void;
  43445. }
  43446. /**
  43447. * XR input used to track XR inputs such as controllers/rays
  43448. */
  43449. class WebXRInput implements IDisposable {
  43450. private helper;
  43451. /**
  43452. * XR controllers being tracked
  43453. */
  43454. controllers: Array<WebXRController>;
  43455. private _tmpMatrix;
  43456. private _frameObserver;
  43457. /**
  43458. * Initializes the WebXRInput
  43459. * @param helper experience helper which the input should be created for
  43460. */
  43461. constructor(helper: WebXRExperienceHelper);
  43462. /**
  43463. * Disposes of the object
  43464. */
  43465. dispose(): void;
  43466. }
  43467. }
  43468. declare module BABYLON {
  43469. /**
  43470. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43471. */
  43472. class WebXRManagedOutputCanvas implements IDisposable {
  43473. private _canvas;
  43474. /**
  43475. * xrpresent context of the canvas which can be used to display/mirror xr content
  43476. */
  43477. canvasContext: Nullable<WebGLRenderingContext>;
  43478. /**
  43479. * Initializes the canvas to be added/removed upon entering/exiting xr
  43480. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  43481. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43482. */
  43483. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43484. /**
  43485. * Disposes of the object
  43486. */
  43487. dispose(): void;
  43488. private _setManagedOutputCanvas;
  43489. private _addCanvas;
  43490. private _removeCanvas;
  43491. }
  43492. }
  43493. declare module BABYLON {
  43494. /**
  43495. * Manages an XRSession
  43496. * @see https://doc.babylonjs.com/how_to/webxr
  43497. */
  43498. class WebXRSessionManager implements IDisposable {
  43499. private scene;
  43500. /**
  43501. * Fires every time a new xrFrame arrives which can be used to update the camera
  43502. */
  43503. onXRFrameObservable: Observable<any>;
  43504. /**
  43505. * Fires when the xr session is ended either by the device or manually done
  43506. */
  43507. onXRSessionEnded: Observable<any>;
  43508. /** @hidden */
  43509. _xrSession: XRSession;
  43510. /** @hidden */
  43511. _frameOfReference: XRFrameOfReference;
  43512. /** @hidden */
  43513. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  43514. /** @hidden */
  43515. _currentXRFrame: Nullable<XRFrame>;
  43516. private _xrNavigator;
  43517. private _xrDevice;
  43518. private _tmpMatrix;
  43519. /**
  43520. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43521. * @param scene The scene which the session should be created for
  43522. */
  43523. constructor(scene: BABYLON.Scene);
  43524. /**
  43525. * Initializes the manager
  43526. * After initialization enterXR can be called to start an XR session
  43527. * @returns Promise which resolves after it is initialized
  43528. */
  43529. initializeAsync(): Promise<void>;
  43530. /**
  43531. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  43532. * @param sessionCreationOptions xr options to create the session with
  43533. * @param frameOfReferenceType option to configure how the xr pose is expressed
  43534. * @returns Promise which resolves after it enters XR
  43535. */
  43536. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  43537. /**
  43538. * Stops the xrSession and restores the renderloop
  43539. * @returns Promise which resolves after it exits XR
  43540. */
  43541. exitXRAsync(): Promise<void>;
  43542. /**
  43543. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43544. * @param ray ray to cast into the environment
  43545. * @returns Promise which resolves with a collision point in the environment if it exists
  43546. */
  43547. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43548. /**
  43549. * Checks if a session would be supported for the creation options specified
  43550. * @param options creation options to check if they are supported
  43551. * @returns true if supported
  43552. */
  43553. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43554. /**
  43555. * @hidden
  43556. * Converts the render layer of xrSession to a render target
  43557. * @param session session to create render target for
  43558. * @param scene scene the new render target should be created for
  43559. */
  43560. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: BABYLON.Scene): RenderTargetTexture;
  43561. /**
  43562. * Disposes of the session manager
  43563. */
  43564. dispose(): void;
  43565. }
  43566. }
  43567. declare module BABYLON {
  43568. /** @hidden */
  43569. class _OcclusionDataStorage {
  43570. /** @hidden */
  43571. occlusionInternalRetryCounter: number;
  43572. /** @hidden */
  43573. isOcclusionQueryInProgress: boolean;
  43574. /** @hidden */
  43575. isOccluded: boolean;
  43576. /** @hidden */
  43577. occlusionRetryCount: number;
  43578. /** @hidden */
  43579. occlusionType: number;
  43580. /** @hidden */
  43581. occlusionQueryAlgorithmType: number;
  43582. }
  43583. interface Engine {
  43584. /**
  43585. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43586. * @return the new query
  43587. */
  43588. createQuery(): WebGLQuery;
  43589. /**
  43590. * Delete and release a webGL query
  43591. * @param query defines the query to delete
  43592. * @return the current engine
  43593. */
  43594. deleteQuery(query: WebGLQuery): Engine;
  43595. /**
  43596. * Check if a given query has resolved and got its value
  43597. * @param query defines the query to check
  43598. * @returns true if the query got its value
  43599. */
  43600. isQueryResultAvailable(query: WebGLQuery): boolean;
  43601. /**
  43602. * Gets the value of a given query
  43603. * @param query defines the query to check
  43604. * @returns the value of the query
  43605. */
  43606. getQueryResult(query: WebGLQuery): number;
  43607. /**
  43608. * Initiates an occlusion query
  43609. * @param algorithmType defines the algorithm to use
  43610. * @param query defines the query to use
  43611. * @returns the current engine
  43612. * @see http://doc.babylonjs.com/features/occlusionquery
  43613. */
  43614. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43615. /**
  43616. * Ends an occlusion query
  43617. * @see http://doc.babylonjs.com/features/occlusionquery
  43618. * @param algorithmType defines the algorithm to use
  43619. * @returns the current engine
  43620. */
  43621. endOcclusionQuery(algorithmType: number): Engine;
  43622. /**
  43623. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43624. * Please note that only one query can be issued at a time
  43625. * @returns a time token used to track the time span
  43626. */
  43627. startTimeQuery(): Nullable<_TimeToken>;
  43628. /**
  43629. * Ends a time query
  43630. * @param token defines the token used to measure the time span
  43631. * @returns the time spent (in ns)
  43632. */
  43633. endTimeQuery(token: _TimeToken): int;
  43634. /** @hidden */
  43635. _currentNonTimestampToken: Nullable<_TimeToken>;
  43636. /** @hidden */
  43637. _createTimeQuery(): WebGLQuery;
  43638. /** @hidden */
  43639. _deleteTimeQuery(query: WebGLQuery): void;
  43640. /** @hidden */
  43641. _getGlAlgorithmType(algorithmType: number): number;
  43642. /** @hidden */
  43643. _getTimeQueryResult(query: WebGLQuery): any;
  43644. /** @hidden */
  43645. _getTimeQueryAvailability(query: WebGLQuery): any;
  43646. }
  43647. interface AbstractMesh {
  43648. /**
  43649. * Backing filed
  43650. * @hidden
  43651. */
  43652. __occlusionDataStorage: _OcclusionDataStorage;
  43653. /**
  43654. * Access property
  43655. * @hidden
  43656. */
  43657. _occlusionDataStorage: _OcclusionDataStorage;
  43658. /**
  43659. * 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.
  43660. * The default value is -1 which means don't break the query and wait till the result
  43661. * @see http://doc.babylonjs.com/features/occlusionquery
  43662. */
  43663. occlusionRetryCount: number;
  43664. /**
  43665. * 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:
  43666. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43667. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43668. * * 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.
  43669. * @see http://doc.babylonjs.com/features/occlusionquery
  43670. */
  43671. occlusionType: number;
  43672. /**
  43673. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43674. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43675. * * 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.
  43676. * @see http://doc.babylonjs.com/features/occlusionquery
  43677. */
  43678. occlusionQueryAlgorithmType: number;
  43679. /**
  43680. * 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
  43681. * @see http://doc.babylonjs.com/features/occlusionquery
  43682. */
  43683. isOccluded: boolean;
  43684. /**
  43685. * Flag to check the progress status of the query
  43686. * @see http://doc.babylonjs.com/features/occlusionquery
  43687. */
  43688. isOcclusionQueryInProgress: boolean;
  43689. }
  43690. }
  43691. declare module BABYLON {
  43692. interface Engine {
  43693. /**
  43694. * Creates a webGL transform feedback object
  43695. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43696. * @returns the webGL transform feedback object
  43697. */
  43698. createTransformFeedback(): WebGLTransformFeedback;
  43699. /**
  43700. * Delete a webGL transform feedback object
  43701. * @param value defines the webGL transform feedback object to delete
  43702. */
  43703. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43704. /**
  43705. * Bind a webGL transform feedback object to the webgl context
  43706. * @param value defines the webGL transform feedback object to bind
  43707. */
  43708. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43709. /**
  43710. * Begins a transform feedback operation
  43711. * @param usePoints defines if points or triangles must be used
  43712. */
  43713. beginTransformFeedback(usePoints: boolean): void;
  43714. /**
  43715. * Ends a transform feedback operation
  43716. */
  43717. endTransformFeedback(): void;
  43718. /**
  43719. * Specify the varyings to use with transform feedback
  43720. * @param program defines the associated webGL program
  43721. * @param value defines the list of strings representing the varying names
  43722. */
  43723. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43724. /**
  43725. * Bind a webGL buffer for a transform feedback operation
  43726. * @param value defines the webGL buffer to bind
  43727. */
  43728. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43729. }
  43730. }
  43731. declare module BABYLON {
  43732. /**
  43733. * Google Daydream controller
  43734. */
  43735. class DaydreamController extends WebVRController {
  43736. /**
  43737. * Base Url for the controller model.
  43738. */
  43739. static MODEL_BASE_URL: string;
  43740. /**
  43741. * File name for the controller model.
  43742. */
  43743. static MODEL_FILENAME: string;
  43744. /**
  43745. * Gamepad Id prefix used to identify Daydream Controller.
  43746. */
  43747. static readonly GAMEPAD_ID_PREFIX: string;
  43748. /**
  43749. * Creates a new DaydreamController from a gamepad
  43750. * @param vrGamepad the gamepad that the controller should be created from
  43751. */
  43752. constructor(vrGamepad: any);
  43753. /**
  43754. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43755. * @param scene scene in which to add meshes
  43756. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43757. */
  43758. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43759. /**
  43760. * Called once for each button that changed state since the last frame
  43761. * @param buttonIdx Which button index changed
  43762. * @param state New state of the button
  43763. * @param changes Which properties on the state changed since last frame
  43764. */
  43765. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43766. }
  43767. }
  43768. declare module BABYLON {
  43769. /**
  43770. * Gear VR Controller
  43771. */
  43772. class GearVRController extends WebVRController {
  43773. /**
  43774. * Base Url for the controller model.
  43775. */
  43776. static MODEL_BASE_URL: string;
  43777. /**
  43778. * File name for the controller model.
  43779. */
  43780. static MODEL_FILENAME: string;
  43781. /**
  43782. * Gamepad Id prefix used to identify this controller.
  43783. */
  43784. static readonly GAMEPAD_ID_PREFIX: string;
  43785. private readonly _buttonIndexToObservableNameMap;
  43786. /**
  43787. * Creates a new GearVRController from a gamepad
  43788. * @param vrGamepad the gamepad that the controller should be created from
  43789. */
  43790. constructor(vrGamepad: any);
  43791. /**
  43792. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43793. * @param scene scene in which to add meshes
  43794. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43795. */
  43796. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43797. /**
  43798. * Called once for each button that changed state since the last frame
  43799. * @param buttonIdx Which button index changed
  43800. * @param state New state of the button
  43801. * @param changes Which properties on the state changed since last frame
  43802. */
  43803. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43804. }
  43805. }
  43806. declare module BABYLON {
  43807. /**
  43808. * Generic Controller
  43809. */
  43810. class GenericController extends WebVRController {
  43811. /**
  43812. * Base Url for the controller model.
  43813. */
  43814. static readonly MODEL_BASE_URL: string;
  43815. /**
  43816. * File name for the controller model.
  43817. */
  43818. static readonly MODEL_FILENAME: string;
  43819. /**
  43820. * Creates a new GenericController from a gamepad
  43821. * @param vrGamepad the gamepad that the controller should be created from
  43822. */
  43823. constructor(vrGamepad: any);
  43824. /**
  43825. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43826. * @param scene scene in which to add meshes
  43827. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43828. */
  43829. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43830. /**
  43831. * Called once for each button that changed state since the last frame
  43832. * @param buttonIdx Which button index changed
  43833. * @param state New state of the button
  43834. * @param changes Which properties on the state changed since last frame
  43835. */
  43836. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43837. }
  43838. }
  43839. declare module BABYLON {
  43840. /**
  43841. * Oculus Touch Controller
  43842. */
  43843. class OculusTouchController extends WebVRController {
  43844. /**
  43845. * Base Url for the controller model.
  43846. */
  43847. static MODEL_BASE_URL: string;
  43848. /**
  43849. * File name for the left controller model.
  43850. */
  43851. static MODEL_LEFT_FILENAME: string;
  43852. /**
  43853. * File name for the right controller model.
  43854. */
  43855. static MODEL_RIGHT_FILENAME: string;
  43856. /**
  43857. * Fired when the secondary trigger on this controller is modified
  43858. */
  43859. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43860. /**
  43861. * Fired when the thumb rest on this controller is modified
  43862. */
  43863. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43864. /**
  43865. * Creates a new OculusTouchController from a gamepad
  43866. * @param vrGamepad the gamepad that the controller should be created from
  43867. */
  43868. constructor(vrGamepad: any);
  43869. /**
  43870. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43871. * @param scene scene in which to add meshes
  43872. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43873. */
  43874. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43875. /**
  43876. * Fired when the A button on this controller is modified
  43877. */
  43878. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43879. /**
  43880. * Fired when the B button on this controller is modified
  43881. */
  43882. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43883. /**
  43884. * Fired when the X button on this controller is modified
  43885. */
  43886. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43887. /**
  43888. * Fired when the Y button on this controller is modified
  43889. */
  43890. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43891. /**
  43892. * Called once for each button that changed state since the last frame
  43893. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43894. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43895. * 2) secondary trigger (same)
  43896. * 3) A (right) X (left), touch, pressed = value
  43897. * 4) B / Y
  43898. * 5) thumb rest
  43899. * @param buttonIdx Which button index changed
  43900. * @param state New state of the button
  43901. * @param changes Which properties on the state changed since last frame
  43902. */
  43903. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43904. }
  43905. }
  43906. declare module BABYLON {
  43907. /**
  43908. * Defines the types of pose enabled controllers that are supported
  43909. */
  43910. enum PoseEnabledControllerType {
  43911. /**
  43912. * HTC Vive
  43913. */
  43914. VIVE = 0,
  43915. /**
  43916. * Oculus Rift
  43917. */
  43918. OCULUS = 1,
  43919. /**
  43920. * Windows mixed reality
  43921. */
  43922. WINDOWS = 2,
  43923. /**
  43924. * Samsung gear VR
  43925. */
  43926. GEAR_VR = 3,
  43927. /**
  43928. * Google Daydream
  43929. */
  43930. DAYDREAM = 4,
  43931. /**
  43932. * Generic
  43933. */
  43934. GENERIC = 5
  43935. }
  43936. /**
  43937. * Defines the MutableGamepadButton interface for the state of a gamepad button
  43938. */
  43939. interface MutableGamepadButton {
  43940. /**
  43941. * Value of the button/trigger
  43942. */
  43943. value: number;
  43944. /**
  43945. * If the button/trigger is currently touched
  43946. */
  43947. touched: boolean;
  43948. /**
  43949. * If the button/trigger is currently pressed
  43950. */
  43951. pressed: boolean;
  43952. }
  43953. /**
  43954. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  43955. * @hidden
  43956. */
  43957. interface ExtendedGamepadButton extends GamepadButton {
  43958. /**
  43959. * If the button/trigger is currently pressed
  43960. */
  43961. readonly pressed: boolean;
  43962. /**
  43963. * If the button/trigger is currently touched
  43964. */
  43965. readonly touched: boolean;
  43966. /**
  43967. * Value of the button/trigger
  43968. */
  43969. readonly value: number;
  43970. }
  43971. /**
  43972. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43973. */
  43974. class PoseEnabledControllerHelper {
  43975. /**
  43976. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43977. * @param vrGamepad the gamepad to initialized
  43978. * @returns a vr controller of the type the gamepad identified as
  43979. */
  43980. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  43981. }
  43982. /**
  43983. * Defines the PoseEnabledController object that contains state of a vr capable controller
  43984. */
  43985. class PoseEnabledController extends Gamepad implements PoseControlled {
  43986. private _deviceRoomPosition;
  43987. private _deviceRoomRotationQuaternion;
  43988. /**
  43989. * The device position in babylon space
  43990. */
  43991. devicePosition: Vector3;
  43992. /**
  43993. * The device rotation in babylon space
  43994. */
  43995. deviceRotationQuaternion: Quaternion;
  43996. /**
  43997. * The scale factor of the device in babylon space
  43998. */
  43999. deviceScaleFactor: number;
  44000. /**
  44001. * (Likely devicePosition should be used instead) The device position in its room space
  44002. */
  44003. position: Vector3;
  44004. /**
  44005. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  44006. */
  44007. rotationQuaternion: Quaternion;
  44008. /**
  44009. * The type of controller (Eg. Windows mixed reality)
  44010. */
  44011. controllerType: PoseEnabledControllerType;
  44012. protected _calculatedPosition: Vector3;
  44013. private _calculatedRotation;
  44014. /**
  44015. * The raw pose from the device
  44016. */
  44017. rawPose: DevicePose;
  44018. private _trackPosition;
  44019. private _maxRotationDistFromHeadset;
  44020. private _draggedRoomRotation;
  44021. /**
  44022. * @hidden
  44023. */
  44024. _disableTrackPosition(fixedPosition: Vector3): void;
  44025. /**
  44026. * Internal, the mesh attached to the controller
  44027. * @hidden
  44028. */
  44029. _mesh: Nullable<AbstractMesh>;
  44030. private _poseControlledCamera;
  44031. private _leftHandSystemQuaternion;
  44032. /**
  44033. * Internal, matrix used to convert room space to babylon space
  44034. * @hidden
  44035. */
  44036. _deviceToWorld: Matrix;
  44037. /**
  44038. * Node to be used when casting a ray from the controller
  44039. * @hidden
  44040. */
  44041. _pointingPoseNode: Nullable<TransformNode>;
  44042. /**
  44043. * Name of the child mesh that can be used to cast a ray from the controller
  44044. */
  44045. static readonly POINTING_POSE: string;
  44046. /**
  44047. * Creates a new PoseEnabledController from a gamepad
  44048. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  44049. */
  44050. constructor(browserGamepad: any);
  44051. private _workingMatrix;
  44052. /**
  44053. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  44054. */
  44055. update(): void;
  44056. /**
  44057. * Updates only the pose device and mesh without doing any button event checking
  44058. */
  44059. protected _updatePoseAndMesh(): void;
  44060. /**
  44061. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  44062. * @param poseData raw pose fromthe device
  44063. */
  44064. updateFromDevice(poseData: DevicePose): void;
  44065. /**
  44066. * @hidden
  44067. */
  44068. _meshAttachedObservable: Observable<AbstractMesh>;
  44069. /**
  44070. * Attaches a mesh to the controller
  44071. * @param mesh the mesh to be attached
  44072. */
  44073. attachToMesh(mesh: AbstractMesh): void;
  44074. /**
  44075. * Attaches the controllers mesh to a camera
  44076. * @param camera the camera the mesh should be attached to
  44077. */
  44078. attachToPoseControlledCamera(camera: TargetCamera): void;
  44079. /**
  44080. * Disposes of the controller
  44081. */
  44082. dispose(): void;
  44083. /**
  44084. * The mesh that is attached to the controller
  44085. */
  44086. readonly mesh: Nullable<AbstractMesh>;
  44087. /**
  44088. * Gets the ray of the controller in the direction the controller is pointing
  44089. * @param length the length the resulting ray should be
  44090. * @returns a ray in the direction the controller is pointing
  44091. */
  44092. getForwardRay(length?: number): Ray;
  44093. }
  44094. }
  44095. declare module BABYLON {
  44096. /**
  44097. * Vive Controller
  44098. */
  44099. class ViveController extends WebVRController {
  44100. /**
  44101. * Base Url for the controller model.
  44102. */
  44103. static MODEL_BASE_URL: string;
  44104. /**
  44105. * File name for the controller model.
  44106. */
  44107. static MODEL_FILENAME: string;
  44108. /**
  44109. * Creates a new ViveController from a gamepad
  44110. * @param vrGamepad the gamepad that the controller should be created from
  44111. */
  44112. constructor(vrGamepad: any);
  44113. /**
  44114. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44115. * @param scene scene in which to add meshes
  44116. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44117. */
  44118. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44119. /**
  44120. * Fired when the left button on this controller is modified
  44121. */
  44122. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44123. /**
  44124. * Fired when the right button on this controller is modified
  44125. */
  44126. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44127. /**
  44128. * Fired when the menu button on this controller is modified
  44129. */
  44130. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44131. /**
  44132. * Called once for each button that changed state since the last frame
  44133. * Vive mapping:
  44134. * 0: touchpad
  44135. * 1: trigger
  44136. * 2: left AND right buttons
  44137. * 3: menu button
  44138. * @param buttonIdx Which button index changed
  44139. * @param state New state of the button
  44140. * @param changes Which properties on the state changed since last frame
  44141. */
  44142. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44143. }
  44144. }
  44145. declare module BABYLON {
  44146. /**
  44147. * Defines the WebVRController object that represents controllers tracked in 3D space
  44148. */
  44149. abstract class WebVRController extends PoseEnabledController {
  44150. /**
  44151. * Internal, the default controller model for the controller
  44152. */
  44153. protected _defaultModel: AbstractMesh;
  44154. /**
  44155. * Fired when the trigger state has changed
  44156. */
  44157. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44158. /**
  44159. * Fired when the main button state has changed
  44160. */
  44161. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44162. /**
  44163. * Fired when the secondary button state has changed
  44164. */
  44165. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44166. /**
  44167. * Fired when the pad state has changed
  44168. */
  44169. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  44170. /**
  44171. * Fired when controllers stick values have changed
  44172. */
  44173. onPadValuesChangedObservable: Observable<StickValues>;
  44174. /**
  44175. * Array of button availible on the controller
  44176. */
  44177. protected _buttons: Array<MutableGamepadButton>;
  44178. private _onButtonStateChange;
  44179. /**
  44180. * Fired when a controller button's state has changed
  44181. * @param callback the callback containing the button that was modified
  44182. */
  44183. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  44184. /**
  44185. * X and Y axis corrisponding to the controllers joystick
  44186. */
  44187. pad: StickValues;
  44188. /**
  44189. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  44190. */
  44191. hand: string;
  44192. /**
  44193. * The default controller model for the controller
  44194. */
  44195. readonly defaultModel: AbstractMesh;
  44196. /**
  44197. * Creates a new WebVRController from a gamepad
  44198. * @param vrGamepad the gamepad that the WebVRController should be created from
  44199. */
  44200. constructor(vrGamepad: any);
  44201. /**
  44202. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  44203. */
  44204. update(): void;
  44205. /**
  44206. * Function to be called when a button is modified
  44207. */
  44208. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44209. /**
  44210. * Loads a mesh and attaches it to the controller
  44211. * @param scene the scene the mesh should be added to
  44212. * @param meshLoaded callback for when the mesh has been loaded
  44213. */
  44214. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44215. private _setButtonValue;
  44216. private _changes;
  44217. private _checkChanges;
  44218. /**
  44219. * Disposes of th webVRCOntroller
  44220. */
  44221. dispose(): void;
  44222. }
  44223. }
  44224. declare module BABYLON {
  44225. /**
  44226. * Defines the WindowsMotionController object that the state of the windows motion controller
  44227. */
  44228. class WindowsMotionController extends WebVRController {
  44229. /**
  44230. * The base url used to load the left and right controller models
  44231. */
  44232. static MODEL_BASE_URL: string;
  44233. /**
  44234. * The name of the left controller model file
  44235. */
  44236. static MODEL_LEFT_FILENAME: string;
  44237. /**
  44238. * The name of the right controller model file
  44239. */
  44240. static MODEL_RIGHT_FILENAME: string;
  44241. /**
  44242. * The controller name prefix for this controller type
  44243. */
  44244. static readonly GAMEPAD_ID_PREFIX: string;
  44245. /**
  44246. * The controller id pattern for this controller type
  44247. */
  44248. private static readonly GAMEPAD_ID_PATTERN;
  44249. private _loadedMeshInfo;
  44250. private readonly _mapping;
  44251. /**
  44252. * Fired when the trackpad on this controller is clicked
  44253. */
  44254. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44255. /**
  44256. * Fired when the trackpad on this controller is modified
  44257. */
  44258. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44259. /**
  44260. * The current x and y values of this controller's trackpad
  44261. */
  44262. trackpad: StickValues;
  44263. /**
  44264. * Creates a new WindowsMotionController from a gamepad
  44265. * @param vrGamepad the gamepad that the controller should be created from
  44266. */
  44267. constructor(vrGamepad: any);
  44268. /**
  44269. * Fired when the trigger on this controller is modified
  44270. */
  44271. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44272. /**
  44273. * Fired when the menu button on this controller is modified
  44274. */
  44275. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44276. /**
  44277. * Fired when the grip button on this controller is modified
  44278. */
  44279. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44280. /**
  44281. * Fired when the thumbstick button on this controller is modified
  44282. */
  44283. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44284. /**
  44285. * Fired when the touchpad button on this controller is modified
  44286. */
  44287. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44288. /**
  44289. * Fired when the touchpad values on this controller are modified
  44290. */
  44291. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44292. private _updateTrackpad;
  44293. /**
  44294. * Called once per frame by the engine.
  44295. */
  44296. update(): void;
  44297. /**
  44298. * Called once for each button that changed state since the last frame
  44299. * @param buttonIdx Which button index changed
  44300. * @param state New state of the button
  44301. * @param changes Which properties on the state changed since last frame
  44302. */
  44303. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44304. /**
  44305. * Moves the buttons on the controller mesh based on their current state
  44306. * @param buttonName the name of the button to move
  44307. * @param buttonValue the value of the button which determines the buttons new position
  44308. */
  44309. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44310. /**
  44311. * Moves the axis on the controller mesh based on its current state
  44312. * @param axis the index of the axis
  44313. * @param axisValue the value of the axis which determines the meshes new position
  44314. * @hidden
  44315. */
  44316. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44317. /**
  44318. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44319. * @param scene scene in which to add meshes
  44320. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44321. */
  44322. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44323. /**
  44324. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44325. * can be transformed by button presses and axes values, based on this._mapping.
  44326. *
  44327. * @param scene scene in which the meshes exist
  44328. * @param meshes list of meshes that make up the controller model to process
  44329. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44330. */
  44331. private processModel;
  44332. private createMeshInfo;
  44333. /**
  44334. * Gets the ray of the controller in the direction the controller is pointing
  44335. * @param length the length the resulting ray should be
  44336. * @returns a ray in the direction the controller is pointing
  44337. */
  44338. getForwardRay(length?: number): Ray;
  44339. /**
  44340. * Disposes of the controller
  44341. */
  44342. dispose(): void;
  44343. }
  44344. }
  44345. declare module BABYLON {
  44346. /**
  44347. * Interface to implement to create a shadow generator compatible with BJS.
  44348. */
  44349. interface IShadowGenerator {
  44350. /**
  44351. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44352. * @returns The render target texture if present otherwise, null
  44353. */
  44354. getShadowMap(): Nullable<RenderTargetTexture>;
  44355. /**
  44356. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44357. * @returns The render target texture if the shadow map is present otherwise, null
  44358. */
  44359. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44360. /**
  44361. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44362. * @param subMesh The submesh we want to render in the shadow map
  44363. * @param useInstances Defines wether will draw in the map using instances
  44364. * @returns true if ready otherwise, false
  44365. */
  44366. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44367. /**
  44368. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44369. * @param defines Defines of the material we want to update
  44370. * @param lightIndex Index of the light in the enabled light list of the material
  44371. */
  44372. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  44373. /**
  44374. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44375. * defined in the generator but impacting the effect).
  44376. * It implies the unifroms available on the materials are the standard BJS ones.
  44377. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44378. * @param effect The effect we are binfing the information for
  44379. */
  44380. bindShadowLight(lightIndex: string, effect: Effect): void;
  44381. /**
  44382. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44383. * (eq to shadow prjection matrix * light transform matrix)
  44384. * @returns The transform matrix used to create the shadow map
  44385. */
  44386. getTransformMatrix(): Matrix;
  44387. /**
  44388. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44389. * Cube and 2D textures for instance.
  44390. */
  44391. recreateShadowMap(): void;
  44392. /**
  44393. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44394. * @param onCompiled Callback triggered at the and of the effects compilation
  44395. * @param options Sets of optional options forcing the compilation with different modes
  44396. */
  44397. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44398. useInstances: boolean;
  44399. }>): void;
  44400. /**
  44401. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44402. * @param options Sets of optional options forcing the compilation with different modes
  44403. * @returns A promise that resolves when the compilation completes
  44404. */
  44405. forceCompilationAsync(options?: Partial<{
  44406. useInstances: boolean;
  44407. }>): Promise<void>;
  44408. /**
  44409. * Serializes the shadow generator setup to a json object.
  44410. * @returns The serialized JSON object
  44411. */
  44412. serialize(): any;
  44413. /**
  44414. * Disposes the Shadow map and related Textures and effects.
  44415. */
  44416. dispose(): void;
  44417. }
  44418. /**
  44419. * Default implementation IShadowGenerator.
  44420. * This is the main object responsible of generating shadows in the framework.
  44421. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44422. */
  44423. class ShadowGenerator implements IShadowGenerator {
  44424. /**
  44425. * Shadow generator mode None: no filtering applied.
  44426. */
  44427. static readonly FILTER_NONE: number;
  44428. /**
  44429. * Shadow generator mode ESM: Exponential Shadow Mapping.
  44430. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44431. */
  44432. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  44433. /**
  44434. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  44435. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  44436. */
  44437. static readonly FILTER_POISSONSAMPLING: number;
  44438. /**
  44439. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  44440. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44441. */
  44442. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  44443. /**
  44444. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  44445. * edge artifacts on steep falloff.
  44446. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44447. */
  44448. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  44449. /**
  44450. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  44451. * edge artifacts on steep falloff.
  44452. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44453. */
  44454. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  44455. /**
  44456. * Shadow generator mode PCF: Percentage Closer Filtering
  44457. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44458. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  44459. */
  44460. static readonly FILTER_PCF: number;
  44461. /**
  44462. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  44463. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44464. * Contact Hardening
  44465. */
  44466. static readonly FILTER_PCSS: number;
  44467. /**
  44468. * Reserved for PCF and PCSS
  44469. * Highest Quality.
  44470. *
  44471. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  44472. *
  44473. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  44474. */
  44475. static readonly QUALITY_HIGH: number;
  44476. /**
  44477. * Reserved for PCF and PCSS
  44478. * Good tradeoff for quality/perf cross devices
  44479. *
  44480. * Execute PCF on a 3*3 kernel.
  44481. *
  44482. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  44483. */
  44484. static readonly QUALITY_MEDIUM: number;
  44485. /**
  44486. * Reserved for PCF and PCSS
  44487. * The lowest quality but the fastest.
  44488. *
  44489. * Execute PCF on a 1*1 kernel.
  44490. *
  44491. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  44492. */
  44493. static readonly QUALITY_LOW: number;
  44494. private _bias;
  44495. /**
  44496. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44497. */
  44498. /**
  44499. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44500. */
  44501. bias: number;
  44502. private _normalBias;
  44503. /**
  44504. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44505. */
  44506. /**
  44507. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44508. */
  44509. normalBias: number;
  44510. private _blurBoxOffset;
  44511. /**
  44512. * Gets the blur box offset: offset applied during the blur pass.
  44513. * Only useful if useKernelBlur = false
  44514. */
  44515. /**
  44516. * Sets the blur box offset: offset applied during the blur pass.
  44517. * Only useful if useKernelBlur = false
  44518. */
  44519. blurBoxOffset: number;
  44520. private _blurScale;
  44521. /**
  44522. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44523. * 2 means half of the size.
  44524. */
  44525. /**
  44526. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44527. * 2 means half of the size.
  44528. */
  44529. blurScale: number;
  44530. private _blurKernel;
  44531. /**
  44532. * Gets the blur kernel: kernel size of the blur pass.
  44533. * Only useful if useKernelBlur = true
  44534. */
  44535. /**
  44536. * Sets the blur kernel: kernel size of the blur pass.
  44537. * Only useful if useKernelBlur = true
  44538. */
  44539. blurKernel: number;
  44540. private _useKernelBlur;
  44541. /**
  44542. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44543. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44544. */
  44545. /**
  44546. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44547. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44548. */
  44549. useKernelBlur: boolean;
  44550. private _depthScale;
  44551. /**
  44552. * Gets the depth scale used in ESM mode.
  44553. */
  44554. /**
  44555. * Sets the depth scale used in ESM mode.
  44556. * This can override the scale stored on the light.
  44557. */
  44558. depthScale: number;
  44559. private _filter;
  44560. /**
  44561. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44562. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44563. */
  44564. /**
  44565. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44566. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44567. */
  44568. filter: number;
  44569. /**
  44570. * Gets if the current filter is set to Poisson Sampling.
  44571. */
  44572. /**
  44573. * Sets the current filter to Poisson Sampling.
  44574. */
  44575. usePoissonSampling: boolean;
  44576. /**
  44577. * Gets if the current filter is set to ESM.
  44578. */
  44579. /**
  44580. * Sets the current filter is to ESM.
  44581. */
  44582. useExponentialShadowMap: boolean;
  44583. /**
  44584. * Gets if the current filter is set to filtered ESM.
  44585. */
  44586. /**
  44587. * Gets if the current filter is set to filtered ESM.
  44588. */
  44589. useBlurExponentialShadowMap: boolean;
  44590. /**
  44591. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44592. * exponential to prevent steep falloff artifacts).
  44593. */
  44594. /**
  44595. * Sets the current filter to "close ESM" (using the inverse of the
  44596. * exponential to prevent steep falloff artifacts).
  44597. */
  44598. useCloseExponentialShadowMap: boolean;
  44599. /**
  44600. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44601. * exponential to prevent steep falloff artifacts).
  44602. */
  44603. /**
  44604. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44605. * exponential to prevent steep falloff artifacts).
  44606. */
  44607. useBlurCloseExponentialShadowMap: boolean;
  44608. /**
  44609. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44610. */
  44611. /**
  44612. * Sets the current filter to "PCF" (percentage closer filtering).
  44613. */
  44614. usePercentageCloserFiltering: boolean;
  44615. private _filteringQuality;
  44616. /**
  44617. * Gets the PCF or PCSS Quality.
  44618. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44619. */
  44620. /**
  44621. * Sets the PCF or PCSS Quality.
  44622. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44623. */
  44624. filteringQuality: number;
  44625. /**
  44626. * Gets if the current filter is set to "PCSS" (contact hardening).
  44627. */
  44628. /**
  44629. * Sets the current filter to "PCSS" (contact hardening).
  44630. */
  44631. useContactHardeningShadow: boolean;
  44632. private _contactHardeningLightSizeUVRatio;
  44633. /**
  44634. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44635. * Using a ratio helps keeping shape stability independently of the map size.
  44636. *
  44637. * It does not account for the light projection as it was having too much
  44638. * instability during the light setup or during light position changes.
  44639. *
  44640. * Only valid if useContactHardeningShadow is true.
  44641. */
  44642. /**
  44643. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44644. * Using a ratio helps keeping shape stability independently of the map size.
  44645. *
  44646. * It does not account for the light projection as it was having too much
  44647. * instability during the light setup or during light position changes.
  44648. *
  44649. * Only valid if useContactHardeningShadow is true.
  44650. */
  44651. contactHardeningLightSizeUVRatio: number;
  44652. private _darkness;
  44653. /**
  44654. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44655. * 0 means strongest and 1 would means no shadow.
  44656. * @returns the darkness.
  44657. */
  44658. getDarkness(): number;
  44659. /**
  44660. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44661. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44662. * @returns the shadow generator allowing fluent coding.
  44663. */
  44664. setDarkness(darkness: number): ShadowGenerator;
  44665. private _transparencyShadow;
  44666. /**
  44667. * Sets the ability to have transparent shadow (boolean).
  44668. * @param transparent True if transparent else False
  44669. * @returns the shadow generator allowing fluent coding
  44670. */
  44671. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  44672. private _shadowMap;
  44673. private _shadowMap2;
  44674. /**
  44675. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44676. * @returns The render target texture if present otherwise, null
  44677. */
  44678. getShadowMap(): Nullable<RenderTargetTexture>;
  44679. /**
  44680. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44681. * @returns The render target texture if the shadow map is present otherwise, null
  44682. */
  44683. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44684. /**
  44685. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44686. * @param mesh Mesh to add
  44687. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44688. * @returns the Shadow Generator itself
  44689. */
  44690. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44691. /**
  44692. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44693. * @param mesh Mesh to remove
  44694. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44695. * @returns the Shadow Generator itself
  44696. */
  44697. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44698. /**
  44699. * Controls the extent to which the shadows fade out at the edge of the frustum
  44700. * Used only by directionals and spots
  44701. */
  44702. frustumEdgeFalloff: number;
  44703. private _light;
  44704. /**
  44705. * Returns the associated light object.
  44706. * @returns the light generating the shadow
  44707. */
  44708. getLight(): IShadowLight;
  44709. /**
  44710. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44711. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44712. * It might on the other hand introduce peter panning.
  44713. */
  44714. forceBackFacesOnly: boolean;
  44715. private _scene;
  44716. private _lightDirection;
  44717. private _effect;
  44718. private _viewMatrix;
  44719. private _projectionMatrix;
  44720. private _transformMatrix;
  44721. private _cachedPosition;
  44722. private _cachedDirection;
  44723. private _cachedDefines;
  44724. private _currentRenderID;
  44725. private _boxBlurPostprocess;
  44726. private _kernelBlurXPostprocess;
  44727. private _kernelBlurYPostprocess;
  44728. private _blurPostProcesses;
  44729. private _mapSize;
  44730. private _currentFaceIndex;
  44731. private _currentFaceIndexCache;
  44732. private _textureType;
  44733. private _defaultTextureMatrix;
  44734. /**
  44735. * Creates a ShadowGenerator object.
  44736. * A ShadowGenerator is the required tool to use the shadows.
  44737. * Each light casting shadows needs to use its own ShadowGenerator.
  44738. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44739. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44740. * @param light The light object generating the shadows.
  44741. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  44742. */
  44743. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  44744. private _initializeGenerator;
  44745. private _initializeShadowMap;
  44746. private _initializeBlurRTTAndPostProcesses;
  44747. private _renderForShadowMap;
  44748. private _renderSubMeshForShadowMap;
  44749. private _applyFilterValues;
  44750. /**
  44751. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44752. * @param onCompiled Callback triggered at the and of the effects compilation
  44753. * @param options Sets of optional options forcing the compilation with different modes
  44754. */
  44755. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44756. useInstances: boolean;
  44757. }>): void;
  44758. /**
  44759. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44760. * @param options Sets of optional options forcing the compilation with different modes
  44761. * @returns A promise that resolves when the compilation completes
  44762. */
  44763. forceCompilationAsync(options?: Partial<{
  44764. useInstances: boolean;
  44765. }>): Promise<void>;
  44766. /**
  44767. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44768. * @param subMesh The submesh we want to render in the shadow map
  44769. * @param useInstances Defines wether will draw in the map using instances
  44770. * @returns true if ready otherwise, false
  44771. */
  44772. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44773. /**
  44774. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44775. * @param defines Defines of the material we want to update
  44776. * @param lightIndex Index of the light in the enabled light list of the material
  44777. */
  44778. prepareDefines(defines: any, lightIndex: number): void;
  44779. /**
  44780. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44781. * defined in the generator but impacting the effect).
  44782. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44783. * @param effect The effect we are binfing the information for
  44784. */
  44785. bindShadowLight(lightIndex: string, effect: Effect): void;
  44786. /**
  44787. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44788. * (eq to shadow prjection matrix * light transform matrix)
  44789. * @returns The transform matrix used to create the shadow map
  44790. */
  44791. getTransformMatrix(): Matrix;
  44792. /**
  44793. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44794. * Cube and 2D textures for instance.
  44795. */
  44796. recreateShadowMap(): void;
  44797. private _disposeBlurPostProcesses;
  44798. private _disposeRTTandPostProcesses;
  44799. /**
  44800. * Disposes the ShadowGenerator.
  44801. * Returns nothing.
  44802. */
  44803. dispose(): void;
  44804. /**
  44805. * Serializes the shadow generator setup to a json object.
  44806. * @returns The serialized JSON object
  44807. */
  44808. serialize(): any;
  44809. /**
  44810. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44811. * @param parsedShadowGenerator The JSON object to parse
  44812. * @param scene The scene to create the shadow map for
  44813. * @returns The parsed shadow generator
  44814. */
  44815. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  44816. }
  44817. }
  44818. declare module BABYLON {
  44819. /**
  44820. * Defines the shadow generator component responsible to manage any shadow generators
  44821. * in a given scene.
  44822. */
  44823. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44824. /**
  44825. * The component name helpfull to identify the component in the list of scene components.
  44826. */
  44827. readonly name: string;
  44828. /**
  44829. * The scene the component belongs to.
  44830. */
  44831. scene: Scene;
  44832. /**
  44833. * Creates a new instance of the component for the given scene
  44834. * @param scene Defines the scene to register the component in
  44835. */
  44836. constructor(scene: Scene);
  44837. /**
  44838. * Registers the component in a given scene
  44839. */
  44840. register(): void;
  44841. /**
  44842. * Rebuilds the elements related to this component in case of
  44843. * context lost for instance.
  44844. */
  44845. rebuild(): void;
  44846. /**
  44847. * Serializes the component data to the specified json object
  44848. * @param serializationObject The object to serialize to
  44849. */
  44850. serialize(serializationObject: any): void;
  44851. /**
  44852. * Adds all the element from the container to the scene
  44853. * @param container the container holding the elements
  44854. */
  44855. addFromContainer(container: AbstractScene): void;
  44856. /**
  44857. * Removes all the elements in the container from the scene
  44858. * @param container contains the elements to remove
  44859. */
  44860. removeFromContainer(container: AbstractScene): void;
  44861. /**
  44862. * Rebuilds the elements related to this component in case of
  44863. * context lost for instance.
  44864. */
  44865. dispose(): void;
  44866. private _gatherRenderTargets;
  44867. }
  44868. }
  44869. declare module BABYLON {
  44870. }
  44871. declare module BABYLON {
  44872. /**
  44873. * Background material used to create an efficient environement around your scene.
  44874. */
  44875. class BackgroundMaterial extends PushMaterial {
  44876. /**
  44877. * Standard reflectance value at parallel view angle.
  44878. */
  44879. static StandardReflectance0: number;
  44880. /**
  44881. * Standard reflectance value at grazing angle.
  44882. */
  44883. static StandardReflectance90: number;
  44884. protected _primaryColor: Color3;
  44885. /**
  44886. * Key light Color (multiply against the environement texture)
  44887. */
  44888. primaryColor: Color3;
  44889. protected __perceptualColor: Nullable<Color3>;
  44890. /**
  44891. * Experimental Internal Use Only.
  44892. *
  44893. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44894. * This acts as a helper to set the primary color to a more "human friendly" value.
  44895. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44896. * output color as close as possible from the chosen value.
  44897. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44898. * part of lighting setup.)
  44899. */
  44900. _perceptualColor: Nullable<Color3>;
  44901. protected _primaryColorShadowLevel: float;
  44902. /**
  44903. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44904. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44905. */
  44906. primaryColorShadowLevel: float;
  44907. protected _primaryColorHighlightLevel: float;
  44908. /**
  44909. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44910. * The primary color is used at the level chosen to define what the white area would look.
  44911. */
  44912. primaryColorHighlightLevel: float;
  44913. protected _reflectionTexture: Nullable<BaseTexture>;
  44914. /**
  44915. * Reflection Texture used in the material.
  44916. * Should be author in a specific way for the best result (refer to the documentation).
  44917. */
  44918. reflectionTexture: Nullable<BaseTexture>;
  44919. protected _reflectionBlur: float;
  44920. /**
  44921. * Reflection Texture level of blur.
  44922. *
  44923. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44924. * texture twice.
  44925. */
  44926. reflectionBlur: float;
  44927. protected _diffuseTexture: Nullable<BaseTexture>;
  44928. /**
  44929. * Diffuse Texture used in the material.
  44930. * Should be author in a specific way for the best result (refer to the documentation).
  44931. */
  44932. diffuseTexture: Nullable<BaseTexture>;
  44933. protected _shadowLights: Nullable<IShadowLight[]>;
  44934. /**
  44935. * Specify the list of lights casting shadow on the material.
  44936. * All scene shadow lights will be included if null.
  44937. */
  44938. shadowLights: Nullable<IShadowLight[]>;
  44939. protected _shadowLevel: float;
  44940. /**
  44941. * Helps adjusting the shadow to a softer level if required.
  44942. * 0 means black shadows and 1 means no shadows.
  44943. */
  44944. shadowLevel: float;
  44945. protected _sceneCenter: Vector3;
  44946. /**
  44947. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44948. * It is usually zero but might be interesting to modify according to your setup.
  44949. */
  44950. sceneCenter: Vector3;
  44951. protected _opacityFresnel: boolean;
  44952. /**
  44953. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44954. * This helps ensuring a nice transition when the camera goes under the ground.
  44955. */
  44956. opacityFresnel: boolean;
  44957. protected _reflectionFresnel: boolean;
  44958. /**
  44959. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44960. * This helps adding a mirror texture on the ground.
  44961. */
  44962. reflectionFresnel: boolean;
  44963. protected _reflectionFalloffDistance: number;
  44964. /**
  44965. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44966. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44967. */
  44968. reflectionFalloffDistance: number;
  44969. protected _reflectionAmount: number;
  44970. /**
  44971. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44972. */
  44973. reflectionAmount: number;
  44974. protected _reflectionReflectance0: number;
  44975. /**
  44976. * This specifies the weight of the reflection at grazing angle.
  44977. */
  44978. reflectionReflectance0: number;
  44979. protected _reflectionReflectance90: number;
  44980. /**
  44981. * This specifies the weight of the reflection at a perpendicular point of view.
  44982. */
  44983. reflectionReflectance90: number;
  44984. /**
  44985. * Sets the reflection reflectance fresnel values according to the default standard
  44986. * empirically know to work well :-)
  44987. */
  44988. reflectionStandardFresnelWeight: number;
  44989. protected _useRGBColor: boolean;
  44990. /**
  44991. * Helps to directly use the maps channels instead of their level.
  44992. */
  44993. useRGBColor: boolean;
  44994. protected _enableNoise: boolean;
  44995. /**
  44996. * This helps reducing the banding effect that could occur on the background.
  44997. */
  44998. enableNoise: boolean;
  44999. /**
  45000. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45001. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45002. * Recommended to be keep at 1.0 except for special cases.
  45003. */
  45004. fovMultiplier: number;
  45005. private _fovMultiplier;
  45006. /**
  45007. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45008. */
  45009. useEquirectangularFOV: boolean;
  45010. private _maxSimultaneousLights;
  45011. /**
  45012. * Number of Simultaneous lights allowed on the material.
  45013. */
  45014. maxSimultaneousLights: int;
  45015. /**
  45016. * Default configuration related to image processing available in the Background Material.
  45017. */
  45018. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45019. /**
  45020. * Keep track of the image processing observer to allow dispose and replace.
  45021. */
  45022. private _imageProcessingObserver;
  45023. /**
  45024. * Attaches a new image processing configuration to the PBR Material.
  45025. * @param configuration (if null the scene configuration will be use)
  45026. */
  45027. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45028. /**
  45029. * Gets the image processing configuration used either in this material.
  45030. */
  45031. /**
  45032. * Sets the Default image processing configuration used either in the this material.
  45033. *
  45034. * If sets to null, the scene one is in use.
  45035. */
  45036. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45037. /**
  45038. * Gets wether the color curves effect is enabled.
  45039. */
  45040. /**
  45041. * Sets wether the color curves effect is enabled.
  45042. */
  45043. cameraColorCurvesEnabled: boolean;
  45044. /**
  45045. * Gets wether the color grading effect is enabled.
  45046. */
  45047. /**
  45048. * Gets wether the color grading effect is enabled.
  45049. */
  45050. cameraColorGradingEnabled: boolean;
  45051. /**
  45052. * Gets wether tonemapping is enabled or not.
  45053. */
  45054. /**
  45055. * Sets wether tonemapping is enabled or not
  45056. */
  45057. cameraToneMappingEnabled: boolean;
  45058. /**
  45059. * The camera exposure used on this material.
  45060. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45061. * This corresponds to a photographic exposure.
  45062. */
  45063. /**
  45064. * The camera exposure used on this material.
  45065. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45066. * This corresponds to a photographic exposure.
  45067. */
  45068. cameraExposure: float;
  45069. /**
  45070. * Gets The camera contrast used on this material.
  45071. */
  45072. /**
  45073. * Sets The camera contrast used on this material.
  45074. */
  45075. cameraContrast: float;
  45076. /**
  45077. * Gets the Color Grading 2D Lookup Texture.
  45078. */
  45079. /**
  45080. * Sets the Color Grading 2D Lookup Texture.
  45081. */
  45082. cameraColorGradingTexture: Nullable<BaseTexture>;
  45083. /**
  45084. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45085. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45086. * 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;
  45087. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45088. */
  45089. /**
  45090. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45091. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45092. * 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;
  45093. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45094. */
  45095. cameraColorCurves: Nullable<ColorCurves>;
  45096. /**
  45097. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45098. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45099. */
  45100. switchToBGR: boolean;
  45101. private _renderTargets;
  45102. private _reflectionControls;
  45103. private _white;
  45104. private _primaryShadowColor;
  45105. private _primaryHighlightColor;
  45106. /**
  45107. * Instantiates a Background Material in the given scene
  45108. * @param name The friendly name of the material
  45109. * @param scene The scene to add the material to
  45110. */
  45111. constructor(name: string, scene: Scene);
  45112. /**
  45113. * Gets a boolean indicating that current material needs to register RTT
  45114. */
  45115. readonly hasRenderTargetTextures: boolean;
  45116. /**
  45117. * The entire material has been created in order to prevent overdraw.
  45118. * @returns false
  45119. */
  45120. needAlphaTesting(): boolean;
  45121. /**
  45122. * The entire material has been created in order to prevent overdraw.
  45123. * @returns true if blending is enable
  45124. */
  45125. needAlphaBlending(): boolean;
  45126. /**
  45127. * Checks wether the material is ready to be rendered for a given mesh.
  45128. * @param mesh The mesh to render
  45129. * @param subMesh The submesh to check against
  45130. * @param useInstances Specify wether or not the material is used with instances
  45131. * @returns true if all the dependencies are ready (Textures, Effects...)
  45132. */
  45133. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45134. /**
  45135. * Compute the primary color according to the chosen perceptual color.
  45136. */
  45137. private _computePrimaryColorFromPerceptualColor;
  45138. /**
  45139. * Compute the highlights and shadow colors according to their chosen levels.
  45140. */
  45141. private _computePrimaryColors;
  45142. /**
  45143. * Build the uniform buffer used in the material.
  45144. */
  45145. buildUniformLayout(): void;
  45146. /**
  45147. * Unbind the material.
  45148. */
  45149. unbind(): void;
  45150. /**
  45151. * Bind only the world matrix to the material.
  45152. * @param world The world matrix to bind.
  45153. */
  45154. bindOnlyWorldMatrix(world: Matrix): void;
  45155. /**
  45156. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45157. * @param world The world matrix to bind.
  45158. * @param subMesh The submesh to bind for.
  45159. */
  45160. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45161. /**
  45162. * Dispose the material.
  45163. * @param forceDisposeEffect Force disposal of the associated effect.
  45164. * @param forceDisposeTextures Force disposal of the associated textures.
  45165. */
  45166. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45167. /**
  45168. * Clones the material.
  45169. * @param name The cloned name.
  45170. * @returns The cloned material.
  45171. */
  45172. clone(name: string): BackgroundMaterial;
  45173. /**
  45174. * Serializes the current material to its JSON representation.
  45175. * @returns The JSON representation.
  45176. */
  45177. serialize(): any;
  45178. /**
  45179. * Gets the class name of the material
  45180. * @returns "BackgroundMaterial"
  45181. */
  45182. getClassName(): string;
  45183. /**
  45184. * Parse a JSON input to create back a background material.
  45185. * @param source The JSON data to parse
  45186. * @param scene The scene to create the parsed material in
  45187. * @param rootUrl The root url of the assets the material depends upon
  45188. * @returns the instantiated BackgroundMaterial.
  45189. */
  45190. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45191. }
  45192. }
  45193. declare module BABYLON {
  45194. /**
  45195. * The Physically based material base class of BJS.
  45196. *
  45197. * This offers the main features of a standard PBR material.
  45198. * For more information, please refer to the documentation :
  45199. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45200. */
  45201. abstract class PBRBaseMaterial extends PushMaterial {
  45202. /**
  45203. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45204. */
  45205. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45206. /**
  45207. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45208. * to enhance interoperability with other engines.
  45209. */
  45210. static readonly LIGHTFALLOFF_GLTF: number;
  45211. /**
  45212. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45213. * to enhance interoperability with other materials.
  45214. */
  45215. static readonly LIGHTFALLOFF_STANDARD: number;
  45216. /**
  45217. * Intensity of the direct lights e.g. the four lights available in your scene.
  45218. * This impacts both the direct diffuse and specular highlights.
  45219. */
  45220. protected _directIntensity: number;
  45221. /**
  45222. * Intensity of the emissive part of the material.
  45223. * This helps controlling the emissive effect without modifying the emissive color.
  45224. */
  45225. protected _emissiveIntensity: number;
  45226. /**
  45227. * Intensity of the environment e.g. how much the environment will light the object
  45228. * either through harmonics for rough material or through the refelction for shiny ones.
  45229. */
  45230. protected _environmentIntensity: number;
  45231. /**
  45232. * This is a special control allowing the reduction of the specular highlights coming from the
  45233. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45234. */
  45235. protected _specularIntensity: number;
  45236. /**
  45237. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45238. */
  45239. private _lightingInfos;
  45240. /**
  45241. * Debug Control allowing disabling the bump map on this material.
  45242. */
  45243. protected _disableBumpMap: boolean;
  45244. /**
  45245. * AKA Diffuse Texture in standard nomenclature.
  45246. */
  45247. protected _albedoTexture: BaseTexture;
  45248. /**
  45249. * AKA Occlusion Texture in other nomenclature.
  45250. */
  45251. protected _ambientTexture: BaseTexture;
  45252. /**
  45253. * AKA Occlusion Texture Intensity in other nomenclature.
  45254. */
  45255. protected _ambientTextureStrength: number;
  45256. /**
  45257. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45258. * 1 means it completely occludes it
  45259. * 0 mean it has no impact
  45260. */
  45261. protected _ambientTextureImpactOnAnalyticalLights: number;
  45262. /**
  45263. * Stores the alpha values in a texture.
  45264. */
  45265. protected _opacityTexture: BaseTexture;
  45266. /**
  45267. * Stores the reflection values in a texture.
  45268. */
  45269. protected _reflectionTexture: BaseTexture;
  45270. /**
  45271. * Stores the refraction values in a texture.
  45272. */
  45273. protected _refractionTexture: BaseTexture;
  45274. /**
  45275. * Stores the emissive values in a texture.
  45276. */
  45277. protected _emissiveTexture: BaseTexture;
  45278. /**
  45279. * AKA Specular texture in other nomenclature.
  45280. */
  45281. protected _reflectivityTexture: BaseTexture;
  45282. /**
  45283. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45284. */
  45285. protected _metallicTexture: BaseTexture;
  45286. /**
  45287. * Specifies the metallic scalar of the metallic/roughness workflow.
  45288. * Can also be used to scale the metalness values of the metallic texture.
  45289. */
  45290. protected _metallic: Nullable<number>;
  45291. /**
  45292. * Specifies the roughness scalar of the metallic/roughness workflow.
  45293. * Can also be used to scale the roughness values of the metallic texture.
  45294. */
  45295. protected _roughness: Nullable<number>;
  45296. /**
  45297. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45298. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45299. */
  45300. protected _microSurfaceTexture: BaseTexture;
  45301. /**
  45302. * Stores surface normal data used to displace a mesh in a texture.
  45303. */
  45304. protected _bumpTexture: BaseTexture;
  45305. /**
  45306. * Stores the pre-calculated light information of a mesh in a texture.
  45307. */
  45308. protected _lightmapTexture: BaseTexture;
  45309. /**
  45310. * The color of a material in ambient lighting.
  45311. */
  45312. protected _ambientColor: Color3;
  45313. /**
  45314. * AKA Diffuse Color in other nomenclature.
  45315. */
  45316. protected _albedoColor: Color3;
  45317. /**
  45318. * AKA Specular Color in other nomenclature.
  45319. */
  45320. protected _reflectivityColor: Color3;
  45321. /**
  45322. * The color applied when light is reflected from a material.
  45323. */
  45324. protected _reflectionColor: Color3;
  45325. /**
  45326. * The color applied when light is emitted from a material.
  45327. */
  45328. protected _emissiveColor: Color3;
  45329. /**
  45330. * AKA Glossiness in other nomenclature.
  45331. */
  45332. protected _microSurface: number;
  45333. /**
  45334. * source material index of refraction (IOR)' / 'destination material IOR.
  45335. */
  45336. protected _indexOfRefraction: number;
  45337. /**
  45338. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45339. */
  45340. protected _invertRefractionY: boolean;
  45341. /**
  45342. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45343. * Materials half opaque for instance using refraction could benefit from this control.
  45344. */
  45345. protected _linkRefractionWithTransparency: boolean;
  45346. /**
  45347. * Specifies that the material will use the light map as a show map.
  45348. */
  45349. protected _useLightmapAsShadowmap: boolean;
  45350. /**
  45351. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45352. * makes the reflect vector face the model (under horizon).
  45353. */
  45354. protected _useHorizonOcclusion: boolean;
  45355. /**
  45356. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45357. * too much the area relying on ambient texture to define their ambient occlusion.
  45358. */
  45359. protected _useRadianceOcclusion: boolean;
  45360. /**
  45361. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45362. */
  45363. protected _useAlphaFromAlbedoTexture: boolean;
  45364. /**
  45365. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45366. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45367. */
  45368. protected _useSpecularOverAlpha: boolean;
  45369. /**
  45370. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45371. */
  45372. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45373. /**
  45374. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45375. */
  45376. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45377. /**
  45378. * Specifies if the metallic texture contains the roughness information in its green channel.
  45379. */
  45380. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45381. /**
  45382. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45383. */
  45384. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45385. /**
  45386. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45387. */
  45388. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45389. /**
  45390. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45391. */
  45392. protected _useAmbientInGrayScale: boolean;
  45393. /**
  45394. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45395. * The material will try to infer what glossiness each pixel should be.
  45396. */
  45397. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45398. /**
  45399. * Defines the falloff type used in this material.
  45400. * It by default is Physical.
  45401. */
  45402. protected _lightFalloff: number;
  45403. /**
  45404. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45405. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45406. */
  45407. protected _useRadianceOverAlpha: boolean;
  45408. /**
  45409. * Allows using an object space normal map (instead of tangent space).
  45410. */
  45411. protected _useObjectSpaceNormalMap: boolean;
  45412. /**
  45413. * Allows using the bump map in parallax mode.
  45414. */
  45415. protected _useParallax: boolean;
  45416. /**
  45417. * Allows using the bump map in parallax occlusion mode.
  45418. */
  45419. protected _useParallaxOcclusion: boolean;
  45420. /**
  45421. * Controls the scale bias of the parallax mode.
  45422. */
  45423. protected _parallaxScaleBias: number;
  45424. /**
  45425. * If sets to true, disables all the lights affecting the material.
  45426. */
  45427. protected _disableLighting: boolean;
  45428. /**
  45429. * Number of Simultaneous lights allowed on the material.
  45430. */
  45431. protected _maxSimultaneousLights: number;
  45432. /**
  45433. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45434. */
  45435. protected _invertNormalMapX: boolean;
  45436. /**
  45437. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45438. */
  45439. protected _invertNormalMapY: boolean;
  45440. /**
  45441. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45442. */
  45443. protected _twoSidedLighting: boolean;
  45444. /**
  45445. * Defines the alpha limits in alpha test mode.
  45446. */
  45447. protected _alphaCutOff: number;
  45448. /**
  45449. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45450. */
  45451. protected _forceAlphaTest: boolean;
  45452. /**
  45453. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45454. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45455. */
  45456. protected _useAlphaFresnel: boolean;
  45457. /**
  45458. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45459. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45460. */
  45461. protected _useLinearAlphaFresnel: boolean;
  45462. /**
  45463. * The transparency mode of the material.
  45464. */
  45465. protected _transparencyMode: Nullable<number>;
  45466. /**
  45467. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45468. * from cos thetav and roughness:
  45469. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45470. */
  45471. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45472. /**
  45473. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45474. */
  45475. protected _forceIrradianceInFragment: boolean;
  45476. /**
  45477. * Force normal to face away from face.
  45478. */
  45479. protected _forceNormalForward: boolean;
  45480. /**
  45481. * Enables specular anti aliasing in the PBR shader.
  45482. * It will both interacts on the Geometry for analytical and IBL lighting.
  45483. * It also prefilter the roughness map based on the bump values.
  45484. */
  45485. protected _enableSpecularAntiAliasing: boolean;
  45486. /**
  45487. * Default configuration related to image processing available in the PBR Material.
  45488. */
  45489. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45490. /**
  45491. * Keep track of the image processing observer to allow dispose and replace.
  45492. */
  45493. private _imageProcessingObserver;
  45494. /**
  45495. * Attaches a new image processing configuration to the PBR Material.
  45496. * @param configuration
  45497. */
  45498. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45499. /**
  45500. * Stores the available render targets.
  45501. */
  45502. private _renderTargets;
  45503. /**
  45504. * Sets the global ambient color for the material used in lighting calculations.
  45505. */
  45506. private _globalAmbientColor;
  45507. /**
  45508. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45509. */
  45510. private _useLogarithmicDepth;
  45511. /**
  45512. * If set to true, no lighting calculations will be applied.
  45513. */
  45514. private _unlit;
  45515. /**
  45516. * Instantiates a new PBRMaterial instance.
  45517. *
  45518. * @param name The material name
  45519. * @param scene The scene the material will be use in.
  45520. */
  45521. constructor(name: string, scene: Scene);
  45522. /**
  45523. * Gets a boolean indicating that current material needs to register RTT
  45524. */
  45525. readonly hasRenderTargetTextures: boolean;
  45526. /**
  45527. * Gets the name of the material class.
  45528. */
  45529. getClassName(): string;
  45530. /**
  45531. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45532. */
  45533. /**
  45534. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45535. */
  45536. useLogarithmicDepth: boolean;
  45537. /**
  45538. * Gets the current transparency mode.
  45539. */
  45540. /**
  45541. * Sets the transparency mode of the material.
  45542. *
  45543. * | Value | Type | Description |
  45544. * | ----- | ----------------------------------- | ----------- |
  45545. * | 0 | OPAQUE | |
  45546. * | 1 | ALPHATEST | |
  45547. * | 2 | ALPHABLEND | |
  45548. * | 3 | ALPHATESTANDBLEND | |
  45549. *
  45550. */
  45551. transparencyMode: Nullable<number>;
  45552. /**
  45553. * Returns true if alpha blending should be disabled.
  45554. */
  45555. private readonly _disableAlphaBlending;
  45556. /**
  45557. * Specifies whether or not this material should be rendered in alpha blend mode.
  45558. */
  45559. needAlphaBlending(): boolean;
  45560. /**
  45561. * Specifies if the mesh will require alpha blending.
  45562. * @param mesh - BJS mesh.
  45563. */
  45564. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45565. /**
  45566. * Specifies whether or not this material should be rendered in alpha test mode.
  45567. */
  45568. needAlphaTesting(): boolean;
  45569. /**
  45570. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45571. */
  45572. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45573. /**
  45574. * Gets the texture used for the alpha test.
  45575. */
  45576. getAlphaTestTexture(): BaseTexture;
  45577. /**
  45578. * Stores the reflectivity values based on metallic roughness workflow.
  45579. */
  45580. private static _scaledReflectivity;
  45581. /**
  45582. * Specifies that the submesh is ready to be used.
  45583. * @param mesh - BJS mesh.
  45584. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45585. * @param useInstances - Specifies that instances should be used.
  45586. * @returns - boolean indicating that the submesh is ready or not.
  45587. */
  45588. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45589. /**
  45590. * Specifies if the material uses metallic roughness workflow.
  45591. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45592. */
  45593. isMetallicWorkflow(): boolean;
  45594. private _prepareEffect;
  45595. private _prepareDefines;
  45596. /**
  45597. * Force shader compilation
  45598. */
  45599. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45600. clipPlane: boolean;
  45601. }>): void;
  45602. /**
  45603. * Initializes the uniform buffer layout for the shader.
  45604. */
  45605. buildUniformLayout(): void;
  45606. /**
  45607. * Unbinds the textures.
  45608. */
  45609. unbind(): void;
  45610. /**
  45611. * Binds the submesh data.
  45612. * @param world - The world matrix.
  45613. * @param mesh - The BJS mesh.
  45614. * @param subMesh - A submesh of the BJS mesh.
  45615. */
  45616. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45617. /**
  45618. * Returns the animatable textures.
  45619. * @returns - Array of animatable textures.
  45620. */
  45621. getAnimatables(): IAnimatable[];
  45622. /**
  45623. * Returns the texture used for reflections.
  45624. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45625. */
  45626. private _getReflectionTexture;
  45627. /**
  45628. * Returns the texture used for refraction or null if none is used.
  45629. * @returns - Refection texture if present. If no refraction texture and refraction
  45630. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45631. */
  45632. private _getRefractionTexture;
  45633. /**
  45634. * Disposes the resources of the material.
  45635. * @param forceDisposeEffect - Forces the disposal of effects.
  45636. * @param forceDisposeTextures - Forces the disposal of all textures.
  45637. */
  45638. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45639. }
  45640. }
  45641. declare module BABYLON {
  45642. /**
  45643. * The Physically based simple base material of BJS.
  45644. *
  45645. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45646. * It is used as the base class for both the specGloss and metalRough conventions.
  45647. */
  45648. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45649. /**
  45650. * Number of Simultaneous lights allowed on the material.
  45651. */
  45652. maxSimultaneousLights: number;
  45653. /**
  45654. * If sets to true, disables all the lights affecting the material.
  45655. */
  45656. disableLighting: boolean;
  45657. /**
  45658. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45659. */
  45660. environmentTexture: BaseTexture;
  45661. /**
  45662. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45663. */
  45664. invertNormalMapX: boolean;
  45665. /**
  45666. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45667. */
  45668. invertNormalMapY: boolean;
  45669. /**
  45670. * Normal map used in the model.
  45671. */
  45672. normalTexture: BaseTexture;
  45673. /**
  45674. * Emissivie color used to self-illuminate the model.
  45675. */
  45676. emissiveColor: Color3;
  45677. /**
  45678. * Emissivie texture used to self-illuminate the model.
  45679. */
  45680. emissiveTexture: BaseTexture;
  45681. /**
  45682. * Occlusion Channel Strenght.
  45683. */
  45684. occlusionStrength: number;
  45685. /**
  45686. * Occlusion Texture of the material (adding extra occlusion effects).
  45687. */
  45688. occlusionTexture: BaseTexture;
  45689. /**
  45690. * Defines the alpha limits in alpha test mode.
  45691. */
  45692. alphaCutOff: number;
  45693. /**
  45694. * Gets the current double sided mode.
  45695. */
  45696. /**
  45697. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45698. */
  45699. doubleSided: boolean;
  45700. /**
  45701. * Stores the pre-calculated light information of a mesh in a texture.
  45702. */
  45703. lightmapTexture: BaseTexture;
  45704. /**
  45705. * If true, the light map contains occlusion information instead of lighting info.
  45706. */
  45707. useLightmapAsShadowmap: boolean;
  45708. /**
  45709. * Return the active textures of the material.
  45710. */
  45711. getActiveTextures(): BaseTexture[];
  45712. hasTexture(texture: BaseTexture): boolean;
  45713. /**
  45714. * Instantiates a new PBRMaterial instance.
  45715. *
  45716. * @param name The material name
  45717. * @param scene The scene the material will be use in.
  45718. */
  45719. constructor(name: string, scene: Scene);
  45720. getClassName(): string;
  45721. }
  45722. }
  45723. declare module BABYLON {
  45724. /**
  45725. * The Physically based material of BJS.
  45726. *
  45727. * This offers the main features of a standard PBR material.
  45728. * For more information, please refer to the documentation :
  45729. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45730. */
  45731. class PBRMaterial extends PBRBaseMaterial {
  45732. /**
  45733. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45734. */
  45735. static readonly PBRMATERIAL_OPAQUE: number;
  45736. /**
  45737. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45738. */
  45739. static readonly PBRMATERIAL_ALPHATEST: number;
  45740. /**
  45741. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45742. */
  45743. static readonly PBRMATERIAL_ALPHABLEND: number;
  45744. /**
  45745. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45746. * They are also discarded below the alpha cutoff threshold to improve performances.
  45747. */
  45748. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45749. /**
  45750. * Defines the default value of how much AO map is occluding the analytical lights
  45751. * (point spot...).
  45752. */
  45753. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45754. /**
  45755. * Intensity of the direct lights e.g. the four lights available in your scene.
  45756. * This impacts both the direct diffuse and specular highlights.
  45757. */
  45758. directIntensity: number;
  45759. /**
  45760. * Intensity of the emissive part of the material.
  45761. * This helps controlling the emissive effect without modifying the emissive color.
  45762. */
  45763. emissiveIntensity: number;
  45764. /**
  45765. * Intensity of the environment e.g. how much the environment will light the object
  45766. * either through harmonics for rough material or through the refelction for shiny ones.
  45767. */
  45768. environmentIntensity: number;
  45769. /**
  45770. * This is a special control allowing the reduction of the specular highlights coming from the
  45771. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45772. */
  45773. specularIntensity: number;
  45774. /**
  45775. * Debug Control allowing disabling the bump map on this material.
  45776. */
  45777. disableBumpMap: boolean;
  45778. /**
  45779. * AKA Diffuse Texture in standard nomenclature.
  45780. */
  45781. albedoTexture: BaseTexture;
  45782. /**
  45783. * AKA Occlusion Texture in other nomenclature.
  45784. */
  45785. ambientTexture: BaseTexture;
  45786. /**
  45787. * AKA Occlusion Texture Intensity in other nomenclature.
  45788. */
  45789. ambientTextureStrength: number;
  45790. /**
  45791. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45792. * 1 means it completely occludes it
  45793. * 0 mean it has no impact
  45794. */
  45795. ambientTextureImpactOnAnalyticalLights: number;
  45796. /**
  45797. * Stores the alpha values in a texture.
  45798. */
  45799. opacityTexture: BaseTexture;
  45800. /**
  45801. * Stores the reflection values in a texture.
  45802. */
  45803. reflectionTexture: Nullable<BaseTexture>;
  45804. /**
  45805. * Stores the emissive values in a texture.
  45806. */
  45807. emissiveTexture: BaseTexture;
  45808. /**
  45809. * AKA Specular texture in other nomenclature.
  45810. */
  45811. reflectivityTexture: BaseTexture;
  45812. /**
  45813. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45814. */
  45815. metallicTexture: BaseTexture;
  45816. /**
  45817. * Specifies the metallic scalar of the metallic/roughness workflow.
  45818. * Can also be used to scale the metalness values of the metallic texture.
  45819. */
  45820. metallic: Nullable<number>;
  45821. /**
  45822. * Specifies the roughness scalar of the metallic/roughness workflow.
  45823. * Can also be used to scale the roughness values of the metallic texture.
  45824. */
  45825. roughness: Nullable<number>;
  45826. /**
  45827. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45828. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45829. */
  45830. microSurfaceTexture: BaseTexture;
  45831. /**
  45832. * Stores surface normal data used to displace a mesh in a texture.
  45833. */
  45834. bumpTexture: BaseTexture;
  45835. /**
  45836. * Stores the pre-calculated light information of a mesh in a texture.
  45837. */
  45838. lightmapTexture: BaseTexture;
  45839. /**
  45840. * Stores the refracted light information in a texture.
  45841. */
  45842. refractionTexture: BaseTexture;
  45843. /**
  45844. * The color of a material in ambient lighting.
  45845. */
  45846. ambientColor: Color3;
  45847. /**
  45848. * AKA Diffuse Color in other nomenclature.
  45849. */
  45850. albedoColor: Color3;
  45851. /**
  45852. * AKA Specular Color in other nomenclature.
  45853. */
  45854. reflectivityColor: Color3;
  45855. /**
  45856. * The color reflected from the material.
  45857. */
  45858. reflectionColor: Color3;
  45859. /**
  45860. * The color emitted from the material.
  45861. */
  45862. emissiveColor: Color3;
  45863. /**
  45864. * AKA Glossiness in other nomenclature.
  45865. */
  45866. microSurface: number;
  45867. /**
  45868. * source material index of refraction (IOR)' / 'destination material IOR.
  45869. */
  45870. indexOfRefraction: number;
  45871. /**
  45872. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45873. */
  45874. invertRefractionY: boolean;
  45875. /**
  45876. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45877. * Materials half opaque for instance using refraction could benefit from this control.
  45878. */
  45879. linkRefractionWithTransparency: boolean;
  45880. /**
  45881. * If true, the light map contains occlusion information instead of lighting info.
  45882. */
  45883. useLightmapAsShadowmap: boolean;
  45884. /**
  45885. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45886. */
  45887. useAlphaFromAlbedoTexture: boolean;
  45888. /**
  45889. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45890. */
  45891. forceAlphaTest: boolean;
  45892. /**
  45893. * Defines the alpha limits in alpha test mode.
  45894. */
  45895. alphaCutOff: number;
  45896. /**
  45897. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45898. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45899. */
  45900. useSpecularOverAlpha: boolean;
  45901. /**
  45902. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45903. */
  45904. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45905. /**
  45906. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45907. */
  45908. useRoughnessFromMetallicTextureAlpha: boolean;
  45909. /**
  45910. * Specifies if the metallic texture contains the roughness information in its green channel.
  45911. */
  45912. useRoughnessFromMetallicTextureGreen: boolean;
  45913. /**
  45914. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45915. */
  45916. useMetallnessFromMetallicTextureBlue: boolean;
  45917. /**
  45918. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45919. */
  45920. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45921. /**
  45922. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45923. */
  45924. useAmbientInGrayScale: boolean;
  45925. /**
  45926. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45927. * The material will try to infer what glossiness each pixel should be.
  45928. */
  45929. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45930. /**
  45931. * BJS is using an harcoded light falloff based on a manually sets up range.
  45932. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45933. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45934. */
  45935. /**
  45936. * BJS is using an harcoded light falloff based on a manually sets up range.
  45937. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45938. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45939. */
  45940. usePhysicalLightFalloff: boolean;
  45941. /**
  45942. * In order to support the falloff compatibility with gltf, a special mode has been added
  45943. * to reproduce the gltf light falloff.
  45944. */
  45945. /**
  45946. * In order to support the falloff compatibility with gltf, a special mode has been added
  45947. * to reproduce the gltf light falloff.
  45948. */
  45949. useGLTFLightFalloff: boolean;
  45950. /**
  45951. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45952. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45953. */
  45954. useRadianceOverAlpha: boolean;
  45955. /**
  45956. * Allows using an object space normal map (instead of tangent space).
  45957. */
  45958. useObjectSpaceNormalMap: boolean;
  45959. /**
  45960. * Allows using the bump map in parallax mode.
  45961. */
  45962. useParallax: boolean;
  45963. /**
  45964. * Allows using the bump map in parallax occlusion mode.
  45965. */
  45966. useParallaxOcclusion: boolean;
  45967. /**
  45968. * Controls the scale bias of the parallax mode.
  45969. */
  45970. parallaxScaleBias: number;
  45971. /**
  45972. * If sets to true, disables all the lights affecting the material.
  45973. */
  45974. disableLighting: boolean;
  45975. /**
  45976. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45977. */
  45978. forceIrradianceInFragment: boolean;
  45979. /**
  45980. * Number of Simultaneous lights allowed on the material.
  45981. */
  45982. maxSimultaneousLights: number;
  45983. /**
  45984. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45985. */
  45986. invertNormalMapX: boolean;
  45987. /**
  45988. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45989. */
  45990. invertNormalMapY: boolean;
  45991. /**
  45992. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45993. */
  45994. twoSidedLighting: boolean;
  45995. /**
  45996. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45997. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45998. */
  45999. useAlphaFresnel: boolean;
  46000. /**
  46001. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46002. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46003. */
  46004. useLinearAlphaFresnel: boolean;
  46005. /**
  46006. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46007. * And/Or occlude the blended part.
  46008. */
  46009. environmentBRDFTexture: Nullable<BaseTexture>;
  46010. /**
  46011. * Force normal to face away from face.
  46012. */
  46013. forceNormalForward: boolean;
  46014. /**
  46015. * Enables specular anti aliasing in the PBR shader.
  46016. * It will both interacts on the Geometry for analytical and IBL lighting.
  46017. * It also prefilter the roughness map based on the bump values.
  46018. */
  46019. enableSpecularAntiAliasing: boolean;
  46020. /**
  46021. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46022. * makes the reflect vector face the model (under horizon).
  46023. */
  46024. useHorizonOcclusion: boolean;
  46025. /**
  46026. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46027. * too much the area relying on ambient texture to define their ambient occlusion.
  46028. */
  46029. useRadianceOcclusion: boolean;
  46030. /**
  46031. * If set to true, no lighting calculations will be applied.
  46032. */
  46033. unlit: boolean;
  46034. /**
  46035. * Gets the image processing configuration used either in this material.
  46036. */
  46037. /**
  46038. * Sets the Default image processing configuration used either in the this material.
  46039. *
  46040. * If sets to null, the scene one is in use.
  46041. */
  46042. imageProcessingConfiguration: ImageProcessingConfiguration;
  46043. /**
  46044. * Gets wether the color curves effect is enabled.
  46045. */
  46046. /**
  46047. * Sets wether the color curves effect is enabled.
  46048. */
  46049. cameraColorCurvesEnabled: boolean;
  46050. /**
  46051. * Gets wether the color grading effect is enabled.
  46052. */
  46053. /**
  46054. * Gets wether the color grading effect is enabled.
  46055. */
  46056. cameraColorGradingEnabled: boolean;
  46057. /**
  46058. * Gets wether tonemapping is enabled or not.
  46059. */
  46060. /**
  46061. * Sets wether tonemapping is enabled or not
  46062. */
  46063. cameraToneMappingEnabled: boolean;
  46064. /**
  46065. * The camera exposure used on this material.
  46066. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46067. * This corresponds to a photographic exposure.
  46068. */
  46069. /**
  46070. * The camera exposure used on this material.
  46071. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46072. * This corresponds to a photographic exposure.
  46073. */
  46074. cameraExposure: number;
  46075. /**
  46076. * Gets The camera contrast used on this material.
  46077. */
  46078. /**
  46079. * Sets The camera contrast used on this material.
  46080. */
  46081. cameraContrast: number;
  46082. /**
  46083. * Gets the Color Grading 2D Lookup Texture.
  46084. */
  46085. /**
  46086. * Sets the Color Grading 2D Lookup Texture.
  46087. */
  46088. cameraColorGradingTexture: Nullable<BaseTexture>;
  46089. /**
  46090. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46091. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46092. * 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;
  46093. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46094. */
  46095. /**
  46096. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46097. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46098. * 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;
  46099. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46100. */
  46101. cameraColorCurves: Nullable<ColorCurves>;
  46102. /**
  46103. * Instantiates a new PBRMaterial instance.
  46104. *
  46105. * @param name The material name
  46106. * @param scene The scene the material will be use in.
  46107. */
  46108. constructor(name: string, scene: Scene);
  46109. /**
  46110. * Returns the name of this material class.
  46111. */
  46112. getClassName(): string;
  46113. /**
  46114. * Returns an array of the actively used textures.
  46115. * @returns - Array of BaseTextures
  46116. */
  46117. getActiveTextures(): BaseTexture[];
  46118. /**
  46119. * Checks to see if a texture is used in the material.
  46120. * @param texture - Base texture to use.
  46121. * @returns - Boolean specifying if a texture is used in the material.
  46122. */
  46123. hasTexture(texture: BaseTexture): boolean;
  46124. /**
  46125. * Makes a duplicate of the current material.
  46126. * @param name - name to use for the new material.
  46127. */
  46128. clone(name: string): PBRMaterial;
  46129. /**
  46130. * Serializes this PBR Material.
  46131. * @returns - An object with the serialized material.
  46132. */
  46133. serialize(): any;
  46134. /**
  46135. * Parses a PBR Material from a serialized object.
  46136. * @param source - Serialized object.
  46137. * @param scene - BJS scene instance.
  46138. * @param rootUrl - url for the scene object
  46139. * @returns - PBRMaterial
  46140. */
  46141. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46142. }
  46143. }
  46144. declare module BABYLON {
  46145. /**
  46146. * The PBR material of BJS following the metal roughness convention.
  46147. *
  46148. * This fits to the PBR convention in the GLTF definition:
  46149. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  46150. */
  46151. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  46152. /**
  46153. * The base color has two different interpretations depending on the value of metalness.
  46154. * When the material is a metal, the base color is the specific measured reflectance value
  46155. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  46156. * of the material.
  46157. */
  46158. baseColor: Color3;
  46159. /**
  46160. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  46161. * well as opacity information in the alpha channel.
  46162. */
  46163. baseTexture: BaseTexture;
  46164. /**
  46165. * Specifies the metallic scalar value of the material.
  46166. * Can also be used to scale the metalness values of the metallic texture.
  46167. */
  46168. metallic: number;
  46169. /**
  46170. * Specifies the roughness scalar value of the material.
  46171. * Can also be used to scale the roughness values of the metallic texture.
  46172. */
  46173. roughness: number;
  46174. /**
  46175. * Texture containing both the metallic value in the B channel and the
  46176. * roughness value in the G channel to keep better precision.
  46177. */
  46178. metallicRoughnessTexture: BaseTexture;
  46179. /**
  46180. * Instantiates a new PBRMetalRoughnessMaterial instance.
  46181. *
  46182. * @param name The material name
  46183. * @param scene The scene the material will be use in.
  46184. */
  46185. constructor(name: string, scene: Scene);
  46186. /**
  46187. * Return the currrent class name of the material.
  46188. */
  46189. getClassName(): string;
  46190. /**
  46191. * Return the active textures of the material.
  46192. */
  46193. getActiveTextures(): BaseTexture[];
  46194. /**
  46195. * Checks to see if a texture is used in the material.
  46196. * @param texture - Base texture to use.
  46197. * @returns - Boolean specifying if a texture is used in the material.
  46198. */
  46199. hasTexture(texture: BaseTexture): boolean;
  46200. /**
  46201. * Makes a duplicate of the current material.
  46202. * @param name - name to use for the new material.
  46203. */
  46204. clone(name: string): PBRMetallicRoughnessMaterial;
  46205. /**
  46206. * Serialize the material to a parsable JSON object.
  46207. */
  46208. serialize(): any;
  46209. /**
  46210. * Parses a JSON object correponding to the serialize function.
  46211. */
  46212. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  46213. }
  46214. }
  46215. declare module BABYLON {
  46216. /**
  46217. * The PBR material of BJS following the specular glossiness convention.
  46218. *
  46219. * This fits to the PBR convention in the GLTF definition:
  46220. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  46221. */
  46222. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  46223. /**
  46224. * Specifies the diffuse color of the material.
  46225. */
  46226. diffuseColor: Color3;
  46227. /**
  46228. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  46229. * channel.
  46230. */
  46231. diffuseTexture: BaseTexture;
  46232. /**
  46233. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  46234. */
  46235. specularColor: Color3;
  46236. /**
  46237. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  46238. */
  46239. glossiness: number;
  46240. /**
  46241. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  46242. */
  46243. specularGlossinessTexture: BaseTexture;
  46244. /**
  46245. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  46246. *
  46247. * @param name The material name
  46248. * @param scene The scene the material will be use in.
  46249. */
  46250. constructor(name: string, scene: Scene);
  46251. /**
  46252. * Return the currrent class name of the material.
  46253. */
  46254. getClassName(): string;
  46255. /**
  46256. * Return the active textures of the material.
  46257. */
  46258. getActiveTextures(): BaseTexture[];
  46259. /**
  46260. * Checks to see if a texture is used in the material.
  46261. * @param texture - Base texture to use.
  46262. * @returns - Boolean specifying if a texture is used in the material.
  46263. */
  46264. hasTexture(texture: BaseTexture): boolean;
  46265. /**
  46266. * Makes a duplicate of the current material.
  46267. * @param name - name to use for the new material.
  46268. */
  46269. clone(name: string): PBRSpecularGlossinessMaterial;
  46270. /**
  46271. * Serialize the material to a parsable JSON object.
  46272. */
  46273. serialize(): any;
  46274. /**
  46275. * Parses a JSON object correponding to the serialize function.
  46276. */
  46277. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  46278. }
  46279. }
  46280. declare module BABYLON {
  46281. /**
  46282. * Base class of all the textures in babylon.
  46283. * It groups all the common properties the materials, post process, lights... might need
  46284. * in order to make a correct use of the texture.
  46285. */
  46286. class BaseTexture {
  46287. /**
  46288. * Default anisotropic filtering level for the application.
  46289. * It is set to 4 as a good tradeoff between perf and quality.
  46290. */
  46291. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  46292. /**
  46293. * Gets or sets the unique id of the texture
  46294. */
  46295. uniqueId: number;
  46296. /**
  46297. * Define the name of the texture.
  46298. */
  46299. name: string;
  46300. /**
  46301. * Gets or sets an object used to store user defined information.
  46302. */
  46303. metadata: any;
  46304. /**
  46305. * For internal use only. Please do not use.
  46306. */
  46307. reservedDataStore: any;
  46308. private _hasAlpha;
  46309. /**
  46310. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  46311. */
  46312. hasAlpha: boolean;
  46313. /**
  46314. * Defines if the alpha value should be determined via the rgb values.
  46315. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  46316. */
  46317. getAlphaFromRGB: boolean;
  46318. /**
  46319. * Intensity or strength of the texture.
  46320. * It is commonly used by materials to fine tune the intensity of the texture
  46321. */
  46322. level: number;
  46323. /**
  46324. * Define the UV chanel to use starting from 0 and defaulting to 0.
  46325. * This is part of the texture as textures usually maps to one uv set.
  46326. */
  46327. coordinatesIndex: number;
  46328. private _coordinatesMode;
  46329. /**
  46330. * How a texture is mapped.
  46331. *
  46332. * | Value | Type | Description |
  46333. * | ----- | ----------------------------------- | ----------- |
  46334. * | 0 | EXPLICIT_MODE | |
  46335. * | 1 | SPHERICAL_MODE | |
  46336. * | 2 | PLANAR_MODE | |
  46337. * | 3 | CUBIC_MODE | |
  46338. * | 4 | PROJECTION_MODE | |
  46339. * | 5 | SKYBOX_MODE | |
  46340. * | 6 | INVCUBIC_MODE | |
  46341. * | 7 | EQUIRECTANGULAR_MODE | |
  46342. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  46343. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  46344. */
  46345. coordinatesMode: number;
  46346. /**
  46347. * | Value | Type | Description |
  46348. * | ----- | ------------------ | ----------- |
  46349. * | 0 | CLAMP_ADDRESSMODE | |
  46350. * | 1 | WRAP_ADDRESSMODE | |
  46351. * | 2 | MIRROR_ADDRESSMODE | |
  46352. */
  46353. wrapU: number;
  46354. /**
  46355. * | Value | Type | Description |
  46356. * | ----- | ------------------ | ----------- |
  46357. * | 0 | CLAMP_ADDRESSMODE | |
  46358. * | 1 | WRAP_ADDRESSMODE | |
  46359. * | 2 | MIRROR_ADDRESSMODE | |
  46360. */
  46361. wrapV: number;
  46362. /**
  46363. * | Value | Type | Description |
  46364. * | ----- | ------------------ | ----------- |
  46365. * | 0 | CLAMP_ADDRESSMODE | |
  46366. * | 1 | WRAP_ADDRESSMODE | |
  46367. * | 2 | MIRROR_ADDRESSMODE | |
  46368. */
  46369. wrapR: number;
  46370. /**
  46371. * With compliant hardware and browser (supporting anisotropic filtering)
  46372. * this defines the level of anisotropic filtering in the texture.
  46373. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  46374. */
  46375. anisotropicFilteringLevel: number;
  46376. /**
  46377. * Define if the texture is a cube texture or if false a 2d texture.
  46378. */
  46379. isCube: boolean;
  46380. /**
  46381. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  46382. */
  46383. is3D: boolean;
  46384. /**
  46385. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  46386. * HDR texture are usually stored in linear space.
  46387. * This only impacts the PBR and Background materials
  46388. */
  46389. gammaSpace: boolean;
  46390. /**
  46391. * Gets whether or not the texture contains RGBD data.
  46392. */
  46393. readonly isRGBD: boolean;
  46394. /**
  46395. * Is Z inverted in the texture (useful in a cube texture).
  46396. */
  46397. invertZ: boolean;
  46398. /**
  46399. * Are mip maps generated for this texture or not.
  46400. */
  46401. readonly noMipmap: boolean;
  46402. /**
  46403. * @hidden
  46404. */
  46405. lodLevelInAlpha: boolean;
  46406. /**
  46407. * With prefiltered texture, defined the offset used during the prefiltering steps.
  46408. */
  46409. lodGenerationOffset: number;
  46410. /**
  46411. * With prefiltered texture, defined the scale used during the prefiltering steps.
  46412. */
  46413. lodGenerationScale: number;
  46414. /**
  46415. * Define if the texture is a render target.
  46416. */
  46417. isRenderTarget: boolean;
  46418. /**
  46419. * Define the unique id of the texture in the scene.
  46420. */
  46421. readonly uid: string;
  46422. /**
  46423. * Return a string representation of the texture.
  46424. * @returns the texture as a string
  46425. */
  46426. toString(): string;
  46427. /**
  46428. * Get the class name of the texture.
  46429. * @returns "BaseTexture"
  46430. */
  46431. getClassName(): string;
  46432. /**
  46433. * Define the list of animation attached to the texture.
  46434. */
  46435. animations: Animation[];
  46436. /**
  46437. * An event triggered when the texture is disposed.
  46438. */
  46439. onDisposeObservable: Observable<BaseTexture>;
  46440. private _onDisposeObserver;
  46441. /**
  46442. * Callback triggered when the texture has been disposed.
  46443. * Kept for back compatibility, you can use the onDisposeObservable instead.
  46444. */
  46445. onDispose: () => void;
  46446. /**
  46447. * Define the current state of the loading sequence when in delayed load mode.
  46448. */
  46449. delayLoadState: number;
  46450. private _scene;
  46451. /** @hidden */
  46452. _samplingMode: number;
  46453. /** @hidden */
  46454. _texture: Nullable<InternalTexture>;
  46455. private _uid;
  46456. /**
  46457. * Define if the texture is preventinga material to render or not.
  46458. * If not and the texture is not ready, the engine will use a default black texture instead.
  46459. */
  46460. readonly isBlocking: boolean;
  46461. /**
  46462. * Instantiates a new BaseTexture.
  46463. * Base class of all the textures in babylon.
  46464. * It groups all the common properties the materials, post process, lights... might need
  46465. * in order to make a correct use of the texture.
  46466. * @param scene Define the scene the texture blongs to
  46467. */
  46468. constructor(scene: Nullable<Scene>);
  46469. /**
  46470. * Get the scene the texture belongs to.
  46471. * @returns the scene or null if undefined
  46472. */
  46473. getScene(): Nullable<Scene>;
  46474. /**
  46475. * Get the texture transform matrix used to offset tile the texture for istance.
  46476. * @returns the transformation matrix
  46477. */
  46478. getTextureMatrix(): Matrix;
  46479. /**
  46480. * Get the texture reflection matrix used to rotate/transform the reflection.
  46481. * @returns the reflection matrix
  46482. */
  46483. getReflectionTextureMatrix(): Matrix;
  46484. /**
  46485. * Get the underlying lower level texture from Babylon.
  46486. * @returns the insternal texture
  46487. */
  46488. getInternalTexture(): Nullable<InternalTexture>;
  46489. /**
  46490. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  46491. * @returns true if ready or not blocking
  46492. */
  46493. isReadyOrNotBlocking(): boolean;
  46494. /**
  46495. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  46496. * @returns true if fully ready
  46497. */
  46498. isReady(): boolean;
  46499. private _cachedSize;
  46500. /**
  46501. * Get the size of the texture.
  46502. * @returns the texture size.
  46503. */
  46504. getSize(): ISize;
  46505. /**
  46506. * Get the base size of the texture.
  46507. * It can be different from the size if the texture has been resized for POT for instance
  46508. * @returns the base size
  46509. */
  46510. getBaseSize(): ISize;
  46511. /**
  46512. * Update the sampling mode of the texture.
  46513. * Default is Trilinear mode.
  46514. *
  46515. * | Value | Type | Description |
  46516. * | ----- | ------------------ | ----------- |
  46517. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  46518. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  46519. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  46520. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  46521. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  46522. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  46523. * | 7 | NEAREST_LINEAR | |
  46524. * | 8 | NEAREST_NEAREST | |
  46525. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  46526. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  46527. * | 11 | LINEAR_LINEAR | |
  46528. * | 12 | LINEAR_NEAREST | |
  46529. *
  46530. * > _mag_: magnification filter (close to the viewer)
  46531. * > _min_: minification filter (far from the viewer)
  46532. * > _mip_: filter used between mip map levels
  46533. *@param samplingMode Define the new sampling mode of the texture
  46534. */
  46535. updateSamplingMode(samplingMode: number): void;
  46536. /**
  46537. * Scales the texture if is `canRescale()`
  46538. * @param ratio the resize factor we want to use to rescale
  46539. */
  46540. scale(ratio: number): void;
  46541. /**
  46542. * Get if the texture can rescale.
  46543. */
  46544. readonly canRescale: boolean;
  46545. /** @hidden */
  46546. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  46547. /** @hidden */
  46548. _rebuild(): void;
  46549. /**
  46550. * Triggers the load sequence in delayed load mode.
  46551. */
  46552. delayLoad(): void;
  46553. /**
  46554. * Clones the texture.
  46555. * @returns the cloned texture
  46556. */
  46557. clone(): Nullable<BaseTexture>;
  46558. /**
  46559. * Get the texture underlying type (INT, FLOAT...)
  46560. */
  46561. readonly textureType: number;
  46562. /**
  46563. * Get the texture underlying format (RGB, RGBA...)
  46564. */
  46565. readonly textureFormat: number;
  46566. /**
  46567. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  46568. * This will returns an RGBA array buffer containing either in values (0-255) or
  46569. * float values (0-1) depending of the underlying buffer type.
  46570. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  46571. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  46572. * @param buffer defines a user defined buffer to fill with data (can be null)
  46573. * @returns The Array buffer containing the pixels data.
  46574. */
  46575. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  46576. /**
  46577. * Release and destroy the underlying lower level texture aka internalTexture.
  46578. */
  46579. releaseInternalTexture(): void;
  46580. /**
  46581. * Get the polynomial representation of the texture data.
  46582. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46583. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46584. */
  46585. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46586. /** @hidden */
  46587. readonly _lodTextureHigh: Nullable<BaseTexture>;
  46588. /** @hidden */
  46589. readonly _lodTextureMid: Nullable<BaseTexture>;
  46590. /** @hidden */
  46591. readonly _lodTextureLow: Nullable<BaseTexture>;
  46592. /**
  46593. * Dispose the texture and release its associated resources.
  46594. */
  46595. dispose(): void;
  46596. /**
  46597. * Serialize the texture into a JSON representation that can be parsed later on.
  46598. * @returns the JSON representation of the texture
  46599. */
  46600. serialize(): any;
  46601. /**
  46602. * Helper function to be called back once a list of texture contains only ready textures.
  46603. * @param textures Define the list of textures to wait for
  46604. * @param callback Define the callback triggered once the entire list will be ready
  46605. */
  46606. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  46607. }
  46608. }
  46609. declare module BABYLON {
  46610. /**
  46611. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46612. * It can help converting any input color in a desired output one. This can then be used to create effects
  46613. * from sepia, black and white to sixties or futuristic rendering...
  46614. *
  46615. * The only supported format is currently 3dl.
  46616. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46617. */
  46618. class ColorGradingTexture extends BaseTexture {
  46619. /**
  46620. * The current texture matrix. (will always be identity in color grading texture)
  46621. */
  46622. private _textureMatrix;
  46623. /**
  46624. * The texture URL.
  46625. */
  46626. url: string;
  46627. /**
  46628. * Empty line regex stored for GC.
  46629. */
  46630. private static _noneEmptyLineRegex;
  46631. private _engine;
  46632. /**
  46633. * Instantiates a ColorGradingTexture from the following parameters.
  46634. *
  46635. * @param url The location of the color gradind data (currently only supporting 3dl)
  46636. * @param scene The scene the texture will be used in
  46637. */
  46638. constructor(url: string, scene: Scene);
  46639. /**
  46640. * Returns the texture matrix used in most of the material.
  46641. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46642. */
  46643. getTextureMatrix(): Matrix;
  46644. /**
  46645. * Occurs when the file being loaded is a .3dl LUT file.
  46646. */
  46647. private load3dlTexture;
  46648. /**
  46649. * Starts the loading process of the texture.
  46650. */
  46651. private loadTexture;
  46652. /**
  46653. * Clones the color gradind texture.
  46654. */
  46655. clone(): ColorGradingTexture;
  46656. /**
  46657. * Called during delayed load for textures.
  46658. */
  46659. delayLoad(): void;
  46660. /**
  46661. * Parses a color grading texture serialized by Babylon.
  46662. * @param parsedTexture The texture information being parsedTexture
  46663. * @param scene The scene to load the texture in
  46664. * @param rootUrl The root url of the data assets to load
  46665. * @return A color gradind texture
  46666. */
  46667. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  46668. /**
  46669. * Serializes the LUT texture to json format.
  46670. */
  46671. serialize(): any;
  46672. }
  46673. }
  46674. declare module BABYLON {
  46675. /**
  46676. * Class for creating a cube texture
  46677. */
  46678. class CubeTexture extends BaseTexture {
  46679. private _delayedOnLoad;
  46680. /**
  46681. * The url of the texture
  46682. */
  46683. url: string;
  46684. /**
  46685. * Gets or sets the center of the bounding box associated with the cube texture.
  46686. * It must define where the camera used to render the texture was set
  46687. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46688. */
  46689. boundingBoxPosition: Vector3;
  46690. private _boundingBoxSize;
  46691. /**
  46692. * Gets or sets the size of the bounding box associated with the cube texture
  46693. * When defined, the cubemap will switch to local mode
  46694. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46695. * @example https://www.babylonjs-playground.com/#RNASML
  46696. */
  46697. /**
  46698. * Returns the bounding box size
  46699. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46700. */
  46701. boundingBoxSize: Vector3;
  46702. protected _rotationY: number;
  46703. /**
  46704. * Sets texture matrix rotation angle around Y axis in radians.
  46705. */
  46706. /**
  46707. * Gets texture matrix rotation angle around Y axis radians.
  46708. */
  46709. rotationY: number;
  46710. /**
  46711. * Are mip maps generated for this texture or not.
  46712. */
  46713. readonly noMipmap: boolean;
  46714. private _noMipmap;
  46715. private _files;
  46716. private _extensions;
  46717. private _textureMatrix;
  46718. private _format;
  46719. private _createPolynomials;
  46720. /** @hidden */
  46721. _prefiltered: boolean;
  46722. /**
  46723. * Creates a cube texture from an array of image urls
  46724. * @param files defines an array of image urls
  46725. * @param scene defines the hosting scene
  46726. * @param noMipmap specifies if mip maps are not used
  46727. * @returns a cube texture
  46728. */
  46729. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  46730. /**
  46731. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  46732. * @param url defines the url of the prefiltered texture
  46733. * @param scene defines the scene the texture is attached to
  46734. * @param forcedExtension defines the extension of the file if different from the url
  46735. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46736. * @return the prefiltered texture
  46737. */
  46738. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  46739. /**
  46740. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  46741. * as prefiltered data.
  46742. * @param rootUrl defines the url of the texture or the root name of the six images
  46743. * @param scene defines the scene the texture is attached to
  46744. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  46745. * @param noMipmap defines if mipmaps should be created or not
  46746. * @param files defines the six files to load for the different faces
  46747. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  46748. * @param onError defines a callback triggered in case of error during load
  46749. * @param format defines the internal format to use for the texture once loaded
  46750. * @param prefiltered defines whether or not the texture is created from prefiltered data
  46751. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  46752. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46753. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46754. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46755. * @return the cube texture
  46756. */
  46757. 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);
  46758. /**
  46759. * Get the current class name of the texture useful for serialization or dynamic coding.
  46760. * @returns "CubeTexture"
  46761. */
  46762. getClassName(): string;
  46763. /**
  46764. * Update the url (and optional buffer) of this texture if url was null during construction.
  46765. * @param url the url of the texture
  46766. * @param forcedExtension defines the extension to use
  46767. * @param onLoad callback called when the texture is loaded (defaults to null)
  46768. */
  46769. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  46770. /**
  46771. * Delays loading of the cube texture
  46772. * @param forcedExtension defines the extension to use
  46773. */
  46774. delayLoad(forcedExtension?: string): void;
  46775. /**
  46776. * Returns the reflection texture matrix
  46777. * @returns the reflection texture matrix
  46778. */
  46779. getReflectionTextureMatrix(): Matrix;
  46780. /**
  46781. * Sets the reflection texture matrix
  46782. * @param value Reflection texture matrix
  46783. */
  46784. setReflectionTextureMatrix(value: Matrix): void;
  46785. /**
  46786. * Parses text to create a cube texture
  46787. * @param parsedTexture define the serialized text to read from
  46788. * @param scene defines the hosting scene
  46789. * @param rootUrl defines the root url of the cube texture
  46790. * @returns a cube texture
  46791. */
  46792. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  46793. /**
  46794. * Makes a clone, or deep copy, of the cube texture
  46795. * @returns a new cube texture
  46796. */
  46797. clone(): CubeTexture;
  46798. }
  46799. }
  46800. declare module BABYLON {
  46801. /**
  46802. * A class extending Texture allowing drawing on a texture
  46803. * @see http://doc.babylonjs.com/how_to/dynamictexture
  46804. */
  46805. class DynamicTexture extends Texture {
  46806. private _generateMipMaps;
  46807. private _canvas;
  46808. private _context;
  46809. private _engine;
  46810. /**
  46811. * Creates a DynamicTexture
  46812. * @param name defines the name of the texture
  46813. * @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
  46814. * @param scene defines the scene where you want the texture
  46815. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46816. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46817. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  46818. */
  46819. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46820. /**
  46821. * Get the current class name of the texture useful for serialization or dynamic coding.
  46822. * @returns "DynamicTexture"
  46823. */
  46824. getClassName(): string;
  46825. /**
  46826. * Gets the current state of canRescale
  46827. */
  46828. readonly canRescale: boolean;
  46829. private _recreate;
  46830. /**
  46831. * Scales the texture
  46832. * @param ratio the scale factor to apply to both width and height
  46833. */
  46834. scale(ratio: number): void;
  46835. /**
  46836. * Resizes the texture
  46837. * @param width the new width
  46838. * @param height the new height
  46839. */
  46840. scaleTo(width: number, height: number): void;
  46841. /**
  46842. * Gets the context of the canvas used by the texture
  46843. * @returns the canvas context of the dynamic texture
  46844. */
  46845. getContext(): CanvasRenderingContext2D;
  46846. /**
  46847. * Clears the texture
  46848. */
  46849. clear(): void;
  46850. /**
  46851. * Updates the texture
  46852. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46853. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46854. */
  46855. update(invertY?: boolean, premulAlpha?: boolean): void;
  46856. /**
  46857. * Draws text onto the texture
  46858. * @param text defines the text to be drawn
  46859. * @param x defines the placement of the text from the left
  46860. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46861. * @param font defines the font to be used with font-style, font-size, font-name
  46862. * @param color defines the color used for the text
  46863. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46864. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46865. * @param update defines whether texture is immediately update (default is true)
  46866. */
  46867. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  46868. /**
  46869. * Clones the texture
  46870. * @returns the clone of the texture.
  46871. */
  46872. clone(): DynamicTexture;
  46873. /**
  46874. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46875. * @returns a serialized dynamic texture object
  46876. */
  46877. serialize(): any;
  46878. /** @hidden */
  46879. _rebuild(): void;
  46880. }
  46881. }
  46882. declare module BABYLON {
  46883. /**
  46884. * This represents a texture coming from an HDR input.
  46885. *
  46886. * The only supported format is currently panorama picture stored in RGBE format.
  46887. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46888. */
  46889. class HDRCubeTexture extends BaseTexture {
  46890. private static _facesMapping;
  46891. private _generateHarmonics;
  46892. private _noMipmap;
  46893. private _textureMatrix;
  46894. private _size;
  46895. private _onLoad;
  46896. private _onError;
  46897. /**
  46898. * The texture URL.
  46899. */
  46900. url: string;
  46901. /**
  46902. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46903. */
  46904. coordinatesMode: number;
  46905. protected _isBlocking: boolean;
  46906. /**
  46907. * Sets wether or not the texture is blocking during loading.
  46908. */
  46909. /**
  46910. * Gets wether or not the texture is blocking during loading.
  46911. */
  46912. isBlocking: boolean;
  46913. protected _rotationY: number;
  46914. /**
  46915. * Sets texture matrix rotation angle around Y axis in radians.
  46916. */
  46917. /**
  46918. * Gets texture matrix rotation angle around Y axis radians.
  46919. */
  46920. rotationY: number;
  46921. /**
  46922. * Gets or sets the center of the bounding box associated with the cube texture
  46923. * It must define where the camera used to render the texture was set
  46924. */
  46925. boundingBoxPosition: Vector3;
  46926. private _boundingBoxSize;
  46927. /**
  46928. * Gets or sets the size of the bounding box associated with the cube texture
  46929. * When defined, the cubemap will switch to local mode
  46930. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46931. * @example https://www.babylonjs-playground.com/#RNASML
  46932. */
  46933. boundingBoxSize: Vector3;
  46934. /**
  46935. * Instantiates an HDRTexture from the following parameters.
  46936. *
  46937. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  46938. * @param scene The scene the texture will be used in
  46939. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  46940. * @param noMipmap Forces to not generate the mipmap if true
  46941. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  46942. * @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)
  46943. * @param reserved Reserved flag for internal use.
  46944. */
  46945. 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>);
  46946. /**
  46947. * Get the current class name of the texture useful for serialization or dynamic coding.
  46948. * @returns "HDRCubeTexture"
  46949. */
  46950. getClassName(): string;
  46951. /**
  46952. * Occurs when the file is raw .hdr file.
  46953. */
  46954. private loadTexture;
  46955. clone(): HDRCubeTexture;
  46956. delayLoad(): void;
  46957. /**
  46958. * Get the texture reflection matrix used to rotate/transform the reflection.
  46959. * @returns the reflection matrix
  46960. */
  46961. getReflectionTextureMatrix(): Matrix;
  46962. /**
  46963. * Set the texture reflection matrix used to rotate/transform the reflection.
  46964. * @param value Define the reflection matrix to set
  46965. */
  46966. setReflectionTextureMatrix(value: Matrix): void;
  46967. /**
  46968. * Parses a JSON representation of an HDR Texture in order to create the texture
  46969. * @param parsedTexture Define the JSON representation
  46970. * @param scene Define the scene the texture should be created in
  46971. * @param rootUrl Define the root url in case we need to load relative dependencies
  46972. * @returns the newly created texture after parsing
  46973. */
  46974. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  46975. serialize(): any;
  46976. }
  46977. }
  46978. declare module BABYLON {
  46979. /**
  46980. * Class used to store data associated with WebGL texture data for the engine
  46981. * This class should not be used directly
  46982. */
  46983. class InternalTexture implements IInternalTextureTracker {
  46984. /**
  46985. * The source of the texture data is unknown
  46986. */
  46987. static DATASOURCE_UNKNOWN: number;
  46988. /**
  46989. * Texture data comes from an URL
  46990. */
  46991. static DATASOURCE_URL: number;
  46992. /**
  46993. * Texture data is only used for temporary storage
  46994. */
  46995. static DATASOURCE_TEMP: number;
  46996. /**
  46997. * Texture data comes from raw data (ArrayBuffer)
  46998. */
  46999. static DATASOURCE_RAW: number;
  47000. /**
  47001. * Texture content is dynamic (video or dynamic texture)
  47002. */
  47003. static DATASOURCE_DYNAMIC: number;
  47004. /**
  47005. * Texture content is generated by rendering to it
  47006. */
  47007. static DATASOURCE_RENDERTARGET: number;
  47008. /**
  47009. * Texture content is part of a multi render target process
  47010. */
  47011. static DATASOURCE_MULTIRENDERTARGET: number;
  47012. /**
  47013. * Texture data comes from a cube data file
  47014. */
  47015. static DATASOURCE_CUBE: number;
  47016. /**
  47017. * Texture data comes from a raw cube data
  47018. */
  47019. static DATASOURCE_CUBERAW: number;
  47020. /**
  47021. * Texture data come from a prefiltered cube data file
  47022. */
  47023. static DATASOURCE_CUBEPREFILTERED: number;
  47024. /**
  47025. * Texture content is raw 3D data
  47026. */
  47027. static DATASOURCE_RAW3D: number;
  47028. /**
  47029. * Texture content is a depth texture
  47030. */
  47031. static DATASOURCE_DEPTHTEXTURE: number;
  47032. /**
  47033. * Texture data comes from a raw cube data encoded with RGBD
  47034. */
  47035. static DATASOURCE_CUBERAW_RGBD: number;
  47036. /**
  47037. * Defines if the texture is ready
  47038. */
  47039. isReady: boolean;
  47040. /**
  47041. * Defines if the texture is a cube texture
  47042. */
  47043. isCube: boolean;
  47044. /**
  47045. * Defines if the texture contains 3D data
  47046. */
  47047. is3D: boolean;
  47048. /**
  47049. * Gets the URL used to load this texture
  47050. */
  47051. url: string;
  47052. /**
  47053. * Gets the sampling mode of the texture
  47054. */
  47055. samplingMode: number;
  47056. /**
  47057. * Gets a boolean indicating if the texture needs mipmaps generation
  47058. */
  47059. generateMipMaps: boolean;
  47060. /**
  47061. * Gets the number of samples used by the texture (WebGL2+ only)
  47062. */
  47063. samples: number;
  47064. /**
  47065. * Gets the type of the texture (int, float...)
  47066. */
  47067. type: number;
  47068. /**
  47069. * Gets the format of the texture (RGB, RGBA...)
  47070. */
  47071. format: number;
  47072. /**
  47073. * Observable called when the texture is loaded
  47074. */
  47075. onLoadedObservable: Observable<InternalTexture>;
  47076. /**
  47077. * Gets the width of the texture
  47078. */
  47079. width: number;
  47080. /**
  47081. * Gets the height of the texture
  47082. */
  47083. height: number;
  47084. /**
  47085. * Gets the depth of the texture
  47086. */
  47087. depth: number;
  47088. /**
  47089. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  47090. */
  47091. baseWidth: number;
  47092. /**
  47093. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  47094. */
  47095. baseHeight: number;
  47096. /**
  47097. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  47098. */
  47099. baseDepth: number;
  47100. /**
  47101. * Gets a boolean indicating if the texture is inverted on Y axis
  47102. */
  47103. invertY: boolean;
  47104. /**
  47105. * Gets or set the previous tracker in the list
  47106. */
  47107. previous: Nullable<IInternalTextureTracker>;
  47108. /**
  47109. * Gets or set the next tracker in the list
  47110. */
  47111. next: Nullable<IInternalTextureTracker>;
  47112. /** @hidden */
  47113. _initialSlot: number;
  47114. /** @hidden */
  47115. _designatedSlot: number;
  47116. /** @hidden */
  47117. _dataSource: number;
  47118. /** @hidden */
  47119. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47120. /** @hidden */
  47121. _bufferView: Nullable<ArrayBufferView>;
  47122. /** @hidden */
  47123. _bufferViewArray: Nullable<ArrayBufferView[]>;
  47124. /** @hidden */
  47125. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  47126. /** @hidden */
  47127. _size: number;
  47128. /** @hidden */
  47129. _extension: string;
  47130. /** @hidden */
  47131. _files: Nullable<string[]>;
  47132. /** @hidden */
  47133. _workingCanvas: HTMLCanvasElement;
  47134. /** @hidden */
  47135. _workingContext: CanvasRenderingContext2D;
  47136. /** @hidden */
  47137. _framebuffer: Nullable<WebGLFramebuffer>;
  47138. /** @hidden */
  47139. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  47140. /** @hidden */
  47141. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  47142. /** @hidden */
  47143. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  47144. /** @hidden */
  47145. _attachments: Nullable<number[]>;
  47146. /** @hidden */
  47147. _cachedCoordinatesMode: Nullable<number>;
  47148. /** @hidden */
  47149. _cachedWrapU: Nullable<number>;
  47150. /** @hidden */
  47151. _cachedWrapV: Nullable<number>;
  47152. /** @hidden */
  47153. _cachedWrapR: Nullable<number>;
  47154. /** @hidden */
  47155. _cachedAnisotropicFilteringLevel: Nullable<number>;
  47156. /** @hidden */
  47157. _isDisabled: boolean;
  47158. /** @hidden */
  47159. _compression: Nullable<string>;
  47160. /** @hidden */
  47161. _generateStencilBuffer: boolean;
  47162. /** @hidden */
  47163. _generateDepthBuffer: boolean;
  47164. /** @hidden */
  47165. _comparisonFunction: number;
  47166. /** @hidden */
  47167. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  47168. /** @hidden */
  47169. _lodGenerationScale: number;
  47170. /** @hidden */
  47171. _lodGenerationOffset: number;
  47172. /** @hidden */
  47173. _lodTextureHigh: BaseTexture;
  47174. /** @hidden */
  47175. _lodTextureMid: BaseTexture;
  47176. /** @hidden */
  47177. _lodTextureLow: BaseTexture;
  47178. /** @hidden */
  47179. _isRGBD: boolean;
  47180. /** @hidden */
  47181. _webGLTexture: Nullable<WebGLTexture>;
  47182. /** @hidden */
  47183. _references: number;
  47184. private _engine;
  47185. /**
  47186. * Gets the Engine the texture belongs to.
  47187. * @returns The babylon engine
  47188. */
  47189. getEngine(): Engine;
  47190. /**
  47191. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  47192. */
  47193. readonly dataSource: number;
  47194. /**
  47195. * Creates a new InternalTexture
  47196. * @param engine defines the engine to use
  47197. * @param dataSource defines the type of data that will be used
  47198. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47199. */
  47200. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  47201. /**
  47202. * Increments the number of references (ie. the number of Texture that point to it)
  47203. */
  47204. incrementReferences(): void;
  47205. /**
  47206. * Change the size of the texture (not the size of the content)
  47207. * @param width defines the new width
  47208. * @param height defines the new height
  47209. * @param depth defines the new depth (1 by default)
  47210. */
  47211. updateSize(width: int, height: int, depth?: int): void;
  47212. /** @hidden */
  47213. _rebuild(): void;
  47214. /** @hidden */
  47215. _swapAndDie(target: InternalTexture): void;
  47216. /**
  47217. * Dispose the current allocated resources
  47218. */
  47219. dispose(): void;
  47220. }
  47221. }
  47222. declare module BABYLON {
  47223. /**
  47224. * This represents the required contract to create a new type of texture loader.
  47225. */
  47226. interface IInternalTextureLoader {
  47227. /**
  47228. * Defines wether the loader supports cascade loading the different faces.
  47229. */
  47230. supportCascades: boolean;
  47231. /**
  47232. * This returns if the loader support the current file information.
  47233. * @param extension defines the file extension of the file being loaded
  47234. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47235. * @param fallback defines the fallback internal texture if any
  47236. * @param isBase64 defines whether the texture is encoded as a base64
  47237. * @param isBuffer defines whether the texture data are stored as a buffer
  47238. * @returns true if the loader can load the specified file
  47239. */
  47240. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47241. /**
  47242. * Transform the url before loading if required.
  47243. * @param rootUrl the url of the texture
  47244. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47245. * @returns the transformed texture
  47246. */
  47247. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47248. /**
  47249. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47250. * @param rootUrl the url of the texture
  47251. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47252. * @returns the fallback texture
  47253. */
  47254. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47255. /**
  47256. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47257. * @param data contains the texture data
  47258. * @param texture defines the BabylonJS internal texture
  47259. * @param createPolynomials will be true if polynomials have been requested
  47260. * @param onLoad defines the callback to trigger once the texture is ready
  47261. * @param onError defines the callback to trigger in case of error
  47262. */
  47263. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47264. /**
  47265. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47266. * @param data contains the texture data
  47267. * @param texture defines the BabylonJS internal texture
  47268. * @param callback defines the method to call once ready to upload
  47269. */
  47270. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  47271. }
  47272. }
  47273. declare module BABYLON {
  47274. /**
  47275. * Internal interface used to track InternalTexture already bound to the GL context
  47276. */
  47277. interface IInternalTextureTracker {
  47278. /**
  47279. * Gets or set the previous tracker in the list
  47280. */
  47281. previous: Nullable<IInternalTextureTracker>;
  47282. /**
  47283. * Gets or set the next tracker in the list
  47284. */
  47285. next: Nullable<IInternalTextureTracker>;
  47286. }
  47287. /**
  47288. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  47289. */
  47290. class DummyInternalTextureTracker {
  47291. /**
  47292. * Gets or set the previous tracker in the list
  47293. */
  47294. previous: Nullable<IInternalTextureTracker>;
  47295. /**
  47296. * Gets or set the next tracker in the list
  47297. */
  47298. next: Nullable<IInternalTextureTracker>;
  47299. }
  47300. }
  47301. declare module BABYLON {
  47302. /**
  47303. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47304. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47305. * You can then easily use it as a reflectionTexture on a flat surface.
  47306. * In case the surface is not a plane, please consider relying on reflection probes.
  47307. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47308. */
  47309. class MirrorTexture extends RenderTargetTexture {
  47310. private scene;
  47311. /**
  47312. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  47313. * 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.
  47314. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47315. */
  47316. mirrorPlane: Plane;
  47317. /**
  47318. * Define the blur ratio used to blur the reflection if needed.
  47319. */
  47320. blurRatio: number;
  47321. /**
  47322. * Define the adaptive blur kernel used to blur the reflection if needed.
  47323. * This will autocompute the closest best match for the `blurKernel`
  47324. */
  47325. adaptiveBlurKernel: number;
  47326. /**
  47327. * Define the blur kernel used to blur the reflection if needed.
  47328. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47329. */
  47330. blurKernel: number;
  47331. /**
  47332. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  47333. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47334. */
  47335. blurKernelX: number;
  47336. /**
  47337. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  47338. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47339. */
  47340. blurKernelY: number;
  47341. private _autoComputeBlurKernel;
  47342. protected _onRatioRescale(): void;
  47343. private _updateGammaSpace;
  47344. private _imageProcessingConfigChangeObserver;
  47345. private _transformMatrix;
  47346. private _mirrorMatrix;
  47347. private _savedViewMatrix;
  47348. private _blurX;
  47349. private _blurY;
  47350. private _adaptiveBlurKernel;
  47351. private _blurKernelX;
  47352. private _blurKernelY;
  47353. private _blurRatio;
  47354. /**
  47355. * Instantiates a Mirror Texture.
  47356. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47357. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47358. * You can then easily use it as a reflectionTexture on a flat surface.
  47359. * In case the surface is not a plane, please consider relying on reflection probes.
  47360. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47361. * @param name
  47362. * @param size
  47363. * @param scene
  47364. * @param generateMipMaps
  47365. * @param type
  47366. * @param samplingMode
  47367. * @param generateDepthBuffer
  47368. */
  47369. constructor(name: string, size: number | {
  47370. width: number;
  47371. height: number;
  47372. } | {
  47373. ratio: number;
  47374. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  47375. private _preparePostProcesses;
  47376. /**
  47377. * Clone the mirror texture.
  47378. * @returns the cloned texture
  47379. */
  47380. clone(): MirrorTexture;
  47381. /**
  47382. * Serialize the texture to a JSON representation you could use in Parse later on
  47383. * @returns the serialized JSON representation
  47384. */
  47385. serialize(): any;
  47386. /**
  47387. * Dispose the texture and release its associated resources.
  47388. */
  47389. dispose(): void;
  47390. }
  47391. }
  47392. declare module BABYLON {
  47393. /**
  47394. * Creation options of the multi render target texture.
  47395. */
  47396. interface IMultiRenderTargetOptions {
  47397. /**
  47398. * Define if the texture needs to create mip maps after render.
  47399. */
  47400. generateMipMaps?: boolean;
  47401. /**
  47402. * Define the types of all the draw buffers we want to create
  47403. */
  47404. types?: number[];
  47405. /**
  47406. * Define the sampling modes of all the draw buffers we want to create
  47407. */
  47408. samplingModes?: number[];
  47409. /**
  47410. * Define if a depth buffer is required
  47411. */
  47412. generateDepthBuffer?: boolean;
  47413. /**
  47414. * Define if a stencil buffer is required
  47415. */
  47416. generateStencilBuffer?: boolean;
  47417. /**
  47418. * Define if a depth texture is required instead of a depth buffer
  47419. */
  47420. generateDepthTexture?: boolean;
  47421. /**
  47422. * Define the number of desired draw buffers
  47423. */
  47424. textureCount?: number;
  47425. /**
  47426. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47427. */
  47428. doNotChangeAspectRatio?: boolean;
  47429. /**
  47430. * Define the default type of the buffers we are creating
  47431. */
  47432. defaultType?: number;
  47433. }
  47434. /**
  47435. * A multi render target, like a render target provides the ability to render to a texture.
  47436. * Unlike the render target, it can render to several draw buffers in one draw.
  47437. * This is specially interesting in deferred rendering or for any effects requiring more than
  47438. * just one color from a single pass.
  47439. */
  47440. class MultiRenderTarget extends RenderTargetTexture {
  47441. private _internalTextures;
  47442. private _textures;
  47443. private _multiRenderTargetOptions;
  47444. /**
  47445. * Get if draw buffers are currently supported by the used hardware and browser.
  47446. */
  47447. readonly isSupported: boolean;
  47448. /**
  47449. * Get the list of textures generated by the multi render target.
  47450. */
  47451. readonly textures: Texture[];
  47452. /**
  47453. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47454. */
  47455. readonly depthTexture: Texture;
  47456. /**
  47457. * Set the wrapping mode on U of all the textures we are rendering to.
  47458. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47459. */
  47460. wrapU: number;
  47461. /**
  47462. * Set the wrapping mode on V of all the textures we are rendering to.
  47463. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47464. */
  47465. wrapV: number;
  47466. /**
  47467. * Instantiate a new multi render target texture.
  47468. * A multi render target, like a render target provides the ability to render to a texture.
  47469. * Unlike the render target, it can render to several draw buffers in one draw.
  47470. * This is specially interesting in deferred rendering or for any effects requiring more than
  47471. * just one color from a single pass.
  47472. * @param name Define the name of the texture
  47473. * @param size Define the size of the buffers to render to
  47474. * @param count Define the number of target we are rendering into
  47475. * @param scene Define the scene the texture belongs to
  47476. * @param options Define the options used to create the multi render target
  47477. */
  47478. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47479. /** @hidden */
  47480. _rebuild(): void;
  47481. private _createInternalTextures;
  47482. private _createTextures;
  47483. /**
  47484. * Define the number of samples used if MSAA is enabled.
  47485. */
  47486. samples: number;
  47487. /**
  47488. * Resize all the textures in the multi render target.
  47489. * Be carrefull as it will recreate all the data in the new texture.
  47490. * @param size Define the new size
  47491. */
  47492. resize(size: any): void;
  47493. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47494. /**
  47495. * Dispose the render targets and their associated resources
  47496. */
  47497. dispose(): void;
  47498. /**
  47499. * Release all the underlying texture used as draw buffers.
  47500. */
  47501. releaseInternalTextures(): void;
  47502. }
  47503. }
  47504. declare module BABYLON {
  47505. /**
  47506. * Raw cube texture where the raw buffers are passed in
  47507. */
  47508. class RawCubeTexture extends CubeTexture {
  47509. /**
  47510. * Creates a cube texture where the raw buffers are passed in.
  47511. * @param scene defines the scene the texture is attached to
  47512. * @param data defines the array of data to use to create each face
  47513. * @param size defines the size of the textures
  47514. * @param format defines the format of the data
  47515. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  47516. * @param generateMipMaps defines if the engine should generate the mip levels
  47517. * @param invertY defines if data must be stored with Y axis inverted
  47518. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  47519. * @param compression defines the compression used (null by default)
  47520. */
  47521. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  47522. /**
  47523. * Updates the raw cube texture.
  47524. * @param data defines the data to store
  47525. * @param format defines the data format
  47526. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47527. * @param invertY defines if data must be stored with Y axis inverted
  47528. * @param compression defines the compression used (null by default)
  47529. * @param level defines which level of the texture to update
  47530. */
  47531. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  47532. /**
  47533. * Updates a raw cube texture with RGBD encoded data.
  47534. * @param data defines the array of data [mipmap][face] to use to create each face
  47535. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  47536. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47537. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47538. * @returns a promsie that resolves when the operation is complete
  47539. */
  47540. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  47541. /**
  47542. * Clones the raw cube texture.
  47543. * @return a new cube texture
  47544. */
  47545. clone(): CubeTexture;
  47546. /** @hidden */
  47547. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47548. }
  47549. }
  47550. declare module BABYLON {
  47551. /**
  47552. * Raw texture can help creating a texture directly from an array of data.
  47553. * This can be super useful if you either get the data from an uncompressed source or
  47554. * if you wish to create your texture pixel by pixel.
  47555. */
  47556. class RawTexture extends Texture {
  47557. /**
  47558. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47559. */
  47560. format: number;
  47561. private _engine;
  47562. /**
  47563. * Instantiates a new RawTexture.
  47564. * Raw texture can help creating a texture directly from an array of data.
  47565. * This can be super useful if you either get the data from an uncompressed source or
  47566. * if you wish to create your texture pixel by pixel.
  47567. * @param data define the array of data to use to create the texture
  47568. * @param width define the width of the texture
  47569. * @param height define the height of the texture
  47570. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47571. * @param scene define the scene the texture belongs to
  47572. * @param generateMipMaps define whether mip maps should be generated or not
  47573. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47574. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47575. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47576. */
  47577. constructor(data: ArrayBufferView, width: number, height: number,
  47578. /**
  47579. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47580. */
  47581. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  47582. /**
  47583. * Updates the texture underlying data.
  47584. * @param data Define the new data of the texture
  47585. */
  47586. update(data: ArrayBufferView): void;
  47587. /**
  47588. * Creates a luminance texture from some data.
  47589. * @param data Define the texture data
  47590. * @param width Define the width of the texture
  47591. * @param height Define the height of the texture
  47592. * @param scene Define the scene the texture belongs to
  47593. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47594. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47595. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47596. * @returns the luminance texture
  47597. */
  47598. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47599. /**
  47600. * Creates a luminance alpha texture from some data.
  47601. * @param data Define the texture data
  47602. * @param width Define the width of the texture
  47603. * @param height Define the height of the texture
  47604. * @param scene Define the scene the texture belongs to
  47605. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47606. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47607. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47608. * @returns the luminance alpha texture
  47609. */
  47610. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47611. /**
  47612. * Creates an alpha texture from some data.
  47613. * @param data Define the texture data
  47614. * @param width Define the width of the texture
  47615. * @param height Define the height of the texture
  47616. * @param scene Define the scene the texture belongs to
  47617. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47618. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47619. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47620. * @returns the alpha texture
  47621. */
  47622. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47623. /**
  47624. * Creates a RGB texture from some data.
  47625. * @param data Define the texture data
  47626. * @param width Define the width of the texture
  47627. * @param height Define the height of the texture
  47628. * @param scene Define the scene the texture belongs to
  47629. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47630. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47631. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47632. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47633. * @returns the RGB alpha texture
  47634. */
  47635. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47636. /**
  47637. * Creates a RGBA texture from some data.
  47638. * @param data Define the texture data
  47639. * @param width Define the width of the texture
  47640. * @param height Define the height of the texture
  47641. * @param scene Define the scene the texture belongs to
  47642. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47643. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47644. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47645. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47646. * @returns the RGBA texture
  47647. */
  47648. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47649. /**
  47650. * Creates a R texture from some data.
  47651. * @param data Define the texture data
  47652. * @param width Define the width of the texture
  47653. * @param height Define the height of the texture
  47654. * @param scene Define the scene the texture belongs to
  47655. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47656. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47657. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47658. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47659. * @returns the R texture
  47660. */
  47661. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47662. }
  47663. }
  47664. declare module BABYLON {
  47665. /**
  47666. * Class used to store 3D textures containing user data
  47667. */
  47668. class RawTexture3D extends Texture {
  47669. /** Gets or sets the texture format to use */
  47670. format: number;
  47671. private _engine;
  47672. /**
  47673. * Create a new RawTexture3D
  47674. * @param data defines the data of the texture
  47675. * @param width defines the width of the texture
  47676. * @param height defines the height of the texture
  47677. * @param depth defines the depth of the texture
  47678. * @param format defines the texture format to use
  47679. * @param scene defines the hosting scene
  47680. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47681. * @param invertY defines if texture must be stored with Y axis inverted
  47682. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  47683. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47684. */
  47685. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47686. /** Gets or sets the texture format to use */
  47687. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47688. /**
  47689. * Update the texture with new data
  47690. * @param data defines the data to store in the texture
  47691. */
  47692. update(data: ArrayBufferView): void;
  47693. }
  47694. }
  47695. declare module BABYLON {
  47696. /**
  47697. * Creates a refraction texture used by refraction channel of the standard material.
  47698. * It is like a mirror but to see through a material.
  47699. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47700. */
  47701. class RefractionTexture extends RenderTargetTexture {
  47702. /**
  47703. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47704. * 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.
  47705. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47706. */
  47707. refractionPlane: Plane;
  47708. /**
  47709. * Define how deep under the surface we should see.
  47710. */
  47711. depth: number;
  47712. /**
  47713. * Creates a refraction texture used by refraction channel of the standard material.
  47714. * It is like a mirror but to see through a material.
  47715. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47716. * @param name Define the texture name
  47717. * @param size Define the size of the underlying texture
  47718. * @param scene Define the scene the refraction belongs to
  47719. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47720. */
  47721. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47722. /**
  47723. * Clone the refraction texture.
  47724. * @returns the cloned texture
  47725. */
  47726. clone(): RefractionTexture;
  47727. /**
  47728. * Serialize the texture to a JSON representation you could use in Parse later on
  47729. * @returns the serialized JSON representation
  47730. */
  47731. serialize(): any;
  47732. }
  47733. }
  47734. declare module BABYLON {
  47735. /**
  47736. * This Helps creating a texture that will be created from a camera in your scene.
  47737. * It is basically a dynamic texture that could be used to create special effects for instance.
  47738. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  47739. */
  47740. class RenderTargetTexture extends Texture {
  47741. isCube: boolean;
  47742. /**
  47743. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  47744. */
  47745. static readonly REFRESHRATE_RENDER_ONCE: number;
  47746. /**
  47747. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  47748. */
  47749. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  47750. /**
  47751. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  47752. * the central point of your effect and can save a lot of performances.
  47753. */
  47754. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  47755. /**
  47756. * Use this predicate to dynamically define the list of mesh you want to render.
  47757. * If set, the renderList property will be overwritten.
  47758. */
  47759. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  47760. private _renderList;
  47761. /**
  47762. * Use this list to define the list of mesh you want to render.
  47763. */
  47764. renderList: Nullable<Array<AbstractMesh>>;
  47765. private _hookArray;
  47766. /**
  47767. * Define if particles should be rendered in your texture.
  47768. */
  47769. renderParticles: boolean;
  47770. /**
  47771. * Define if sprites should be rendered in your texture.
  47772. */
  47773. renderSprites: boolean;
  47774. /**
  47775. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  47776. */
  47777. coordinatesMode: number;
  47778. /**
  47779. * Define the camera used to render the texture.
  47780. */
  47781. activeCamera: Nullable<Camera>;
  47782. /**
  47783. * Override the render function of the texture with your own one.
  47784. */
  47785. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  47786. /**
  47787. * Define if camera post processes should be use while rendering the texture.
  47788. */
  47789. useCameraPostProcesses: boolean;
  47790. /**
  47791. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  47792. */
  47793. ignoreCameraViewport: boolean;
  47794. private _postProcessManager;
  47795. private _postProcesses;
  47796. private _resizeObserver;
  47797. /**
  47798. * An event triggered when the texture is unbind.
  47799. */
  47800. onBeforeBindObservable: Observable<RenderTargetTexture>;
  47801. /**
  47802. * An event triggered when the texture is unbind.
  47803. */
  47804. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  47805. private _onAfterUnbindObserver;
  47806. /**
  47807. * Set a after unbind callback in the texture.
  47808. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  47809. */
  47810. onAfterUnbind: () => void;
  47811. /**
  47812. * An event triggered before rendering the texture
  47813. */
  47814. onBeforeRenderObservable: Observable<number>;
  47815. private _onBeforeRenderObserver;
  47816. /**
  47817. * Set a before render callback in the texture.
  47818. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  47819. */
  47820. onBeforeRender: (faceIndex: number) => void;
  47821. /**
  47822. * An event triggered after rendering the texture
  47823. */
  47824. onAfterRenderObservable: Observable<number>;
  47825. private _onAfterRenderObserver;
  47826. /**
  47827. * Set a after render callback in the texture.
  47828. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  47829. */
  47830. onAfterRender: (faceIndex: number) => void;
  47831. /**
  47832. * An event triggered after the texture clear
  47833. */
  47834. onClearObservable: Observable<Engine>;
  47835. private _onClearObserver;
  47836. /**
  47837. * Set a clear callback in the texture.
  47838. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  47839. */
  47840. onClear: (Engine: Engine) => void;
  47841. /**
  47842. * Define the clear color of the Render Target if it should be different from the scene.
  47843. */
  47844. clearColor: Color4;
  47845. protected _size: number | {
  47846. width: number;
  47847. height: number;
  47848. };
  47849. protected _initialSizeParameter: number | {
  47850. width: number;
  47851. height: number;
  47852. } | {
  47853. ratio: number;
  47854. };
  47855. protected _sizeRatio: Nullable<number>;
  47856. /** @hidden */
  47857. _generateMipMaps: boolean;
  47858. protected _renderingManager: RenderingManager;
  47859. /** @hidden */
  47860. _waitingRenderList: string[];
  47861. protected _doNotChangeAspectRatio: boolean;
  47862. protected _currentRefreshId: number;
  47863. protected _refreshRate: number;
  47864. protected _textureMatrix: Matrix;
  47865. protected _samples: number;
  47866. protected _renderTargetOptions: RenderTargetCreationOptions;
  47867. /**
  47868. * Gets render target creation options that were used.
  47869. */
  47870. readonly renderTargetOptions: RenderTargetCreationOptions;
  47871. protected _engine: Engine;
  47872. protected _onRatioRescale(): void;
  47873. /**
  47874. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  47875. * It must define where the camera used to render the texture is set
  47876. */
  47877. boundingBoxPosition: Vector3;
  47878. private _boundingBoxSize;
  47879. /**
  47880. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  47881. * When defined, the cubemap will switch to local mode
  47882. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47883. * @example https://www.babylonjs-playground.com/#RNASML
  47884. */
  47885. boundingBoxSize: Vector3;
  47886. /**
  47887. * In case the RTT has been created with a depth texture, get the associated
  47888. * depth texture.
  47889. * Otherwise, return null.
  47890. */
  47891. depthStencilTexture: Nullable<InternalTexture>;
  47892. /**
  47893. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  47894. * or used a shadow, depth texture...
  47895. * @param name The friendly name of the texture
  47896. * @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)
  47897. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  47898. * @param generateMipMaps True if mip maps need to be generated after render.
  47899. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  47900. * @param type The type of the buffer in the RTT (int, half float, float...)
  47901. * @param isCube True if a cube texture needs to be created
  47902. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  47903. * @param generateDepthBuffer True to generate a depth buffer
  47904. * @param generateStencilBuffer True to generate a stencil buffer
  47905. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  47906. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  47907. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47908. */
  47909. constructor(name: string, size: number | {
  47910. width: number;
  47911. height: number;
  47912. } | {
  47913. ratio: number;
  47914. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  47915. /**
  47916. * Creates a depth stencil texture.
  47917. * This is only available in WebGL 2 or with the depth texture extension available.
  47918. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  47919. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  47920. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  47921. */
  47922. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  47923. private _processSizeParameter;
  47924. /**
  47925. * Define the number of samples to use in case of MSAA.
  47926. * It defaults to one meaning no MSAA has been enabled.
  47927. */
  47928. samples: number;
  47929. /**
  47930. * Resets the refresh counter of the texture and start bak from scratch.
  47931. * Could be useful to regenerate the texture if it is setup to render only once.
  47932. */
  47933. resetRefreshCounter(): void;
  47934. /**
  47935. * Define the refresh rate of the texture or the rendering frequency.
  47936. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  47937. */
  47938. refreshRate: number;
  47939. /**
  47940. * Adds a post process to the render target rendering passes.
  47941. * @param postProcess define the post process to add
  47942. */
  47943. addPostProcess(postProcess: PostProcess): void;
  47944. /**
  47945. * Clear all the post processes attached to the render target
  47946. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  47947. */
  47948. clearPostProcesses(dispose?: boolean): void;
  47949. /**
  47950. * Remove one of the post process from the list of attached post processes to the texture
  47951. * @param postProcess define the post process to remove from the list
  47952. */
  47953. removePostProcess(postProcess: PostProcess): void;
  47954. /** @hidden */
  47955. _shouldRender(): boolean;
  47956. /**
  47957. * Gets the actual render size of the texture.
  47958. * @returns the width of the render size
  47959. */
  47960. getRenderSize(): number;
  47961. /**
  47962. * Gets the actual render width of the texture.
  47963. * @returns the width of the render size
  47964. */
  47965. getRenderWidth(): number;
  47966. /**
  47967. * Gets the actual render height of the texture.
  47968. * @returns the height of the render size
  47969. */
  47970. getRenderHeight(): number;
  47971. /**
  47972. * Get if the texture can be rescaled or not.
  47973. */
  47974. readonly canRescale: boolean;
  47975. /**
  47976. * Resize the texture using a ratio.
  47977. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  47978. */
  47979. scale(ratio: number): void;
  47980. /**
  47981. * Get the texture reflection matrix used to rotate/transform the reflection.
  47982. * @returns the reflection matrix
  47983. */
  47984. getReflectionTextureMatrix(): Matrix;
  47985. /**
  47986. * Resize the texture to a new desired size.
  47987. * Be carrefull as it will recreate all the data in the new texture.
  47988. * @param size Define the new size. It can be:
  47989. * - a number for squared texture,
  47990. * - an object containing { width: number, height: number }
  47991. * - or an object containing a ratio { ratio: number }
  47992. */
  47993. resize(size: number | {
  47994. width: number;
  47995. height: number;
  47996. } | {
  47997. ratio: number;
  47998. }): void;
  47999. /**
  48000. * Renders all the objects from the render list into the texture.
  48001. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  48002. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  48003. */
  48004. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  48005. private _bestReflectionRenderTargetDimension;
  48006. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48007. private renderToTarget;
  48008. /**
  48009. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  48010. * This allowed control for front to back rendering or reversly depending of the special needs.
  48011. *
  48012. * @param renderingGroupId The rendering group id corresponding to its index
  48013. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  48014. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  48015. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  48016. */
  48017. 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;
  48018. /**
  48019. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  48020. *
  48021. * @param renderingGroupId The rendering group id corresponding to its index
  48022. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48023. */
  48024. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48025. /**
  48026. * Clones the texture.
  48027. * @returns the cloned texture
  48028. */
  48029. clone(): RenderTargetTexture;
  48030. /**
  48031. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48032. * @returns The JSON representation of the texture
  48033. */
  48034. serialize(): any;
  48035. /**
  48036. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  48037. */
  48038. disposeFramebufferObjects(): void;
  48039. /**
  48040. * Dispose the texture and release its associated resources.
  48041. */
  48042. dispose(): void;
  48043. /** @hidden */
  48044. _rebuild(): void;
  48045. /**
  48046. * Clear the info related to rendering groups preventing retention point in material dispose.
  48047. */
  48048. freeRenderingGroups(): void;
  48049. }
  48050. }
  48051. declare module BABYLON {
  48052. /**
  48053. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48054. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48055. */
  48056. class Texture extends BaseTexture {
  48057. /** nearest is mag = nearest and min = nearest and mip = linear */
  48058. static readonly NEAREST_SAMPLINGMODE: number;
  48059. /** nearest is mag = nearest and min = nearest and mip = linear */
  48060. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  48061. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48062. static readonly BILINEAR_SAMPLINGMODE: number;
  48063. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48064. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  48065. /** Trilinear is mag = linear and min = linear and mip = linear */
  48066. static readonly TRILINEAR_SAMPLINGMODE: number;
  48067. /** Trilinear is mag = linear and min = linear and mip = linear */
  48068. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  48069. /** mag = nearest and min = nearest and mip = nearest */
  48070. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  48071. /** mag = nearest and min = linear and mip = nearest */
  48072. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  48073. /** mag = nearest and min = linear and mip = linear */
  48074. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  48075. /** mag = nearest and min = linear and mip = none */
  48076. static readonly NEAREST_LINEAR: number;
  48077. /** mag = nearest and min = nearest and mip = none */
  48078. static readonly NEAREST_NEAREST: number;
  48079. /** mag = linear and min = nearest and mip = nearest */
  48080. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  48081. /** mag = linear and min = nearest and mip = linear */
  48082. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  48083. /** mag = linear and min = linear and mip = none */
  48084. static readonly LINEAR_LINEAR: number;
  48085. /** mag = linear and min = nearest and mip = none */
  48086. static readonly LINEAR_NEAREST: number;
  48087. /** Explicit coordinates mode */
  48088. static readonly EXPLICIT_MODE: number;
  48089. /** Spherical coordinates mode */
  48090. static readonly SPHERICAL_MODE: number;
  48091. /** Planar coordinates mode */
  48092. static readonly PLANAR_MODE: number;
  48093. /** Cubic coordinates mode */
  48094. static readonly CUBIC_MODE: number;
  48095. /** Projection coordinates mode */
  48096. static readonly PROJECTION_MODE: number;
  48097. /** Inverse Cubic coordinates mode */
  48098. static readonly SKYBOX_MODE: number;
  48099. /** Inverse Cubic coordinates mode */
  48100. static readonly INVCUBIC_MODE: number;
  48101. /** Equirectangular coordinates mode */
  48102. static readonly EQUIRECTANGULAR_MODE: number;
  48103. /** Equirectangular Fixed coordinates mode */
  48104. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  48105. /** Equirectangular Fixed Mirrored coordinates mode */
  48106. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  48107. /** Texture is not repeating outside of 0..1 UVs */
  48108. static readonly CLAMP_ADDRESSMODE: number;
  48109. /** Texture is repeating outside of 0..1 UVs */
  48110. static readonly WRAP_ADDRESSMODE: number;
  48111. /** Texture is repeating and mirrored */
  48112. static readonly MIRROR_ADDRESSMODE: number;
  48113. /**
  48114. * 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
  48115. */
  48116. static UseSerializedUrlIfAny: boolean;
  48117. /**
  48118. * Define the url of the texture.
  48119. */
  48120. url: Nullable<string>;
  48121. /**
  48122. * Define an offset on the texture to offset the u coordinates of the UVs
  48123. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48124. */
  48125. uOffset: number;
  48126. /**
  48127. * Define an offset on the texture to offset the v coordinates of the UVs
  48128. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48129. */
  48130. vOffset: number;
  48131. /**
  48132. * Define an offset on the texture to scale the u coordinates of the UVs
  48133. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48134. */
  48135. uScale: number;
  48136. /**
  48137. * Define an offset on the texture to scale the v coordinates of the UVs
  48138. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48139. */
  48140. vScale: number;
  48141. /**
  48142. * Define an offset on the texture to rotate around the u coordinates of the UVs
  48143. * @see http://doc.babylonjs.com/how_to/more_materials
  48144. */
  48145. uAng: number;
  48146. /**
  48147. * Define an offset on the texture to rotate around the v coordinates of the UVs
  48148. * @see http://doc.babylonjs.com/how_to/more_materials
  48149. */
  48150. vAng: number;
  48151. /**
  48152. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  48153. * @see http://doc.babylonjs.com/how_to/more_materials
  48154. */
  48155. wAng: number;
  48156. /**
  48157. * Defines the center of rotation (U)
  48158. */
  48159. uRotationCenter: number;
  48160. /**
  48161. * Defines the center of rotation (V)
  48162. */
  48163. vRotationCenter: number;
  48164. /**
  48165. * Defines the center of rotation (W)
  48166. */
  48167. wRotationCenter: number;
  48168. /**
  48169. * Are mip maps generated for this texture or not.
  48170. */
  48171. readonly noMipmap: boolean;
  48172. private _noMipmap;
  48173. /** @hidden */
  48174. _invertY: boolean;
  48175. private _rowGenerationMatrix;
  48176. private _cachedTextureMatrix;
  48177. private _projectionModeMatrix;
  48178. private _t0;
  48179. private _t1;
  48180. private _t2;
  48181. private _cachedUOffset;
  48182. private _cachedVOffset;
  48183. private _cachedUScale;
  48184. private _cachedVScale;
  48185. private _cachedUAng;
  48186. private _cachedVAng;
  48187. private _cachedWAng;
  48188. private _cachedProjectionMatrixId;
  48189. private _cachedCoordinatesMode;
  48190. /** @hidden */
  48191. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  48192. private _deleteBuffer;
  48193. protected _format: Nullable<number>;
  48194. private _delayedOnLoad;
  48195. private _delayedOnError;
  48196. /**
  48197. * Observable triggered once the texture has been loaded.
  48198. */
  48199. onLoadObservable: Observable<Texture>;
  48200. protected _isBlocking: boolean;
  48201. /**
  48202. * Is the texture preventing material to render while loading.
  48203. * If false, a default texture will be used instead of the loading one during the preparation step.
  48204. */
  48205. isBlocking: boolean;
  48206. /**
  48207. * Get the current sampling mode associated with the texture.
  48208. */
  48209. readonly samplingMode: number;
  48210. /**
  48211. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  48212. */
  48213. readonly invertY: boolean;
  48214. /**
  48215. * Instantiates a new texture.
  48216. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48217. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48218. * @param url define the url of the picture to load as a texture
  48219. * @param scene define the scene the texture will belong to
  48220. * @param noMipmap define if the texture will require mip maps or not
  48221. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48222. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48223. * @param onLoad define a callback triggered when the texture has been loaded
  48224. * @param onError define a callback triggered when an error occurred during the loading session
  48225. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48226. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48227. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48228. */
  48229. 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);
  48230. /**
  48231. * Update the url (and optional buffer) of this texture if url was null during construction.
  48232. * @param url the url of the texture
  48233. * @param buffer the buffer of the texture (defaults to null)
  48234. * @param onLoad callback called when the texture is loaded (defaults to null)
  48235. */
  48236. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  48237. /**
  48238. * Finish the loading sequence of a texture flagged as delayed load.
  48239. * @hidden
  48240. */
  48241. delayLoad(): void;
  48242. private _prepareRowForTextureGeneration;
  48243. /**
  48244. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  48245. * @returns the transform matrix of the texture.
  48246. */
  48247. getTextureMatrix(): Matrix;
  48248. /**
  48249. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  48250. * @returns The reflection texture transform
  48251. */
  48252. getReflectionTextureMatrix(): Matrix;
  48253. /**
  48254. * Clones the texture.
  48255. * @returns the cloned texture
  48256. */
  48257. clone(): Texture;
  48258. /**
  48259. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48260. * @returns The JSON representation of the texture
  48261. */
  48262. serialize(): any;
  48263. /**
  48264. * Get the current class name of the texture useful for serialization or dynamic coding.
  48265. * @returns "Texture"
  48266. */
  48267. getClassName(): string;
  48268. /**
  48269. * Dispose the texture and release its associated resources.
  48270. */
  48271. dispose(): void;
  48272. /**
  48273. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  48274. * @param parsedTexture Define the JSON representation of the texture
  48275. * @param scene Define the scene the parsed texture should be instantiated in
  48276. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48277. * @returns The parsed texture if successful
  48278. */
  48279. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  48280. /**
  48281. * Creates a texture from its base 64 representation.
  48282. * @param data Define the base64 payload without the data: prefix
  48283. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48284. * @param scene Define the scene the texture should belong to
  48285. * @param noMipmap Forces the texture to not create mip map information if true
  48286. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48287. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48288. * @param onLoad define a callback triggered when the texture has been loaded
  48289. * @param onError define a callback triggered when an error occurred during the loading session
  48290. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48291. * @returns the created texture
  48292. */
  48293. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  48294. /**
  48295. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  48296. * @param data Define the base64 payload without the data: prefix
  48297. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48298. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48299. * @param scene Define the scene the texture should belong to
  48300. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48301. * @param noMipmap Forces the texture to not create mip map information if true
  48302. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48303. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48304. * @param onLoad define a callback triggered when the texture has been loaded
  48305. * @param onError define a callback triggered when an error occurred during the loading session
  48306. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48307. * @returns the created texture
  48308. */
  48309. 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;
  48310. }
  48311. }
  48312. declare module BABYLON {
  48313. /**
  48314. * Settings for finer control over video usage
  48315. */
  48316. interface VideoTextureSettings {
  48317. /**
  48318. * Applies `autoplay` to video, if specified
  48319. */
  48320. autoPlay?: boolean;
  48321. /**
  48322. * Applies `loop` to video, if specified
  48323. */
  48324. loop?: boolean;
  48325. /**
  48326. * Automatically updates internal texture from video at every frame in the render loop
  48327. */
  48328. autoUpdateTexture: boolean;
  48329. /**
  48330. * Image src displayed during the video loading or until the user interacts with the video.
  48331. */
  48332. poster?: string;
  48333. }
  48334. /**
  48335. * If you want to display a video in your scene, this is the special texture for that.
  48336. * This special texture works similar to other textures, with the exception of a few parameters.
  48337. * @see https://doc.babylonjs.com/how_to/video_texture
  48338. */
  48339. class VideoTexture extends Texture {
  48340. /**
  48341. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  48342. */
  48343. readonly autoUpdateTexture: boolean;
  48344. /**
  48345. * The video instance used by the texture internally
  48346. */
  48347. readonly video: HTMLVideoElement;
  48348. private _onUserActionRequestedObservable;
  48349. /**
  48350. * Event triggerd when a dom action is required by the user to play the video.
  48351. * This happens due to recent changes in browser policies preventing video to auto start.
  48352. */
  48353. readonly onUserActionRequestedObservable: Observable<Texture>;
  48354. private _generateMipMaps;
  48355. private _engine;
  48356. private _stillImageCaptured;
  48357. private _displayingPosterTexture;
  48358. private _settings;
  48359. private _createInternalTextureOnEvent;
  48360. /**
  48361. * Creates a video texture.
  48362. * If you want to display a video in your scene, this is the special texture for that.
  48363. * This special texture works similar to other textures, with the exception of a few parameters.
  48364. * @see https://doc.babylonjs.com/how_to/video_texture
  48365. * @param name optional name, will detect from video source, if not defined
  48366. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  48367. * @param scene is obviously the current scene.
  48368. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  48369. * @param invertY is false by default but can be used to invert video on Y axis
  48370. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  48371. * @param settings allows finer control over video usage
  48372. */
  48373. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  48374. private _getName;
  48375. private _getVideo;
  48376. private _createInternalTexture;
  48377. private reset;
  48378. /**
  48379. * @hidden Internal method to initiate `update`.
  48380. */
  48381. _rebuild(): void;
  48382. /**
  48383. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  48384. */
  48385. update(): void;
  48386. /**
  48387. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  48388. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  48389. */
  48390. updateTexture(isVisible: boolean): void;
  48391. protected _updateInternalTexture: (e?: Event | undefined) => void;
  48392. /**
  48393. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  48394. * @param url New url.
  48395. */
  48396. updateURL(url: string): void;
  48397. /**
  48398. * Dispose the texture and release its associated resources.
  48399. */
  48400. dispose(): void;
  48401. /**
  48402. * Creates a video texture straight from your WebCam video feed.
  48403. * @param scene Define the scene the texture should be created in
  48404. * @param onReady Define a callback to triggered once the texture will be ready
  48405. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  48406. */
  48407. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  48408. minWidth: number;
  48409. maxWidth: number;
  48410. minHeight: number;
  48411. maxHeight: number;
  48412. deviceId: string;
  48413. }): void;
  48414. }
  48415. }
  48416. declare var DracoDecoderModule: any;
  48417. declare var WebAssembly: any;
  48418. declare module BABYLON {
  48419. /**
  48420. * Configuration for Draco compression
  48421. */
  48422. interface IDracoCompressionConfiguration {
  48423. /**
  48424. * Configuration for the decoder.
  48425. */
  48426. decoder?: {
  48427. /**
  48428. * The url to the WebAssembly module.
  48429. */
  48430. wasmUrl?: string;
  48431. /**
  48432. * The url to the WebAssembly binary.
  48433. */
  48434. wasmBinaryUrl?: string;
  48435. /**
  48436. * The url to the fallback JavaScript module.
  48437. */
  48438. fallbackUrl?: string;
  48439. };
  48440. }
  48441. /**
  48442. * Draco compression (https://google.github.io/draco/)
  48443. *
  48444. * This class wraps the Draco module.
  48445. *
  48446. * **Encoder**
  48447. *
  48448. * The encoder is not currently implemented.
  48449. *
  48450. * **Decoder**
  48451. *
  48452. * 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.
  48453. *
  48454. * To update the configuration, use the following code:
  48455. * ```javascript
  48456. * BABYLON.DracoCompression.Configuration = {
  48457. * decoder: {
  48458. * wasmUrl: "<url to the WebAssembly library>",
  48459. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48460. * fallbackUrl: "<url to the fallback JavaScript library>",
  48461. * }
  48462. * };
  48463. * ```
  48464. *
  48465. * 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.
  48466. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48467. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48468. *
  48469. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48470. * ```javascript
  48471. * var dracoCompression = new BABYLON.DracoCompression();
  48472. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48473. * [BABYLON.VertexBuffer.PositionKind]: 0
  48474. * });
  48475. * ```
  48476. *
  48477. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48478. */
  48479. class DracoCompression implements IDisposable {
  48480. private static _DecoderModulePromise;
  48481. /**
  48482. * The configuration. Defaults to the following urls:
  48483. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48484. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48485. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48486. */
  48487. static Configuration: IDracoCompressionConfiguration;
  48488. /**
  48489. * Returns true if the decoder is available.
  48490. */
  48491. static readonly DecoderAvailable: boolean;
  48492. /**
  48493. * Constructor
  48494. */
  48495. constructor();
  48496. /**
  48497. * Stop all async operations and release resources.
  48498. */
  48499. dispose(): void;
  48500. /**
  48501. * Decode Draco compressed mesh data to vertex data.
  48502. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48503. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48504. * @returns A promise that resolves with the decoded vertex data
  48505. */
  48506. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48507. [kind: string]: number;
  48508. }): Promise<VertexData>;
  48509. private static _GetDecoderModule;
  48510. private static _LoadScriptAsync;
  48511. private static _LoadFileAsync;
  48512. }
  48513. }
  48514. declare module BABYLON {
  48515. /**
  48516. * Particle emitter emitting particles from the inside of a box.
  48517. * It emits the particles randomly between 2 given directions.
  48518. */
  48519. class BoxParticleEmitter implements IParticleEmitterType {
  48520. /**
  48521. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48522. */
  48523. direction1: Vector3;
  48524. /**
  48525. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48526. */
  48527. direction2: Vector3;
  48528. /**
  48529. * 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.
  48530. */
  48531. minEmitBox: Vector3;
  48532. /**
  48533. * 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.
  48534. */
  48535. maxEmitBox: Vector3;
  48536. /**
  48537. * Creates a new instance BoxParticleEmitter
  48538. */
  48539. constructor();
  48540. /**
  48541. * Called by the particle System when the direction is computed for the created particle.
  48542. * @param worldMatrix is the world matrix of the particle system
  48543. * @param directionToUpdate is the direction vector to update with the result
  48544. * @param particle is the particle we are computed the direction for
  48545. */
  48546. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48547. /**
  48548. * Called by the particle System when the position is computed for the created particle.
  48549. * @param worldMatrix is the world matrix of the particle system
  48550. * @param positionToUpdate is the position vector to update with the result
  48551. * @param particle is the particle we are computed the position for
  48552. */
  48553. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48554. /**
  48555. * Clones the current emitter and returns a copy of it
  48556. * @returns the new emitter
  48557. */
  48558. clone(): BoxParticleEmitter;
  48559. /**
  48560. * Called by the GPUParticleSystem to setup the update shader
  48561. * @param effect defines the update shader
  48562. */
  48563. applyToShader(effect: Effect): void;
  48564. /**
  48565. * Returns a string to use to update the GPU particles update shader
  48566. * @returns a string containng the defines string
  48567. */
  48568. getEffectDefines(): string;
  48569. /**
  48570. * Returns the string "BoxParticleEmitter"
  48571. * @returns a string containing the class name
  48572. */
  48573. getClassName(): string;
  48574. /**
  48575. * Serializes the particle system to a JSON object.
  48576. * @returns the JSON object
  48577. */
  48578. serialize(): any;
  48579. /**
  48580. * Parse properties from a JSON object
  48581. * @param serializationObject defines the JSON object
  48582. */
  48583. parse(serializationObject: any): void;
  48584. }
  48585. }
  48586. declare module BABYLON {
  48587. /**
  48588. * Particle emitter emitting particles from the inside of a cone.
  48589. * It emits the particles alongside the cone volume from the base to the particle.
  48590. * The emission direction might be randomized.
  48591. */
  48592. class ConeParticleEmitter implements IParticleEmitterType {
  48593. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48594. directionRandomizer: number;
  48595. private _radius;
  48596. private _angle;
  48597. private _height;
  48598. /**
  48599. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  48600. */
  48601. radiusRange: number;
  48602. /**
  48603. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  48604. */
  48605. heightRange: number;
  48606. /**
  48607. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  48608. */
  48609. emitFromSpawnPointOnly: boolean;
  48610. /**
  48611. * Gets or sets the radius of the emission cone
  48612. */
  48613. radius: number;
  48614. /**
  48615. * Gets or sets the angle of the emission cone
  48616. */
  48617. angle: number;
  48618. private _buildHeight;
  48619. /**
  48620. * Creates a new instance ConeParticleEmitter
  48621. * @param radius the radius of the emission cone (1 by default)
  48622. * @param angles the cone base angle (PI by default)
  48623. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  48624. */
  48625. constructor(radius?: number, angle?: number,
  48626. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48627. directionRandomizer?: number);
  48628. /**
  48629. * Called by the particle System when the direction is computed for the created particle.
  48630. * @param worldMatrix is the world matrix of the particle system
  48631. * @param directionToUpdate is the direction vector to update with the result
  48632. * @param particle is the particle we are computed the direction for
  48633. */
  48634. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48635. /**
  48636. * Called by the particle System when the position is computed for the created particle.
  48637. * @param worldMatrix is the world matrix of the particle system
  48638. * @param positionToUpdate is the position vector to update with the result
  48639. * @param particle is the particle we are computed the position for
  48640. */
  48641. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48642. /**
  48643. * Clones the current emitter and returns a copy of it
  48644. * @returns the new emitter
  48645. */
  48646. clone(): ConeParticleEmitter;
  48647. /**
  48648. * Called by the GPUParticleSystem to setup the update shader
  48649. * @param effect defines the update shader
  48650. */
  48651. applyToShader(effect: Effect): void;
  48652. /**
  48653. * Returns a string to use to update the GPU particles update shader
  48654. * @returns a string containng the defines string
  48655. */
  48656. getEffectDefines(): string;
  48657. /**
  48658. * Returns the string "ConeParticleEmitter"
  48659. * @returns a string containing the class name
  48660. */
  48661. getClassName(): string;
  48662. /**
  48663. * Serializes the particle system to a JSON object.
  48664. * @returns the JSON object
  48665. */
  48666. serialize(): any;
  48667. /**
  48668. * Parse properties from a JSON object
  48669. * @param serializationObject defines the JSON object
  48670. */
  48671. parse(serializationObject: any): void;
  48672. }
  48673. }
  48674. declare module BABYLON {
  48675. /**
  48676. * Particle emitter emitting particles from the inside of a cylinder.
  48677. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  48678. */
  48679. class CylinderParticleEmitter implements IParticleEmitterType {
  48680. /**
  48681. * The radius of the emission cylinder.
  48682. */
  48683. radius: number;
  48684. /**
  48685. * The height of the emission cylinder.
  48686. */
  48687. height: number;
  48688. /**
  48689. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48690. */
  48691. radiusRange: number;
  48692. /**
  48693. * How much to randomize the particle direction [0-1].
  48694. */
  48695. directionRandomizer: number;
  48696. /**
  48697. * Creates a new instance CylinderParticleEmitter
  48698. * @param radius the radius of the emission cylinder (1 by default)
  48699. * @param height the height of the emission cylinder (1 by default)
  48700. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48701. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48702. */
  48703. constructor(
  48704. /**
  48705. * The radius of the emission cylinder.
  48706. */
  48707. radius?: number,
  48708. /**
  48709. * The height of the emission cylinder.
  48710. */
  48711. height?: number,
  48712. /**
  48713. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48714. */
  48715. radiusRange?: number,
  48716. /**
  48717. * How much to randomize the particle direction [0-1].
  48718. */
  48719. directionRandomizer?: number);
  48720. /**
  48721. * Called by the particle System when the direction is computed for the created particle.
  48722. * @param worldMatrix is the world matrix of the particle system
  48723. * @param directionToUpdate is the direction vector to update with the result
  48724. * @param particle is the particle we are computed the direction for
  48725. */
  48726. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48727. /**
  48728. * Called by the particle System when the position is computed for the created particle.
  48729. * @param worldMatrix is the world matrix of the particle system
  48730. * @param positionToUpdate is the position vector to update with the result
  48731. * @param particle is the particle we are computed the position for
  48732. */
  48733. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48734. /**
  48735. * Clones the current emitter and returns a copy of it
  48736. * @returns the new emitter
  48737. */
  48738. clone(): CylinderParticleEmitter;
  48739. /**
  48740. * Called by the GPUParticleSystem to setup the update shader
  48741. * @param effect defines the update shader
  48742. */
  48743. applyToShader(effect: Effect): void;
  48744. /**
  48745. * Returns a string to use to update the GPU particles update shader
  48746. * @returns a string containng the defines string
  48747. */
  48748. getEffectDefines(): string;
  48749. /**
  48750. * Returns the string "CylinderParticleEmitter"
  48751. * @returns a string containing the class name
  48752. */
  48753. getClassName(): string;
  48754. /**
  48755. * Serializes the particle system to a JSON object.
  48756. * @returns the JSON object
  48757. */
  48758. serialize(): any;
  48759. /**
  48760. * Parse properties from a JSON object
  48761. * @param serializationObject defines the JSON object
  48762. */
  48763. parse(serializationObject: any): void;
  48764. }
  48765. /**
  48766. * Particle emitter emitting particles from the inside of a cylinder.
  48767. * It emits the particles randomly between two vectors.
  48768. */
  48769. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  48770. /**
  48771. * The min limit of the emission direction.
  48772. */
  48773. direction1: Vector3;
  48774. /**
  48775. * The max limit of the emission direction.
  48776. */
  48777. direction2: Vector3;
  48778. /**
  48779. * Creates a new instance CylinderDirectedParticleEmitter
  48780. * @param radius the radius of the emission cylinder (1 by default)
  48781. * @param height the height of the emission cylinder (1 by default)
  48782. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48783. * @param direction1 the min limit of the emission direction (up vector by default)
  48784. * @param direction2 the max limit of the emission direction (up vector by default)
  48785. */
  48786. constructor(radius?: number, height?: number, radiusRange?: number,
  48787. /**
  48788. * The min limit of the emission direction.
  48789. */
  48790. direction1?: Vector3,
  48791. /**
  48792. * The max limit of the emission direction.
  48793. */
  48794. direction2?: Vector3);
  48795. /**
  48796. * Called by the particle System when the direction is computed for the created particle.
  48797. * @param worldMatrix is the world matrix of the particle system
  48798. * @param directionToUpdate is the direction vector to update with the result
  48799. * @param particle is the particle we are computed the direction for
  48800. */
  48801. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48802. /**
  48803. * Clones the current emitter and returns a copy of it
  48804. * @returns the new emitter
  48805. */
  48806. clone(): CylinderDirectedParticleEmitter;
  48807. /**
  48808. * Called by the GPUParticleSystem to setup the update shader
  48809. * @param effect defines the update shader
  48810. */
  48811. applyToShader(effect: Effect): void;
  48812. /**
  48813. * Returns a string to use to update the GPU particles update shader
  48814. * @returns a string containng the defines string
  48815. */
  48816. getEffectDefines(): string;
  48817. /**
  48818. * Returns the string "CylinderDirectedParticleEmitter"
  48819. * @returns a string containing the class name
  48820. */
  48821. getClassName(): string;
  48822. /**
  48823. * Serializes the particle system to a JSON object.
  48824. * @returns the JSON object
  48825. */
  48826. serialize(): any;
  48827. /**
  48828. * Parse properties from a JSON object
  48829. * @param serializationObject defines the JSON object
  48830. */
  48831. parse(serializationObject: any): void;
  48832. }
  48833. }
  48834. declare module BABYLON {
  48835. /**
  48836. * Particle emitter emitting particles from the inside of a hemisphere.
  48837. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  48838. */
  48839. class HemisphericParticleEmitter implements IParticleEmitterType {
  48840. /**
  48841. * The radius of the emission hemisphere.
  48842. */
  48843. radius: number;
  48844. /**
  48845. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48846. */
  48847. radiusRange: number;
  48848. /**
  48849. * How much to randomize the particle direction [0-1].
  48850. */
  48851. directionRandomizer: number;
  48852. /**
  48853. * Creates a new instance HemisphericParticleEmitter
  48854. * @param radius the radius of the emission hemisphere (1 by default)
  48855. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48856. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48857. */
  48858. constructor(
  48859. /**
  48860. * The radius of the emission hemisphere.
  48861. */
  48862. radius?: number,
  48863. /**
  48864. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48865. */
  48866. radiusRange?: number,
  48867. /**
  48868. * How much to randomize the particle direction [0-1].
  48869. */
  48870. directionRandomizer?: number);
  48871. /**
  48872. * Called by the particle System when the direction is computed for the created particle.
  48873. * @param worldMatrix is the world matrix of the particle system
  48874. * @param directionToUpdate is the direction vector to update with the result
  48875. * @param particle is the particle we are computed the direction for
  48876. */
  48877. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48878. /**
  48879. * Called by the particle System when the position is computed for the created particle.
  48880. * @param worldMatrix is the world matrix of the particle system
  48881. * @param positionToUpdate is the position vector to update with the result
  48882. * @param particle is the particle we are computed the position for
  48883. */
  48884. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48885. /**
  48886. * Clones the current emitter and returns a copy of it
  48887. * @returns the new emitter
  48888. */
  48889. clone(): HemisphericParticleEmitter;
  48890. /**
  48891. * Called by the GPUParticleSystem to setup the update shader
  48892. * @param effect defines the update shader
  48893. */
  48894. applyToShader(effect: Effect): void;
  48895. /**
  48896. * Returns a string to use to update the GPU particles update shader
  48897. * @returns a string containng the defines string
  48898. */
  48899. getEffectDefines(): string;
  48900. /**
  48901. * Returns the string "HemisphericParticleEmitter"
  48902. * @returns a string containing the class name
  48903. */
  48904. getClassName(): string;
  48905. /**
  48906. * Serializes the particle system to a JSON object.
  48907. * @returns the JSON object
  48908. */
  48909. serialize(): any;
  48910. /**
  48911. * Parse properties from a JSON object
  48912. * @param serializationObject defines the JSON object
  48913. */
  48914. parse(serializationObject: any): void;
  48915. }
  48916. }
  48917. declare module BABYLON {
  48918. /**
  48919. * Particle emitter represents a volume emitting particles.
  48920. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  48921. */
  48922. interface IParticleEmitterType {
  48923. /**
  48924. * Called by the particle System when the direction is computed for the created particle.
  48925. * @param worldMatrix is the world matrix of the particle system
  48926. * @param directionToUpdate is the direction vector to update with the result
  48927. * @param particle is the particle we are computed the direction for
  48928. */
  48929. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48930. /**
  48931. * Called by the particle System when the position is computed for the created particle.
  48932. * @param worldMatrix is the world matrix of the particle system
  48933. * @param positionToUpdate is the position vector to update with the result
  48934. * @param particle is the particle we are computed the position for
  48935. */
  48936. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48937. /**
  48938. * Clones the current emitter and returns a copy of it
  48939. * @returns the new emitter
  48940. */
  48941. clone(): IParticleEmitterType;
  48942. /**
  48943. * Called by the GPUParticleSystem to setup the update shader
  48944. * @param effect defines the update shader
  48945. */
  48946. applyToShader(effect: Effect): void;
  48947. /**
  48948. * Returns a string to use to update the GPU particles update shader
  48949. * @returns the effect defines string
  48950. */
  48951. getEffectDefines(): string;
  48952. /**
  48953. * Returns a string representing the class name
  48954. * @returns a string containing the class name
  48955. */
  48956. getClassName(): string;
  48957. /**
  48958. * Serializes the particle system to a JSON object.
  48959. * @returns the JSON object
  48960. */
  48961. serialize(): any;
  48962. /**
  48963. * Parse properties from a JSON object
  48964. * @param serializationObject defines the JSON object
  48965. */
  48966. parse(serializationObject: any): void;
  48967. }
  48968. }
  48969. declare module BABYLON {
  48970. /**
  48971. * Particle emitter emitting particles from a point.
  48972. * It emits the particles randomly between 2 given directions.
  48973. */
  48974. class PointParticleEmitter implements IParticleEmitterType {
  48975. /**
  48976. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48977. */
  48978. direction1: Vector3;
  48979. /**
  48980. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48981. */
  48982. direction2: Vector3;
  48983. /**
  48984. * Creates a new instance PointParticleEmitter
  48985. */
  48986. constructor();
  48987. /**
  48988. * Called by the particle System when the direction is computed for the created particle.
  48989. * @param worldMatrix is the world matrix of the particle system
  48990. * @param directionToUpdate is the direction vector to update with the result
  48991. * @param particle is the particle we are computed the direction for
  48992. */
  48993. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48994. /**
  48995. * Called by the particle System when the position is computed for the created particle.
  48996. * @param worldMatrix is the world matrix of the particle system
  48997. * @param positionToUpdate is the position vector to update with the result
  48998. * @param particle is the particle we are computed the position for
  48999. */
  49000. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49001. /**
  49002. * Clones the current emitter and returns a copy of it
  49003. * @returns the new emitter
  49004. */
  49005. clone(): PointParticleEmitter;
  49006. /**
  49007. * Called by the GPUParticleSystem to setup the update shader
  49008. * @param effect defines the update shader
  49009. */
  49010. applyToShader(effect: Effect): void;
  49011. /**
  49012. * Returns a string to use to update the GPU particles update shader
  49013. * @returns a string containng the defines string
  49014. */
  49015. getEffectDefines(): string;
  49016. /**
  49017. * Returns the string "PointParticleEmitter"
  49018. * @returns a string containing the class name
  49019. */
  49020. getClassName(): string;
  49021. /**
  49022. * Serializes the particle system to a JSON object.
  49023. * @returns the JSON object
  49024. */
  49025. serialize(): any;
  49026. /**
  49027. * Parse properties from a JSON object
  49028. * @param serializationObject defines the JSON object
  49029. */
  49030. parse(serializationObject: any): void;
  49031. }
  49032. }
  49033. declare module BABYLON {
  49034. /**
  49035. * Particle emitter emitting particles from the inside of a sphere.
  49036. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  49037. */
  49038. class SphereParticleEmitter implements IParticleEmitterType {
  49039. /**
  49040. * The radius of the emission sphere.
  49041. */
  49042. radius: number;
  49043. /**
  49044. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49045. */
  49046. radiusRange: number;
  49047. /**
  49048. * How much to randomize the particle direction [0-1].
  49049. */
  49050. directionRandomizer: number;
  49051. /**
  49052. * Creates a new instance SphereParticleEmitter
  49053. * @param radius the radius of the emission sphere (1 by default)
  49054. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49055. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  49056. */
  49057. constructor(
  49058. /**
  49059. * The radius of the emission sphere.
  49060. */
  49061. radius?: number,
  49062. /**
  49063. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49064. */
  49065. radiusRange?: number,
  49066. /**
  49067. * How much to randomize the particle direction [0-1].
  49068. */
  49069. directionRandomizer?: number);
  49070. /**
  49071. * Called by the particle System when the direction is computed for the created particle.
  49072. * @param worldMatrix is the world matrix of the particle system
  49073. * @param directionToUpdate is the direction vector to update with the result
  49074. * @param particle is the particle we are computed the direction for
  49075. */
  49076. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49077. /**
  49078. * Called by the particle System when the position is computed for the created particle.
  49079. * @param worldMatrix is the world matrix of the particle system
  49080. * @param positionToUpdate is the position vector to update with the result
  49081. * @param particle is the particle we are computed the position for
  49082. */
  49083. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49084. /**
  49085. * Clones the current emitter and returns a copy of it
  49086. * @returns the new emitter
  49087. */
  49088. clone(): SphereParticleEmitter;
  49089. /**
  49090. * Called by the GPUParticleSystem to setup the update shader
  49091. * @param effect defines the update shader
  49092. */
  49093. applyToShader(effect: Effect): void;
  49094. /**
  49095. * Returns a string to use to update the GPU particles update shader
  49096. * @returns a string containng the defines string
  49097. */
  49098. getEffectDefines(): string;
  49099. /**
  49100. * Returns the string "SphereParticleEmitter"
  49101. * @returns a string containing the class name
  49102. */
  49103. getClassName(): string;
  49104. /**
  49105. * Serializes the particle system to a JSON object.
  49106. * @returns the JSON object
  49107. */
  49108. serialize(): any;
  49109. /**
  49110. * Parse properties from a JSON object
  49111. * @param serializationObject defines the JSON object
  49112. */
  49113. parse(serializationObject: any): void;
  49114. }
  49115. /**
  49116. * Particle emitter emitting particles from the inside of a sphere.
  49117. * It emits the particles randomly between two vectors.
  49118. */
  49119. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  49120. /**
  49121. * The min limit of the emission direction.
  49122. */
  49123. direction1: Vector3;
  49124. /**
  49125. * The max limit of the emission direction.
  49126. */
  49127. direction2: Vector3;
  49128. /**
  49129. * Creates a new instance SphereDirectedParticleEmitter
  49130. * @param radius the radius of the emission sphere (1 by default)
  49131. * @param direction1 the min limit of the emission direction (up vector by default)
  49132. * @param direction2 the max limit of the emission direction (up vector by default)
  49133. */
  49134. constructor(radius?: number,
  49135. /**
  49136. * The min limit of the emission direction.
  49137. */
  49138. direction1?: Vector3,
  49139. /**
  49140. * The max limit of the emission direction.
  49141. */
  49142. direction2?: Vector3);
  49143. /**
  49144. * Called by the particle System when the direction is computed for the created particle.
  49145. * @param worldMatrix is the world matrix of the particle system
  49146. * @param directionToUpdate is the direction vector to update with the result
  49147. * @param particle is the particle we are computed the direction for
  49148. */
  49149. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49150. /**
  49151. * Clones the current emitter and returns a copy of it
  49152. * @returns the new emitter
  49153. */
  49154. clone(): SphereDirectedParticleEmitter;
  49155. /**
  49156. * Called by the GPUParticleSystem to setup the update shader
  49157. * @param effect defines the update shader
  49158. */
  49159. applyToShader(effect: Effect): void;
  49160. /**
  49161. * Returns a string to use to update the GPU particles update shader
  49162. * @returns a string containng the defines string
  49163. */
  49164. getEffectDefines(): string;
  49165. /**
  49166. * Returns the string "SphereDirectedParticleEmitter"
  49167. * @returns a string containing the class name
  49168. */
  49169. getClassName(): string;
  49170. /**
  49171. * Serializes the particle system to a JSON object.
  49172. * @returns the JSON object
  49173. */
  49174. serialize(): any;
  49175. /**
  49176. * Parse properties from a JSON object
  49177. * @param serializationObject defines the JSON object
  49178. */
  49179. parse(serializationObject: any): void;
  49180. }
  49181. }
  49182. declare module BABYLON {
  49183. /** @hidden */
  49184. class CannonJSPlugin implements IPhysicsEnginePlugin {
  49185. private _useDeltaForWorldStep;
  49186. world: any;
  49187. name: string;
  49188. private _physicsMaterials;
  49189. private _fixedTimeStep;
  49190. BJSCANNON: any;
  49191. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  49192. setGravity(gravity: Vector3): void;
  49193. setTimeStep(timeStep: number): void;
  49194. getTimeStep(): number;
  49195. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49196. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49197. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49198. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49199. private _processChildMeshes;
  49200. removePhysicsBody(impostor: PhysicsImpostor): void;
  49201. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49202. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49203. private _addMaterial;
  49204. private _checkWithEpsilon;
  49205. private _createShape;
  49206. private _createHeightmap;
  49207. private _minus90X;
  49208. private _plus90X;
  49209. private _tmpPosition;
  49210. private _tmpDeltaPosition;
  49211. private _tmpUnityRotation;
  49212. private _updatePhysicsBodyTransformation;
  49213. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49214. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49215. isSupported(): boolean;
  49216. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49217. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49218. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49219. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49220. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49221. getBodyMass(impostor: PhysicsImpostor): number;
  49222. getBodyFriction(impostor: PhysicsImpostor): number;
  49223. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49224. getBodyRestitution(impostor: PhysicsImpostor): number;
  49225. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49226. sleepBody(impostor: PhysicsImpostor): void;
  49227. wakeUpBody(impostor: PhysicsImpostor): void;
  49228. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49229. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49230. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49231. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49232. getRadius(impostor: PhysicsImpostor): number;
  49233. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49234. dispose(): void;
  49235. private _extendNamespace;
  49236. }
  49237. }
  49238. declare module BABYLON {
  49239. /** @hidden */
  49240. class OimoJSPlugin implements IPhysicsEnginePlugin {
  49241. world: any;
  49242. name: string;
  49243. BJSOIMO: any;
  49244. constructor(iterations?: number);
  49245. setGravity(gravity: Vector3): void;
  49246. setTimeStep(timeStep: number): void;
  49247. getTimeStep(): number;
  49248. private _tmpImpostorsArray;
  49249. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49250. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49251. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49252. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49253. private _tmpPositionVector;
  49254. removePhysicsBody(impostor: PhysicsImpostor): void;
  49255. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49256. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49257. isSupported(): boolean;
  49258. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49259. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49260. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49261. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49262. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49263. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49264. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49265. getBodyMass(impostor: PhysicsImpostor): number;
  49266. getBodyFriction(impostor: PhysicsImpostor): number;
  49267. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49268. getBodyRestitution(impostor: PhysicsImpostor): number;
  49269. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49270. sleepBody(impostor: PhysicsImpostor): void;
  49271. wakeUpBody(impostor: PhysicsImpostor): void;
  49272. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49273. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  49274. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49275. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49276. getRadius(impostor: PhysicsImpostor): number;
  49277. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49278. dispose(): void;
  49279. }
  49280. }
  49281. declare module BABYLON {
  49282. /**
  49283. * This represents a set of one or more post processes in Babylon.
  49284. * A post process can be used to apply a shader to a texture after it is rendered.
  49285. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49286. */
  49287. class PostProcessRenderEffect {
  49288. private _postProcesses;
  49289. private _getPostProcesses;
  49290. private _singleInstance;
  49291. private _cameras;
  49292. private _indicesForCamera;
  49293. /**
  49294. * Name of the effect
  49295. * @hidden
  49296. */
  49297. _name: string;
  49298. /**
  49299. * Instantiates a post process render effect.
  49300. * A post process can be used to apply a shader to a texture after it is rendered.
  49301. * @param engine The engine the effect is tied to
  49302. * @param name The name of the effect
  49303. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49304. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49305. */
  49306. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49307. /**
  49308. * Checks if all the post processes in the effect are supported.
  49309. */
  49310. readonly isSupported: boolean;
  49311. /**
  49312. * Updates the current state of the effect
  49313. * @hidden
  49314. */
  49315. _update(): void;
  49316. /**
  49317. * Attaches the effect on cameras
  49318. * @param cameras The camera to attach to.
  49319. * @hidden
  49320. */
  49321. _attachCameras(cameras: Camera): void;
  49322. /**
  49323. * Attaches the effect on cameras
  49324. * @param cameras The camera to attach to.
  49325. * @hidden
  49326. */
  49327. _attachCameras(cameras: Camera[]): void;
  49328. /**
  49329. * Detatches the effect on cameras
  49330. * @param cameras The camera to detatch from.
  49331. * @hidden
  49332. */
  49333. _detachCameras(cameras: Camera): void;
  49334. /**
  49335. * Detatches the effect on cameras
  49336. * @param cameras The camera to detatch from.
  49337. * @hidden
  49338. */
  49339. _detachCameras(cameras: Camera[]): void;
  49340. /**
  49341. * Enables the effect on given cameras
  49342. * @param cameras The camera to enable.
  49343. * @hidden
  49344. */
  49345. _enable(cameras: Camera): void;
  49346. /**
  49347. * Enables the effect on given cameras
  49348. * @param cameras The camera to enable.
  49349. * @hidden
  49350. */
  49351. _enable(cameras: Nullable<Camera[]>): void;
  49352. /**
  49353. * Disables the effect on the given cameras
  49354. * @param cameras The camera to disable.
  49355. * @hidden
  49356. */
  49357. _disable(cameras: Camera): void;
  49358. /**
  49359. * Disables the effect on the given cameras
  49360. * @param cameras The camera to disable.
  49361. * @hidden
  49362. */
  49363. _disable(cameras: Nullable<Camera[]>): void;
  49364. /**
  49365. * Gets a list of the post processes contained in the effect.
  49366. * @param camera The camera to get the post processes on.
  49367. * @returns The list of the post processes in the effect.
  49368. */
  49369. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  49370. }
  49371. }
  49372. declare module BABYLON {
  49373. /**
  49374. * PostProcessRenderPipeline
  49375. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49376. */
  49377. class PostProcessRenderPipeline {
  49378. private engine;
  49379. private _renderEffects;
  49380. private _renderEffectsForIsolatedPass;
  49381. /**
  49382. * @hidden
  49383. */
  49384. protected _cameras: Camera[];
  49385. /** @hidden */
  49386. _name: string;
  49387. /**
  49388. * Initializes a PostProcessRenderPipeline
  49389. * @param engine engine to add the pipeline to
  49390. * @param name name of the pipeline
  49391. */
  49392. constructor(engine: Engine, name: string);
  49393. /**
  49394. * "PostProcessRenderPipeline"
  49395. * @returns "PostProcessRenderPipeline"
  49396. */
  49397. getClassName(): string;
  49398. /**
  49399. * If all the render effects in the pipeline are support
  49400. */
  49401. readonly isSupported: boolean;
  49402. /**
  49403. * Adds an effect to the pipeline
  49404. * @param renderEffect the effect to add
  49405. */
  49406. addEffect(renderEffect: PostProcessRenderEffect): void;
  49407. /** @hidden */
  49408. _rebuild(): void;
  49409. /** @hidden */
  49410. _enableEffect(renderEffectName: string, cameras: Camera): void;
  49411. /** @hidden */
  49412. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49413. /** @hidden */
  49414. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49415. /** @hidden */
  49416. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49417. /** @hidden */
  49418. _attachCameras(cameras: Camera, unique: boolean): void;
  49419. /** @hidden */
  49420. _attachCameras(cameras: Camera[], unique: boolean): void;
  49421. /** @hidden */
  49422. _detachCameras(cameras: Camera): void;
  49423. /** @hidden */
  49424. _detachCameras(cameras: Nullable<Camera[]>): void;
  49425. /** @hidden */
  49426. _update(): void;
  49427. /** @hidden */
  49428. _reset(): void;
  49429. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49430. /**
  49431. * Disposes of the pipeline
  49432. */
  49433. dispose(): void;
  49434. }
  49435. }
  49436. declare module BABYLON {
  49437. /**
  49438. * PostProcessRenderPipelineManager class
  49439. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49440. */
  49441. class PostProcessRenderPipelineManager {
  49442. private _renderPipelines;
  49443. /**
  49444. * Initializes a PostProcessRenderPipelineManager
  49445. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49446. */
  49447. constructor();
  49448. /**
  49449. * Adds a pipeline to the manager
  49450. * @param renderPipeline The pipeline to add
  49451. */
  49452. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  49453. /**
  49454. * Attaches a camera to the pipeline
  49455. * @param renderPipelineName The name of the pipeline to attach to
  49456. * @param cameras the camera to attach
  49457. * @param unique if the camera can be attached multiple times to the pipeline
  49458. */
  49459. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  49460. /**
  49461. * Detaches a camera from the pipeline
  49462. * @param renderPipelineName The name of the pipeline to detach from
  49463. * @param cameras the camera to detach
  49464. */
  49465. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  49466. /**
  49467. * Enables an effect by name on a pipeline
  49468. * @param renderPipelineName the name of the pipeline to enable the effect in
  49469. * @param renderEffectName the name of the effect to enable
  49470. * @param cameras the cameras that the effect should be enabled on
  49471. */
  49472. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49473. /**
  49474. * Disables an effect by name on a pipeline
  49475. * @param renderPipelineName the name of the pipeline to disable the effect in
  49476. * @param renderEffectName the name of the effect to disable
  49477. * @param cameras the cameras that the effect should be disabled on
  49478. */
  49479. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49480. /**
  49481. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  49482. */
  49483. update(): void;
  49484. /** @hidden */
  49485. _rebuild(): void;
  49486. /**
  49487. * Disposes of the manager and pipelines
  49488. */
  49489. dispose(): void;
  49490. }
  49491. }
  49492. declare module BABYLON {
  49493. interface Scene {
  49494. /** @hidden (Backing field) */
  49495. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49496. /**
  49497. * Gets the postprocess render pipeline manager
  49498. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49499. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49500. */
  49501. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49502. }
  49503. /**
  49504. * Defines the Render Pipeline scene component responsible to rendering pipelines
  49505. */
  49506. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  49507. /**
  49508. * The component name helpfull to identify the component in the list of scene components.
  49509. */
  49510. readonly name: string;
  49511. /**
  49512. * The scene the component belongs to.
  49513. */
  49514. scene: Scene;
  49515. /**
  49516. * Creates a new instance of the component for the given scene
  49517. * @param scene Defines the scene to register the component in
  49518. */
  49519. constructor(scene: Scene);
  49520. /**
  49521. * Registers the component in a given scene
  49522. */
  49523. register(): void;
  49524. /**
  49525. * Rebuilds the elements related to this component in case of
  49526. * context lost for instance.
  49527. */
  49528. rebuild(): void;
  49529. /**
  49530. * Disposes the component and the associated ressources
  49531. */
  49532. dispose(): void;
  49533. private _gatherRenderTargets;
  49534. }
  49535. }
  49536. declare module BABYLON {
  49537. /**
  49538. * Helper class dealing with the extraction of spherical polynomial dataArray
  49539. * from a cube map.
  49540. */
  49541. class CubeMapToSphericalPolynomialTools {
  49542. private static FileFaces;
  49543. /**
  49544. * Converts a texture to the according Spherical Polynomial data.
  49545. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49546. *
  49547. * @param texture The texture to extract the information from.
  49548. * @return The Spherical Polynomial data.
  49549. */
  49550. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49551. /**
  49552. * Converts a cubemap to the according Spherical Polynomial data.
  49553. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49554. *
  49555. * @param cubeInfo The Cube map to extract the information from.
  49556. * @return The Spherical Polynomial data.
  49557. */
  49558. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49559. }
  49560. }
  49561. declare module BABYLON {
  49562. /**
  49563. * Header information of HDR texture files.
  49564. */
  49565. interface HDRInfo {
  49566. /**
  49567. * The height of the texture in pixels.
  49568. */
  49569. height: number;
  49570. /**
  49571. * The width of the texture in pixels.
  49572. */
  49573. width: number;
  49574. /**
  49575. * The index of the beginning of the data in the binary file.
  49576. */
  49577. dataPosition: number;
  49578. }
  49579. /**
  49580. * This groups tools to convert HDR texture to native colors array.
  49581. */
  49582. class HDRTools {
  49583. private static Ldexp;
  49584. private static Rgbe2float;
  49585. private static readStringLine;
  49586. /**
  49587. * Reads header information from an RGBE texture stored in a native array.
  49588. * More information on this format are available here:
  49589. * https://en.wikipedia.org/wiki/RGBE_image_format
  49590. *
  49591. * @param uint8array The binary file stored in native array.
  49592. * @return The header information.
  49593. */
  49594. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49595. /**
  49596. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49597. * This RGBE texture needs to store the information as a panorama.
  49598. *
  49599. * More information on this format are available here:
  49600. * https://en.wikipedia.org/wiki/RGBE_image_format
  49601. *
  49602. * @param buffer The binary file stored in an array buffer.
  49603. * @param size The expected size of the extracted cubemap.
  49604. * @return The Cube Map information.
  49605. */
  49606. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49607. /**
  49608. * Returns the pixels data extracted from an RGBE texture.
  49609. * This pixels will be stored left to right up to down in the R G B order in one array.
  49610. *
  49611. * More information on this format are available here:
  49612. * https://en.wikipedia.org/wiki/RGBE_image_format
  49613. *
  49614. * @param uint8array The binary file stored in an array buffer.
  49615. * @param hdrInfo The header information of the file.
  49616. * @return The pixels data in RGB right to left up to down order.
  49617. */
  49618. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49619. private static RGBE_ReadPixels_RLE;
  49620. }
  49621. }
  49622. declare module BABYLON {
  49623. /**
  49624. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49625. */
  49626. interface CubeMapInfo {
  49627. /**
  49628. * The pixel array for the front face.
  49629. * This is stored in format, left to right, up to down format.
  49630. */
  49631. front: Nullable<ArrayBufferView>;
  49632. /**
  49633. * The pixel array for the back face.
  49634. * This is stored in format, left to right, up to down format.
  49635. */
  49636. back: Nullable<ArrayBufferView>;
  49637. /**
  49638. * The pixel array for the left face.
  49639. * This is stored in format, left to right, up to down format.
  49640. */
  49641. left: Nullable<ArrayBufferView>;
  49642. /**
  49643. * The pixel array for the right face.
  49644. * This is stored in format, left to right, up to down format.
  49645. */
  49646. right: Nullable<ArrayBufferView>;
  49647. /**
  49648. * The pixel array for the up face.
  49649. * This is stored in format, left to right, up to down format.
  49650. */
  49651. up: Nullable<ArrayBufferView>;
  49652. /**
  49653. * The pixel array for the down face.
  49654. * This is stored in format, left to right, up to down format.
  49655. */
  49656. down: Nullable<ArrayBufferView>;
  49657. /**
  49658. * The size of the cubemap stored.
  49659. *
  49660. * Each faces will be size * size pixels.
  49661. */
  49662. size: number;
  49663. /**
  49664. * The format of the texture.
  49665. *
  49666. * RGBA, RGB.
  49667. */
  49668. format: number;
  49669. /**
  49670. * The type of the texture data.
  49671. *
  49672. * UNSIGNED_INT, FLOAT.
  49673. */
  49674. type: number;
  49675. /**
  49676. * Specifies whether the texture is in gamma space.
  49677. */
  49678. gammaSpace: boolean;
  49679. }
  49680. /**
  49681. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49682. */
  49683. class PanoramaToCubeMapTools {
  49684. private static FACE_FRONT;
  49685. private static FACE_BACK;
  49686. private static FACE_RIGHT;
  49687. private static FACE_LEFT;
  49688. private static FACE_DOWN;
  49689. private static FACE_UP;
  49690. /**
  49691. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49692. *
  49693. * @param float32Array The source data.
  49694. * @param inputWidth The width of the input panorama.
  49695. * @param inputHeight The height of the input panorama.
  49696. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49697. * @return The cubemap data
  49698. */
  49699. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49700. private static CreateCubemapTexture;
  49701. private static CalcProjectionSpherical;
  49702. }
  49703. }
  49704. declare module BABYLON {
  49705. }
  49706. declare module BABYLON {
  49707. }
  49708. declare module BABYLON {
  49709. }
  49710. declare module BABYLON {
  49711. }
  49712. declare module BABYLON {
  49713. /**
  49714. * 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.
  49715. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49716. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49717. */
  49718. class CustomProceduralTexture extends ProceduralTexture {
  49719. private _animate;
  49720. private _time;
  49721. private _config;
  49722. private _texturePath;
  49723. /**
  49724. * Instantiates a new Custom Procedural Texture.
  49725. * 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.
  49726. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49727. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49728. * @param name Define the name of the texture
  49729. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49730. * @param size Define the size of the texture to create
  49731. * @param scene Define the scene the texture belongs to
  49732. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49733. * @param generateMipMaps Define if the texture should creates mip maps or not
  49734. */
  49735. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49736. private _loadJson;
  49737. /**
  49738. * Is the texture ready to be used ? (rendered at least once)
  49739. * @returns true if ready, otherwise, false.
  49740. */
  49741. isReady(): boolean;
  49742. /**
  49743. * Render the texture to its associated render target.
  49744. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49745. */
  49746. render(useCameraPostProcess?: boolean): void;
  49747. /**
  49748. * Update the list of dependant textures samplers in the shader.
  49749. */
  49750. updateTextures(): void;
  49751. /**
  49752. * Update the uniform values of the procedural texture in the shader.
  49753. */
  49754. updateShaderUniforms(): void;
  49755. /**
  49756. * Define if the texture animates or not.
  49757. */
  49758. animate: boolean;
  49759. }
  49760. }
  49761. declare module BABYLON {
  49762. /**
  49763. * Class used to generate noise procedural textures
  49764. */
  49765. class NoiseProceduralTexture extends ProceduralTexture {
  49766. private _time;
  49767. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49768. brightness: number;
  49769. /** Defines the number of octaves to process */
  49770. octaves: number;
  49771. /** Defines the level of persistence (0.8 by default) */
  49772. persistence: number;
  49773. /** Gets or sets animation speed factor (default is 1) */
  49774. animationSpeedFactor: number;
  49775. /**
  49776. * Creates a new NoiseProceduralTexture
  49777. * @param name defines the name fo the texture
  49778. * @param size defines the size of the texture (default is 256)
  49779. * @param scene defines the hosting scene
  49780. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49781. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49782. */
  49783. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49784. private _updateShaderUniforms;
  49785. protected _getDefines(): string;
  49786. /** Generate the current state of the procedural texture */
  49787. render(useCameraPostProcess?: boolean): void;
  49788. /**
  49789. * Serializes this noise procedural texture
  49790. * @returns a serialized noise procedural texture object
  49791. */
  49792. serialize(): any;
  49793. /**
  49794. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49795. * @param parsedTexture defines parsed texture data
  49796. * @param scene defines the current scene
  49797. * @param rootUrl defines the root URL containing noise procedural texture information
  49798. * @returns a parsed NoiseProceduralTexture
  49799. */
  49800. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  49801. }
  49802. }
  49803. declare module BABYLON {
  49804. /**
  49805. * 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.
  49806. * This is the base class of any Procedural texture and contains most of the shareable code.
  49807. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49808. */
  49809. class ProceduralTexture extends Texture {
  49810. isCube: boolean;
  49811. /**
  49812. * Define if the texture is enabled or not (disabled texture will not render)
  49813. */
  49814. isEnabled: boolean;
  49815. /**
  49816. * Define if the texture must be cleared before rendering (default is true)
  49817. */
  49818. autoClear: boolean;
  49819. /**
  49820. * Callback called when the texture is generated
  49821. */
  49822. onGenerated: () => void;
  49823. /**
  49824. * Event raised when the texture is generated
  49825. */
  49826. onGeneratedObservable: Observable<ProceduralTexture>;
  49827. /** @hidden */
  49828. _generateMipMaps: boolean;
  49829. /** @hidden **/
  49830. _effect: Effect;
  49831. /** @hidden */
  49832. _textures: {
  49833. [key: string]: Texture;
  49834. };
  49835. private _size;
  49836. private _currentRefreshId;
  49837. private _refreshRate;
  49838. private _vertexBuffers;
  49839. private _indexBuffer;
  49840. private _uniforms;
  49841. private _samplers;
  49842. private _fragment;
  49843. private _floats;
  49844. private _ints;
  49845. private _floatsArrays;
  49846. private _colors3;
  49847. private _colors4;
  49848. private _vectors2;
  49849. private _vectors3;
  49850. private _matrices;
  49851. private _fallbackTexture;
  49852. private _fallbackTextureUsed;
  49853. private _engine;
  49854. private _cachedDefines;
  49855. private _contentUpdateId;
  49856. private _contentData;
  49857. /**
  49858. * Instantiates a new procedural texture.
  49859. * 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.
  49860. * This is the base class of any Procedural texture and contains most of the shareable code.
  49861. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49862. * @param name Define the name of the texture
  49863. * @param size Define the size of the texture to create
  49864. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  49865. * @param scene Define the scene the texture belongs to
  49866. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49867. * @param generateMipMaps Define if the texture should creates mip maps or not
  49868. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  49869. */
  49870. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  49871. /**
  49872. * The effect that is created when initializing the post process.
  49873. * @returns The created effect corrisponding the the postprocess.
  49874. */
  49875. getEffect(): Effect;
  49876. /**
  49877. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  49878. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  49879. */
  49880. getContent(): Nullable<ArrayBufferView>;
  49881. private _createIndexBuffer;
  49882. /** @hidden */
  49883. _rebuild(): void;
  49884. /**
  49885. * Resets the texture in order to recreate its associated resources.
  49886. * This can be called in case of context loss
  49887. */
  49888. reset(): void;
  49889. protected _getDefines(): string;
  49890. /**
  49891. * Is the texture ready to be used ? (rendered at least once)
  49892. * @returns true if ready, otherwise, false.
  49893. */
  49894. isReady(): boolean;
  49895. /**
  49896. * Resets the refresh counter of the texture and start bak from scratch.
  49897. * Could be useful to regenerate the texture if it is setup to render only once.
  49898. */
  49899. resetRefreshCounter(): void;
  49900. /**
  49901. * Set the fragment shader to use in order to render the texture.
  49902. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  49903. */
  49904. setFragment(fragment: any): void;
  49905. /**
  49906. * Define the refresh rate of the texture or the rendering frequency.
  49907. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  49908. */
  49909. refreshRate: number;
  49910. /** @hidden */
  49911. _shouldRender(): boolean;
  49912. /**
  49913. * Get the size the texture is rendering at.
  49914. * @returns the size (texture is always squared)
  49915. */
  49916. getRenderSize(): number;
  49917. /**
  49918. * Resize the texture to new value.
  49919. * @param size Define the new size the texture should have
  49920. * @param generateMipMaps Define whether the new texture should create mip maps
  49921. */
  49922. resize(size: number, generateMipMaps: boolean): void;
  49923. private _checkUniform;
  49924. /**
  49925. * Set a texture in the shader program used to render.
  49926. * @param name Define the name of the uniform samplers as defined in the shader
  49927. * @param texture Define the texture to bind to this sampler
  49928. * @return the texture itself allowing "fluent" like uniform updates
  49929. */
  49930. setTexture(name: string, texture: Texture): ProceduralTexture;
  49931. /**
  49932. * Set a float in the shader.
  49933. * @param name Define the name of the uniform as defined in the shader
  49934. * @param value Define the value to give to the uniform
  49935. * @return the texture itself allowing "fluent" like uniform updates
  49936. */
  49937. setFloat(name: string, value: number): ProceduralTexture;
  49938. /**
  49939. * Set a int in the shader.
  49940. * @param name Define the name of the uniform as defined in the shader
  49941. * @param value Define the value to give to the uniform
  49942. * @return the texture itself allowing "fluent" like uniform updates
  49943. */
  49944. setInt(name: string, value: number): ProceduralTexture;
  49945. /**
  49946. * Set an array of floats in the shader.
  49947. * @param name Define the name of the uniform as defined in the shader
  49948. * @param value Define the value to give to the uniform
  49949. * @return the texture itself allowing "fluent" like uniform updates
  49950. */
  49951. setFloats(name: string, value: number[]): ProceduralTexture;
  49952. /**
  49953. * Set a vec3 in the shader from a Color3.
  49954. * @param name Define the name of the uniform as defined in the shader
  49955. * @param value Define the value to give to the uniform
  49956. * @return the texture itself allowing "fluent" like uniform updates
  49957. */
  49958. setColor3(name: string, value: Color3): ProceduralTexture;
  49959. /**
  49960. * Set a vec4 in the shader from a Color4.
  49961. * @param name Define the name of the uniform as defined in the shader
  49962. * @param value Define the value to give to the uniform
  49963. * @return the texture itself allowing "fluent" like uniform updates
  49964. */
  49965. setColor4(name: string, value: Color4): ProceduralTexture;
  49966. /**
  49967. * Set a vec2 in the shader from a Vector2.
  49968. * @param name Define the name of the uniform as defined in the shader
  49969. * @param value Define the value to give to the uniform
  49970. * @return the texture itself allowing "fluent" like uniform updates
  49971. */
  49972. setVector2(name: string, value: Vector2): ProceduralTexture;
  49973. /**
  49974. * Set a vec3 in the shader from a Vector3.
  49975. * @param name Define the name of the uniform as defined in the shader
  49976. * @param value Define the value to give to the uniform
  49977. * @return the texture itself allowing "fluent" like uniform updates
  49978. */
  49979. setVector3(name: string, value: Vector3): ProceduralTexture;
  49980. /**
  49981. * Set a mat4 in the shader from a MAtrix.
  49982. * @param name Define the name of the uniform as defined in the shader
  49983. * @param value Define the value to give to the uniform
  49984. * @return the texture itself allowing "fluent" like uniform updates
  49985. */
  49986. setMatrix(name: string, value: Matrix): ProceduralTexture;
  49987. /**
  49988. * Render the texture to its associated render target.
  49989. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49990. */
  49991. render(useCameraPostProcess?: boolean): void;
  49992. /**
  49993. * Clone the texture.
  49994. * @returns the cloned texture
  49995. */
  49996. clone(): ProceduralTexture;
  49997. /**
  49998. * Dispose the texture and release its asoociated resources.
  49999. */
  50000. dispose(): void;
  50001. }
  50002. }
  50003. declare module BABYLON {
  50004. interface AbstractScene {
  50005. /**
  50006. * The list of procedural textures added to the scene
  50007. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50008. */
  50009. proceduralTextures: Array<ProceduralTexture>;
  50010. }
  50011. /**
  50012. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  50013. * in a given scene.
  50014. */
  50015. class ProceduralTextureSceneComponent implements ISceneComponent {
  50016. /**
  50017. * The component name helpfull to identify the component in the list of scene components.
  50018. */
  50019. readonly name: string;
  50020. /**
  50021. * The scene the component belongs to.
  50022. */
  50023. scene: Scene;
  50024. /**
  50025. * Creates a new instance of the component for the given scene
  50026. * @param scene Defines the scene to register the component in
  50027. */
  50028. constructor(scene: Scene);
  50029. /**
  50030. * Registers the component in a given scene
  50031. */
  50032. register(): void;
  50033. /**
  50034. * Rebuilds the elements related to this component in case of
  50035. * context lost for instance.
  50036. */
  50037. rebuild(): void;
  50038. /**
  50039. * Disposes the component and the associated ressources.
  50040. */
  50041. dispose(): void;
  50042. private _beforeClear;
  50043. }
  50044. }
  50045. declare module BABYLON {
  50046. /**
  50047. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  50048. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50049. */
  50050. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50051. private _scene;
  50052. private _camerasToBeAttached;
  50053. /**
  50054. * ID of the sharpen post process,
  50055. */
  50056. private readonly SharpenPostProcessId;
  50057. /**
  50058. * @ignore
  50059. * ID of the image processing post process;
  50060. */
  50061. readonly ImageProcessingPostProcessId: string;
  50062. /**
  50063. * @ignore
  50064. * ID of the Fast Approximate Anti-Aliasing post process;
  50065. */
  50066. readonly FxaaPostProcessId: string;
  50067. /**
  50068. * ID of the chromatic aberration post process,
  50069. */
  50070. private readonly ChromaticAberrationPostProcessId;
  50071. /**
  50072. * ID of the grain post process
  50073. */
  50074. private readonly GrainPostProcessId;
  50075. /**
  50076. * Sharpen post process which will apply a sharpen convolution to enhance edges
  50077. */
  50078. sharpen: SharpenPostProcess;
  50079. private _sharpenEffect;
  50080. private bloom;
  50081. /**
  50082. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  50083. */
  50084. depthOfField: DepthOfFieldEffect;
  50085. /**
  50086. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50087. */
  50088. fxaa: FxaaPostProcess;
  50089. /**
  50090. * Image post processing pass used to perform operations such as tone mapping or color grading.
  50091. */
  50092. imageProcessing: ImageProcessingPostProcess;
  50093. /**
  50094. * Chromatic aberration post process which will shift rgb colors in the image
  50095. */
  50096. chromaticAberration: ChromaticAberrationPostProcess;
  50097. private _chromaticAberrationEffect;
  50098. /**
  50099. * Grain post process which add noise to the image
  50100. */
  50101. grain: GrainPostProcess;
  50102. private _grainEffect;
  50103. /**
  50104. * Glow post process which adds a glow to emmisive areas of the image
  50105. */
  50106. private _glowLayer;
  50107. /**
  50108. * Animations which can be used to tweak settings over a period of time
  50109. */
  50110. animations: Animation[];
  50111. private _imageProcessingConfigurationObserver;
  50112. private _sharpenEnabled;
  50113. private _bloomEnabled;
  50114. private _depthOfFieldEnabled;
  50115. private _depthOfFieldBlurLevel;
  50116. private _fxaaEnabled;
  50117. private _imageProcessingEnabled;
  50118. private _defaultPipelineTextureType;
  50119. private _bloomScale;
  50120. private _chromaticAberrationEnabled;
  50121. private _grainEnabled;
  50122. private _buildAllowed;
  50123. /**
  50124. * Enable or disable the sharpen process from the pipeline
  50125. */
  50126. sharpenEnabled: boolean;
  50127. private _resizeObserver;
  50128. private _hardwareScaleLevel;
  50129. private _bloomKernel;
  50130. /**
  50131. * Specifies the size of the bloom blur kernel, relative to the final output size
  50132. */
  50133. bloomKernel: number;
  50134. /**
  50135. * Specifies the weight of the bloom in the final rendering
  50136. */
  50137. private _bloomWeight;
  50138. /**
  50139. * Specifies the luma threshold for the area that will be blurred by the bloom
  50140. */
  50141. private _bloomThreshold;
  50142. private _hdr;
  50143. /**
  50144. * The strength of the bloom.
  50145. */
  50146. bloomWeight: number;
  50147. /**
  50148. * The strength of the bloom.
  50149. */
  50150. bloomThreshold: number;
  50151. /**
  50152. * The scale of the bloom, lower value will provide better performance.
  50153. */
  50154. bloomScale: number;
  50155. /**
  50156. * Enable or disable the bloom from the pipeline
  50157. */
  50158. bloomEnabled: boolean;
  50159. private _rebuildBloom;
  50160. /**
  50161. * If the depth of field is enabled.
  50162. */
  50163. depthOfFieldEnabled: boolean;
  50164. /**
  50165. * Blur level of the depth of field effect. (Higher blur will effect performance)
  50166. */
  50167. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  50168. /**
  50169. * If the anti aliasing is enabled.
  50170. */
  50171. fxaaEnabled: boolean;
  50172. private _samples;
  50173. /**
  50174. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50175. */
  50176. samples: number;
  50177. /**
  50178. * If image processing is enabled.
  50179. */
  50180. imageProcessingEnabled: boolean;
  50181. /**
  50182. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  50183. */
  50184. glowLayerEnabled: boolean;
  50185. /**
  50186. * Enable or disable the chromaticAberration process from the pipeline
  50187. */
  50188. chromaticAberrationEnabled: boolean;
  50189. /**
  50190. * Enable or disable the grain process from the pipeline
  50191. */
  50192. grainEnabled: boolean;
  50193. /**
  50194. * @constructor
  50195. * @param name - The rendering pipeline name (default: "")
  50196. * @param hdr - If high dynamic range textures should be used (default: true)
  50197. * @param scene - The scene linked to this pipeline (default: the last created scene)
  50198. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  50199. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  50200. */
  50201. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  50202. /**
  50203. * Force the compilation of the entire pipeline.
  50204. */
  50205. prepare(): void;
  50206. private _hasCleared;
  50207. private _prevPostProcess;
  50208. private _prevPrevPostProcess;
  50209. private _setAutoClearAndTextureSharing;
  50210. private _depthOfFieldSceneObserver;
  50211. private _buildPipeline;
  50212. private _disposePostProcesses;
  50213. /**
  50214. * Adds a camera to the pipeline
  50215. * @param camera the camera to be added
  50216. */
  50217. addCamera(camera: Camera): void;
  50218. /**
  50219. * Removes a camera from the pipeline
  50220. * @param camera the camera to remove
  50221. */
  50222. removeCamera(camera: Camera): void;
  50223. /**
  50224. * Dispose of the pipeline and stop all post processes
  50225. */
  50226. dispose(): void;
  50227. /**
  50228. * Serialize the rendering pipeline (Used when exporting)
  50229. * @returns the serialized object
  50230. */
  50231. serialize(): any;
  50232. /**
  50233. * Parse the serialized pipeline
  50234. * @param source Source pipeline.
  50235. * @param scene The scene to load the pipeline to.
  50236. * @param rootUrl The URL of the serialized pipeline.
  50237. * @returns An instantiated pipeline from the serialized object.
  50238. */
  50239. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  50240. }
  50241. }
  50242. declare module BABYLON {
  50243. /**
  50244. * BABYLON.JS Chromatic Aberration GLSL Shader
  50245. * Author: Olivier Guyot
  50246. * Separates very slightly R, G and B colors on the edges of the screen
  50247. * Inspired by Francois Tarlier & Martins Upitis
  50248. */
  50249. class LensRenderingPipeline extends PostProcessRenderPipeline {
  50250. /**
  50251. * @ignore
  50252. * The chromatic aberration PostProcess id in the pipeline
  50253. */
  50254. LensChromaticAberrationEffect: string;
  50255. /**
  50256. * @ignore
  50257. * The highlights enhancing PostProcess id in the pipeline
  50258. */
  50259. HighlightsEnhancingEffect: string;
  50260. /**
  50261. * @ignore
  50262. * The depth-of-field PostProcess id in the pipeline
  50263. */
  50264. LensDepthOfFieldEffect: string;
  50265. private _scene;
  50266. private _depthTexture;
  50267. private _grainTexture;
  50268. private _chromaticAberrationPostProcess;
  50269. private _highlightsPostProcess;
  50270. private _depthOfFieldPostProcess;
  50271. private _edgeBlur;
  50272. private _grainAmount;
  50273. private _chromaticAberration;
  50274. private _distortion;
  50275. private _highlightsGain;
  50276. private _highlightsThreshold;
  50277. private _dofDistance;
  50278. private _dofAperture;
  50279. private _dofDarken;
  50280. private _dofPentagon;
  50281. private _blurNoise;
  50282. /**
  50283. * @constructor
  50284. *
  50285. * Effect parameters are as follow:
  50286. * {
  50287. * chromatic_aberration: number; // from 0 to x (1 for realism)
  50288. * edge_blur: number; // from 0 to x (1 for realism)
  50289. * distortion: number; // from 0 to x (1 for realism)
  50290. * grain_amount: number; // from 0 to 1
  50291. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  50292. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  50293. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  50294. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  50295. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  50296. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  50297. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  50298. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  50299. * }
  50300. * Note: if an effect parameter is unset, effect is disabled
  50301. *
  50302. * @param name The rendering pipeline name
  50303. * @param parameters - An object containing all parameters (see above)
  50304. * @param scene The scene linked to this pipeline
  50305. * @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)
  50306. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50307. */
  50308. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  50309. /**
  50310. * Sets the amount of blur at the edges
  50311. * @param amount blur amount
  50312. */
  50313. setEdgeBlur(amount: number): void;
  50314. /**
  50315. * Sets edge blur to 0
  50316. */
  50317. disableEdgeBlur(): void;
  50318. /**
  50319. * Sets the amout of grain
  50320. * @param amount Amount of grain
  50321. */
  50322. setGrainAmount(amount: number): void;
  50323. /**
  50324. * Set grain amount to 0
  50325. */
  50326. disableGrain(): void;
  50327. /**
  50328. * Sets the chromatic aberration amount
  50329. * @param amount amount of chromatic aberration
  50330. */
  50331. setChromaticAberration(amount: number): void;
  50332. /**
  50333. * Sets chromatic aberration amount to 0
  50334. */
  50335. disableChromaticAberration(): void;
  50336. /**
  50337. * Sets the EdgeDistortion amount
  50338. * @param amount amount of EdgeDistortion
  50339. */
  50340. setEdgeDistortion(amount: number): void;
  50341. /**
  50342. * Sets edge distortion to 0
  50343. */
  50344. disableEdgeDistortion(): void;
  50345. /**
  50346. * Sets the FocusDistance amount
  50347. * @param amount amount of FocusDistance
  50348. */
  50349. setFocusDistance(amount: number): void;
  50350. /**
  50351. * Disables depth of field
  50352. */
  50353. disableDepthOfField(): void;
  50354. /**
  50355. * Sets the Aperture amount
  50356. * @param amount amount of Aperture
  50357. */
  50358. setAperture(amount: number): void;
  50359. /**
  50360. * Sets the DarkenOutOfFocus amount
  50361. * @param amount amount of DarkenOutOfFocus
  50362. */
  50363. setDarkenOutOfFocus(amount: number): void;
  50364. /**
  50365. * Creates a pentagon bokeh effect
  50366. */
  50367. enablePentagonBokeh(): void;
  50368. /**
  50369. * Disables the pentagon bokeh effect
  50370. */
  50371. disablePentagonBokeh(): void;
  50372. /**
  50373. * Enables noise blur
  50374. */
  50375. enableNoiseBlur(): void;
  50376. /**
  50377. * Disables noise blur
  50378. */
  50379. disableNoiseBlur(): void;
  50380. /**
  50381. * Sets the HighlightsGain amount
  50382. * @param amount amount of HighlightsGain
  50383. */
  50384. setHighlightsGain(amount: number): void;
  50385. /**
  50386. * Sets the HighlightsThreshold amount
  50387. * @param amount amount of HighlightsThreshold
  50388. */
  50389. setHighlightsThreshold(amount: number): void;
  50390. /**
  50391. * Disables highlights
  50392. */
  50393. disableHighlights(): void;
  50394. /**
  50395. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50396. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50397. */
  50398. dispose(disableDepthRender?: boolean): void;
  50399. private _createChromaticAberrationPostProcess;
  50400. private _createHighlightsPostProcess;
  50401. private _createDepthOfFieldPostProcess;
  50402. private _createGrainTexture;
  50403. }
  50404. }
  50405. declare module BABYLON {
  50406. /**
  50407. * Render pipeline to produce ssao effect
  50408. */
  50409. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50410. /**
  50411. * @ignore
  50412. * The PassPostProcess id in the pipeline that contains the original scene color
  50413. */
  50414. SSAOOriginalSceneColorEffect: string;
  50415. /**
  50416. * @ignore
  50417. * The SSAO PostProcess id in the pipeline
  50418. */
  50419. SSAORenderEffect: string;
  50420. /**
  50421. * @ignore
  50422. * The horizontal blur PostProcess id in the pipeline
  50423. */
  50424. SSAOBlurHRenderEffect: string;
  50425. /**
  50426. * @ignore
  50427. * The vertical blur PostProcess id in the pipeline
  50428. */
  50429. SSAOBlurVRenderEffect: string;
  50430. /**
  50431. * @ignore
  50432. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50433. */
  50434. SSAOCombineRenderEffect: string;
  50435. /**
  50436. * The output strength of the SSAO post-process. Default value is 1.0.
  50437. */
  50438. totalStrength: number;
  50439. /**
  50440. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50441. */
  50442. maxZ: number;
  50443. /**
  50444. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50445. */
  50446. minZAspect: number;
  50447. private _samples;
  50448. /**
  50449. * Number of samples used for the SSAO calculations. Default value is 8
  50450. */
  50451. samples: number;
  50452. private _textureSamples;
  50453. /**
  50454. * Number of samples to use for antialiasing
  50455. */
  50456. textureSamples: number;
  50457. /**
  50458. * Ratio object used for SSAO ratio and blur ratio
  50459. */
  50460. private _ratio;
  50461. /**
  50462. * Dynamically generated sphere sampler.
  50463. */
  50464. private _sampleSphere;
  50465. /**
  50466. * Blur filter offsets
  50467. */
  50468. private _samplerOffsets;
  50469. private _expensiveBlur;
  50470. /**
  50471. * If bilateral blur should be used
  50472. */
  50473. expensiveBlur: boolean;
  50474. /**
  50475. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50476. */
  50477. radius: number;
  50478. /**
  50479. * The base color of the SSAO post-process
  50480. * The final result is "base + ssao" between [0, 1]
  50481. */
  50482. base: number;
  50483. /**
  50484. * Support test.
  50485. */
  50486. static readonly IsSupported: boolean;
  50487. private _scene;
  50488. private _depthTexture;
  50489. private _normalTexture;
  50490. private _randomTexture;
  50491. private _originalColorPostProcess;
  50492. private _ssaoPostProcess;
  50493. private _blurHPostProcess;
  50494. private _blurVPostProcess;
  50495. private _ssaoCombinePostProcess;
  50496. private _firstUpdate;
  50497. /**
  50498. * @constructor
  50499. * @param name The rendering pipeline name
  50500. * @param scene The scene linked to this pipeline
  50501. * @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 }
  50502. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50503. */
  50504. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50505. /**
  50506. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50507. */
  50508. dispose(disableGeometryBufferRenderer?: boolean): void;
  50509. private _createBlurPostProcess;
  50510. /** @hidden */
  50511. _rebuild(): void;
  50512. private _bits;
  50513. private _radicalInverse_VdC;
  50514. private _hammersley;
  50515. private _hemisphereSample_uniform;
  50516. private _generateHemisphere;
  50517. private _createSSAOPostProcess;
  50518. private _createSSAOCombinePostProcess;
  50519. private _createRandomTexture;
  50520. /**
  50521. * Serialize the rendering pipeline (Used when exporting)
  50522. * @returns the serialized object
  50523. */
  50524. serialize(): any;
  50525. /**
  50526. * Parse the serialized pipeline
  50527. * @param source Source pipeline.
  50528. * @param scene The scene to load the pipeline to.
  50529. * @param rootUrl The URL of the serialized pipeline.
  50530. * @returns An instantiated pipeline from the serialized object.
  50531. */
  50532. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50533. }
  50534. }
  50535. declare module BABYLON {
  50536. /**
  50537. * Render pipeline to produce ssao effect
  50538. */
  50539. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50540. /**
  50541. * @ignore
  50542. * The PassPostProcess id in the pipeline that contains the original scene color
  50543. */
  50544. SSAOOriginalSceneColorEffect: string;
  50545. /**
  50546. * @ignore
  50547. * The SSAO PostProcess id in the pipeline
  50548. */
  50549. SSAORenderEffect: string;
  50550. /**
  50551. * @ignore
  50552. * The horizontal blur PostProcess id in the pipeline
  50553. */
  50554. SSAOBlurHRenderEffect: string;
  50555. /**
  50556. * @ignore
  50557. * The vertical blur PostProcess id in the pipeline
  50558. */
  50559. SSAOBlurVRenderEffect: string;
  50560. /**
  50561. * @ignore
  50562. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50563. */
  50564. SSAOCombineRenderEffect: string;
  50565. /**
  50566. * The output strength of the SSAO post-process. Default value is 1.0.
  50567. */
  50568. totalStrength: number;
  50569. /**
  50570. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50571. */
  50572. radius: number;
  50573. /**
  50574. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50575. * Must not be equal to fallOff and superior to fallOff.
  50576. * Default value is 0.975
  50577. */
  50578. area: number;
  50579. /**
  50580. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50581. * Must not be equal to area and inferior to area.
  50582. * Default value is 0.0
  50583. */
  50584. fallOff: number;
  50585. /**
  50586. * The base color of the SSAO post-process
  50587. * The final result is "base + ssao" between [0, 1]
  50588. */
  50589. base: number;
  50590. private _scene;
  50591. private _depthTexture;
  50592. private _randomTexture;
  50593. private _originalColorPostProcess;
  50594. private _ssaoPostProcess;
  50595. private _blurHPostProcess;
  50596. private _blurVPostProcess;
  50597. private _ssaoCombinePostProcess;
  50598. private _firstUpdate;
  50599. /**
  50600. * @constructor
  50601. * @param name - The rendering pipeline name
  50602. * @param scene - The scene linked to this pipeline
  50603. * @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 }
  50604. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50605. */
  50606. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50607. /**
  50608. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50609. */
  50610. dispose(disableDepthRender?: boolean): void;
  50611. private _createBlurPostProcess;
  50612. /** @hidden */
  50613. _rebuild(): void;
  50614. private _createSSAOPostProcess;
  50615. private _createSSAOCombinePostProcess;
  50616. private _createRandomTexture;
  50617. }
  50618. }
  50619. declare module BABYLON {
  50620. /**
  50621. * Standard rendering pipeline
  50622. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50623. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  50624. */
  50625. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50626. /**
  50627. * Public members
  50628. */
  50629. /**
  50630. * Post-process which contains the original scene color before the pipeline applies all the effects
  50631. */
  50632. originalPostProcess: Nullable<PostProcess>;
  50633. /**
  50634. * Post-process used to down scale an image x4
  50635. */
  50636. downSampleX4PostProcess: Nullable<PostProcess>;
  50637. /**
  50638. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  50639. */
  50640. brightPassPostProcess: Nullable<PostProcess>;
  50641. /**
  50642. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  50643. */
  50644. blurHPostProcesses: PostProcess[];
  50645. /**
  50646. * Post-process array storing all the vertical blur post-processes used by the pipeline
  50647. */
  50648. blurVPostProcesses: PostProcess[];
  50649. /**
  50650. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  50651. */
  50652. textureAdderPostProcess: Nullable<PostProcess>;
  50653. /**
  50654. * Post-process used to create volumetric lighting effect
  50655. */
  50656. volumetricLightPostProcess: Nullable<PostProcess>;
  50657. /**
  50658. * Post-process used to smooth the previous volumetric light post-process on the X axis
  50659. */
  50660. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  50661. /**
  50662. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  50663. */
  50664. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  50665. /**
  50666. * Post-process used to merge the volumetric light effect and the real scene color
  50667. */
  50668. volumetricLightMergePostProces: Nullable<PostProcess>;
  50669. /**
  50670. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  50671. */
  50672. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  50673. /**
  50674. * Base post-process used to calculate the average luminance of the final image for HDR
  50675. */
  50676. luminancePostProcess: Nullable<PostProcess>;
  50677. /**
  50678. * Post-processes used to create down sample post-processes in order to get
  50679. * the average luminance of the final image for HDR
  50680. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  50681. */
  50682. luminanceDownSamplePostProcesses: PostProcess[];
  50683. /**
  50684. * Post-process used to create a HDR effect (light adaptation)
  50685. */
  50686. hdrPostProcess: Nullable<PostProcess>;
  50687. /**
  50688. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  50689. */
  50690. textureAdderFinalPostProcess: Nullable<PostProcess>;
  50691. /**
  50692. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  50693. */
  50694. lensFlareFinalPostProcess: Nullable<PostProcess>;
  50695. /**
  50696. * Post-process used to merge the final HDR post-process and the real scene color
  50697. */
  50698. hdrFinalPostProcess: Nullable<PostProcess>;
  50699. /**
  50700. * Post-process used to create a lens flare effect
  50701. */
  50702. lensFlarePostProcess: Nullable<PostProcess>;
  50703. /**
  50704. * Post-process that merges the result of the lens flare post-process and the real scene color
  50705. */
  50706. lensFlareComposePostProcess: Nullable<PostProcess>;
  50707. /**
  50708. * Post-process used to create a motion blur effect
  50709. */
  50710. motionBlurPostProcess: Nullable<PostProcess>;
  50711. /**
  50712. * Post-process used to create a depth of field effect
  50713. */
  50714. depthOfFieldPostProcess: Nullable<PostProcess>;
  50715. /**
  50716. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50717. */
  50718. fxaaPostProcess: Nullable<FxaaPostProcess>;
  50719. /**
  50720. * Represents the brightness threshold in order to configure the illuminated surfaces
  50721. */
  50722. brightThreshold: number;
  50723. /**
  50724. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  50725. */
  50726. blurWidth: number;
  50727. /**
  50728. * Sets if the blur for highlighted surfaces must be only horizontal
  50729. */
  50730. horizontalBlur: boolean;
  50731. /**
  50732. * Sets the overall exposure used by the pipeline
  50733. */
  50734. exposure: number;
  50735. /**
  50736. * Texture used typically to simulate "dirty" on camera lens
  50737. */
  50738. lensTexture: Nullable<Texture>;
  50739. /**
  50740. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  50741. */
  50742. volumetricLightCoefficient: number;
  50743. /**
  50744. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  50745. */
  50746. volumetricLightPower: number;
  50747. /**
  50748. * Used the set the blur intensity to smooth the volumetric lights
  50749. */
  50750. volumetricLightBlurScale: number;
  50751. /**
  50752. * Light (spot or directional) used to generate the volumetric lights rays
  50753. * The source light must have a shadow generate so the pipeline can get its
  50754. * depth map
  50755. */
  50756. sourceLight: Nullable<SpotLight | DirectionalLight>;
  50757. /**
  50758. * For eye adaptation, represents the minimum luminance the eye can see
  50759. */
  50760. hdrMinimumLuminance: number;
  50761. /**
  50762. * For eye adaptation, represents the decrease luminance speed
  50763. */
  50764. hdrDecreaseRate: number;
  50765. /**
  50766. * For eye adaptation, represents the increase luminance speed
  50767. */
  50768. hdrIncreaseRate: number;
  50769. /**
  50770. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  50771. */
  50772. lensColorTexture: Nullable<Texture>;
  50773. /**
  50774. * The overall strengh for the lens flare effect
  50775. */
  50776. lensFlareStrength: number;
  50777. /**
  50778. * Dispersion coefficient for lens flare ghosts
  50779. */
  50780. lensFlareGhostDispersal: number;
  50781. /**
  50782. * Main lens flare halo width
  50783. */
  50784. lensFlareHaloWidth: number;
  50785. /**
  50786. * Based on the lens distortion effect, defines how much the lens flare result
  50787. * is distorted
  50788. */
  50789. lensFlareDistortionStrength: number;
  50790. /**
  50791. * Lens star texture must be used to simulate rays on the flares and is available
  50792. * in the documentation
  50793. */
  50794. lensStarTexture: Nullable<Texture>;
  50795. /**
  50796. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  50797. * flare effect by taking account of the dirt texture
  50798. */
  50799. lensFlareDirtTexture: Nullable<Texture>;
  50800. /**
  50801. * Represents the focal length for the depth of field effect
  50802. */
  50803. depthOfFieldDistance: number;
  50804. /**
  50805. * Represents the blur intensity for the blurred part of the depth of field effect
  50806. */
  50807. depthOfFieldBlurWidth: number;
  50808. /**
  50809. * For motion blur, defines how much the image is blurred by the movement
  50810. */
  50811. motionStrength: number;
  50812. /**
  50813. * List of animations for the pipeline (IAnimatable implementation)
  50814. */
  50815. animations: Animation[];
  50816. /**
  50817. * Private members
  50818. */
  50819. private _scene;
  50820. private _currentDepthOfFieldSource;
  50821. private _basePostProcess;
  50822. private _hdrCurrentLuminance;
  50823. private _floatTextureType;
  50824. private _ratio;
  50825. private _bloomEnabled;
  50826. private _depthOfFieldEnabled;
  50827. private _vlsEnabled;
  50828. private _lensFlareEnabled;
  50829. private _hdrEnabled;
  50830. private _motionBlurEnabled;
  50831. private _fxaaEnabled;
  50832. private _motionBlurSamples;
  50833. private _volumetricLightStepsCount;
  50834. private _samples;
  50835. /**
  50836. * @ignore
  50837. * Specifies if the bloom pipeline is enabled
  50838. */
  50839. BloomEnabled: boolean;
  50840. /**
  50841. * @ignore
  50842. * Specifies if the depth of field pipeline is enabed
  50843. */
  50844. DepthOfFieldEnabled: boolean;
  50845. /**
  50846. * @ignore
  50847. * Specifies if the lens flare pipeline is enabed
  50848. */
  50849. LensFlareEnabled: boolean;
  50850. /**
  50851. * @ignore
  50852. * Specifies if the HDR pipeline is enabled
  50853. */
  50854. HDREnabled: boolean;
  50855. /**
  50856. * @ignore
  50857. * Specifies if the volumetric lights scattering effect is enabled
  50858. */
  50859. VLSEnabled: boolean;
  50860. /**
  50861. * @ignore
  50862. * Specifies if the motion blur effect is enabled
  50863. */
  50864. MotionBlurEnabled: boolean;
  50865. /**
  50866. * Specifies if anti-aliasing is enabled
  50867. */
  50868. fxaaEnabled: boolean;
  50869. /**
  50870. * Specifies the number of steps used to calculate the volumetric lights
  50871. * Typically in interval [50, 200]
  50872. */
  50873. volumetricLightStepsCount: number;
  50874. /**
  50875. * Specifies the number of samples used for the motion blur effect
  50876. * Typically in interval [16, 64]
  50877. */
  50878. motionBlurSamples: number;
  50879. /**
  50880. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50881. */
  50882. samples: number;
  50883. /**
  50884. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50885. * @constructor
  50886. * @param name The rendering pipeline name
  50887. * @param scene The scene linked to this pipeline
  50888. * @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)
  50889. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  50890. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50891. */
  50892. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  50893. private _buildPipeline;
  50894. private _createDownSampleX4PostProcess;
  50895. private _createBrightPassPostProcess;
  50896. private _createBlurPostProcesses;
  50897. private _createTextureAdderPostProcess;
  50898. private _createVolumetricLightPostProcess;
  50899. private _createLuminancePostProcesses;
  50900. private _createHdrPostProcess;
  50901. private _createLensFlarePostProcess;
  50902. private _createDepthOfFieldPostProcess;
  50903. private _createMotionBlurPostProcess;
  50904. private _getDepthTexture;
  50905. private _disposePostProcesses;
  50906. /**
  50907. * Dispose of the pipeline and stop all post processes
  50908. */
  50909. dispose(): void;
  50910. /**
  50911. * Serialize the rendering pipeline (Used when exporting)
  50912. * @returns the serialized object
  50913. */
  50914. serialize(): any;
  50915. /**
  50916. * Parse the serialized pipeline
  50917. * @param source Source pipeline.
  50918. * @param scene The scene to load the pipeline to.
  50919. * @param rootUrl The URL of the serialized pipeline.
  50920. * @returns An instantiated pipeline from the serialized object.
  50921. */
  50922. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  50923. /**
  50924. * Luminance steps
  50925. */
  50926. static LuminanceSteps: number;
  50927. }
  50928. }